Crop or resize image

I know this has been asked a few times here but those posts were mainly old or before graphics 2.0 so asking myself now.

I have a project to create a business app, with main aim to edit photos, now I found most of the photo filters I needed in graphics 2.0 and was happy to know that I can actually develop a non-game app in corona rather then my regular Obj-C

But I still need 2 things in app, the user should be able to crop or resize the image. Is it possible ? Can anyone throw some hints or point me in proper direction ?

I read a few posts about using masks but if I use a mask image, it will have a fixed size. I want a interaction, possibly a rectangle or square of lines over the image, which user can use to select the region (stretch or expand or contract) he wants to crop the image, its somewhat like how you do it in photoshop or using native 3rd party libraries.

Is it currently possible to do so or using masks ?
And any tips or ideas on providing a interactive re-sizing of image ?

I really want to try and develop this app in corona to see the extent of corona on non-games app so that I can possibly do my future projects in corona too.

One thing to keep in mind is that you’ll be limited by the max texture size of the device when loading images (usually 2048 or 4096)

This means images larger than 2048px / 4096px  width or height will not load at full resolution.

There’s an ‘isFullResolution’ option when loading an image, but it doesn’t guarantee that the full resolution will be loaded without downsampling.

See the ‘Gotchas’ section in the docs:

http://docs.coronalabs.com/api/library/display/newImage.html 

The “Marching Ants” filter is what you after, if you want to display something visually similar to photoshop, for the user to appear to be selecting an area of the image to crop :slight_smile:

Well that won’t be a problem since the images to edit are the ones taken via device camera, what I want to know is if crop and resize is possible and if yes, then how.

Okay that do looks probably what can be used, but how to use marching ants as a dynamic rect/frame for crop or resize, do I use it as/over a mask ?

It’s something you should consider since many devices have cameras with 8MP (or more) which exceed the max texture size of an OpenGL app. If you can live with some downsampling, then it’s OK. Downsampling occurs more on Android than on iOS.

Well I am not concerned about downsampling and can cope up with that but concerned whether I can and should use corona for this project or not

My major concern right now is how to handle image cropping and resizing interactively

I believe there was a pinch/zoom/rotate tutorial by horacebury on the Corona blog. That could be a good place to start, as it shows resizing an image at runtime, in a sense.

You should be able to find it via a google search. I believe the code is also available on the old Corona code exchange.

I think this is the one:

http://coronalabs.com/blog/2013/01/22/implementing-pinch-zoom-rotate/

One thing to keep in mind is that you’ll be limited by the max texture size of the device when loading images (usually 2048 or 4096)

This means images larger than 2048px / 4096px  width or height will not load at full resolution.

There’s an ‘isFullResolution’ option when loading an image, but it doesn’t guarantee that the full resolution will be loaded without downsampling.

See the ‘Gotchas’ section in the docs:

http://docs.coronalabs.com/api/library/display/newImage.html 

The “Marching Ants” filter is what you after, if you want to display something visually similar to photoshop, for the user to appear to be selecting an area of the image to crop :slight_smile:

Well that won’t be a problem since the images to edit are the ones taken via device camera, what I want to know is if crop and resize is possible and if yes, then how.

Okay that do looks probably what can be used, but how to use marching ants as a dynamic rect/frame for crop or resize, do I use it as/over a mask ?

It’s something you should consider since many devices have cameras with 8MP (or more) which exceed the max texture size of an OpenGL app. If you can live with some downsampling, then it’s OK. Downsampling occurs more on Android than on iOS.

Well I am not concerned about downsampling and can cope up with that but concerned whether I can and should use corona for this project or not

My major concern right now is how to handle image cropping and resizing interactively

I believe there was a pinch/zoom/rotate tutorial by horacebury on the Corona blog. That could be a good place to start, as it shows resizing an image at runtime, in a sense.

You should be able to find it via a google search. I believe the code is also available on the old Corona code exchange.

I think this is the one:

http://coronalabs.com/blog/2013/01/22/implementing-pinch-zoom-rotate/