Re-size an image file (not display object) within Corona app

My application allows users to select images from the native PhotoLibrary, it then copies the file from there to the documents sandbox. No problem there, it all works.

I am just worried that since this procedure does not discriminate against the dimensions of an image the user could potentially fill up this sandbox really fast - not to mention slowing things down when I display these images in a slide show.

Is there a function where I can re-size or compress an image after or during the point where I copy it to the documents directory?

I guess I could ‘save’ a capture of the display object but as I understand, that will only save what is within the display bounds and be limited to the current devices screen resolution ( making zooming on the image later a bit of a non-option )

Any help in regards to image compression or re-sizing (within an app) would be greatly appreciated. [import]uid: 68276 topic_id: 36708 reply_id: 336708[/import]

So nobody knows about this? I’m not smart enough to code my own compression class, I just thought someone must have made one by now… [import]uid: 68276 topic_id: 36708 reply_id: 145577[/import]

I’ve only tinkered with saving things, but I do a lot of digital photography and image manipulation. Compression only affects the size of the file in storage. A 2000 x 1500 pixel image compressed at 75% is still a 2000x1500 pixel image compressed at 50%. The amount of storage taken up on the device would be less at 50%, but the in-memory size, how long it takes to process and such will be the same since the image size is the same.

In theory you would load the image in, if it’s bigger than the screen (or some other arbitrary size) you could scale the display image to make it fit the screen (or your box), then capture that screen image and save it out and you would have a fairly consistent scaled image.
[import]uid: 199310 topic_id: 36708 reply_id: 145602[/import]

Ok, sure, it will use up just the same amount of video memory no matter the compression. How about scaling down the image? That is more what I am interested in. i.e making a 3000 x 4000 image 1500 x 2000.
Capturing a screen seems a bit backwards. 1. it will garner different result on different devices. 2. It won’t preserve any detail greater than the screen dimension. It might be my only solution here… but it will remove the ability to zoom in and have clarity.

I am just worried that technically, a user could use an image they got online (something huge in their library).

Thanks for your comments anyway. I will be a paying customer soon :slight_smile: [import]uid: 68276 topic_id: 36708 reply_id: 145611[/import]

Well a 4000x3000 image in memory takes up a 4096x4096 block of texture memory or 64MB of memory. The image scaled to 1500x2000 is a 2048x2048 block of memory or 16MB, so big images to eat up more memory.

Corona wasn’t built as an image manipulating SDK. It’s a tool for putting small graphics on the screen and moving them around. There are three different API Calls to save images, which includes capturing screens, capturing display groups and one other. They really are there to record screens shots and not about optimizing images.

[import]uid: 199310 topic_id: 36708 reply_id: 145693[/import]

So nobody knows about this? I’m not smart enough to code my own compression class, I just thought someone must have made one by now… [import]uid: 68276 topic_id: 36708 reply_id: 145577[/import]

I’ve only tinkered with saving things, but I do a lot of digital photography and image manipulation. Compression only affects the size of the file in storage. A 2000 x 1500 pixel image compressed at 75% is still a 2000x1500 pixel image compressed at 50%. The amount of storage taken up on the device would be less at 50%, but the in-memory size, how long it takes to process and such will be the same since the image size is the same.

In theory you would load the image in, if it’s bigger than the screen (or some other arbitrary size) you could scale the display image to make it fit the screen (or your box), then capture that screen image and save it out and you would have a fairly consistent scaled image.
[import]uid: 199310 topic_id: 36708 reply_id: 145602[/import]

Ok, sure, it will use up just the same amount of video memory no matter the compression. How about scaling down the image? That is more what I am interested in. i.e making a 3000 x 4000 image 1500 x 2000.
Capturing a screen seems a bit backwards. 1. it will garner different result on different devices. 2. It won’t preserve any detail greater than the screen dimension. It might be my only solution here… but it will remove the ability to zoom in and have clarity.

I am just worried that technically, a user could use an image they got online (something huge in their library).

Thanks for your comments anyway. I will be a paying customer soon :slight_smile: [import]uid: 68276 topic_id: 36708 reply_id: 145611[/import]

Well a 4000x3000 image in memory takes up a 4096x4096 block of texture memory or 64MB of memory. The image scaled to 1500x2000 is a 2048x2048 block of memory or 16MB, so big images to eat up more memory.

Corona wasn’t built as an image manipulating SDK. It’s a tool for putting small graphics on the screen and moving them around. There are three different API Calls to save images, which includes capturing screens, capturing display groups and one other. They really are there to record screens shots and not about optimizing images.

[import]uid: 199310 topic_id: 36708 reply_id: 145693[/import]