Lua File Compression Library

Hi, has anyone managed to find or get a file compression system working with Corona? I see some libraries out there for it but it looks like most require that you include a c file which is a bit of a problem. I have some large XML files that are taking up the build of my build size. Compressing them would drastically drop the file size i send to the app store being as they are really just text files and highly compressible.

Also, I know this is on the roadmap but that doesn’t exactly help atm :slight_smile: [import]uid: 147305 topic_id: 29852 reply_id: 329852[/import]

I did find one, but they aren’t going to be very fast for anything of significant size on a device. The problem is that lua 5.1 doesn’t have any bit operations, so they have to be implemented with really slow divide and mod operations. Even something simple like base64 takes a long time on a 10K file using Lua only code, so doing gzip would be really bad I think. If we had a bit library available, or lua 5.2, we might have a better chance (or just a gzip library :slight_smile:

This one is pure lua.
http://code.google.com/p/eoi/source/browse/trunk/LibCompress.lua

– LibCompress.lua

– Authors: jjsheets and Galmok of European Stormrage (Horde)
– Email : sheets.jeff@gmail.com and galmok@gmail.com
– Licence: GPL version 2 (General Public License) [import]uid: 122310 topic_id: 29852 reply_id: 119749[/import]

I’ll probably see about implementing that in the next two weeks. I am actually not too worried about performance as my only concern is making the deployable app size smaller. I am completely OK if the user has a 1 time wait while I uncompress things.

Thanks for the info! [import]uid: 147305 topic_id: 29852 reply_id: 119751[/import]

you also might want to write your own simple custom compression for the XML file, since XML is not very compact (which is why it compresses so well).

For example, if you are doing something like

<defineitemforpurchase><br> <itemname>Gems</itemname><br> <itemcostindollars>1.29</itemcostindollars><br></defineitemforpurchase>  

you could just do

<di><n>Gems</n><c>1.29</c></di> [import]uid: 122310 topic_id: 29852 reply_id: 119754[/import]

I did find one, but they aren’t going to be very fast for anything of significant size on a device. The problem is that lua 5.1 doesn’t have any bit operations, so they have to be implemented with really slow divide and mod operations. Even something simple like base64 takes a long time on a 10K file using Lua only code, so doing gzip would be really bad I think. If we had a bit library available, or lua 5.2, we might have a better chance (or just a gzip library :slight_smile:

This one is pure lua.
http://code.google.com/p/eoi/source/browse/trunk/LibCompress.lua

– LibCompress.lua

– Authors: jjsheets and Galmok of European Stormrage (Horde)
– Email : sheets.jeff@gmail.com and galmok@gmail.com
– Licence: GPL version 2 (General Public License) [import]uid: 122310 topic_id: 29852 reply_id: 119749[/import]

I’ll probably see about implementing that in the next two weeks. I am actually not too worried about performance as my only concern is making the deployable app size smaller. I am completely OK if the user has a 1 time wait while I uncompress things.

Thanks for the info! [import]uid: 147305 topic_id: 29852 reply_id: 119751[/import]

you also might want to write your own simple custom compression for the XML file, since XML is not very compact (which is why it compresses so well).

For example, if you are doing something like

<defineitemforpurchase><br> <itemname>Gems</itemname><br> <itemcostindollars>1.29</itemcostindollars><br></defineitemforpurchase>  

you could just do

<di><n>Gems</n><c>1.29</c></di> [import]uid: 122310 topic_id: 29852 reply_id: 119754[/import]

hi there ,

Im new here .and I just compress image using some sample codes.and I found image compression libraryand copied the sample code ,however It dosen’t work for me.anyone can help me out?

using System.IO;
using System.Drawing.Printing;
using RasterEdge.Imaging;
using RasterEdge.Imaging.Codec.Compression;

ImageCompression.infile(@“C:\1.tif”);
ImageCompression.Outfile(@“C:\2.tif”);
ImageEncoder = ImageEncoder.Group3Encoding

RasterEdgeImaging Image = new RasterEdgeImaging();
Image.ImageCompression(@“C:\1.tif”, “C:\2.tif”, ImageEncoder ImageEncoder.Group3Encoding);

XML are text files.  They should be compressed for you when building the app bundle.  iOS produces a .ZIP file and .APK’s are just renamed .ZIP files anyway.

That library is written in C#, Corona uses Lua.

hi there ,

Im new here .and I just compress image using some sample codes.and I found image compression libraryand copied the sample code ,however It dosen’t work for me.anyone can help me out?

using System.IO;
using System.Drawing.Printing;
using RasterEdge.Imaging;
using RasterEdge.Imaging.Codec.Compression;

ImageCompression.infile(@“C:\1.tif”);
ImageCompression.Outfile(@“C:\2.tif”);
ImageEncoder = ImageEncoder.Group3Encoding

RasterEdgeImaging Image = new RasterEdgeImaging();
Image.ImageCompression(@“C:\1.tif”, “C:\2.tif”, ImageEncoder ImageEncoder.Group3Encoding);

XML are text files.  They should be compressed for you when building the app bundle.  iOS produces a .ZIP file and .APK’s are just renamed .ZIP files anyway.

That library is written in C#, Corona uses Lua.