Anyway to reduce image quality for Internet Load

I have a “cloud” based app which is written in Corona.  I am coming into problems with how some of the functionality works with regards images.

One of my screens allows the user to either take a photo or load a photo from their library.  I use the standard sdk tools such as media.capturePhoto and media.selectPhoto.

The problem is that the newer types of Tablet are now taking photos at increasingly higher resolution.  My app loads the image into a cloud server so I am using the end user’s standard internet connection for the load.

I don’t need an HD image, but the load time is of HD image so on a UK mega slow 6 mb internet connection the user could be waiting 20 to 25 seconds for the load to complete.  Not really the snappy response I originally intended.

Is there any tools anyone knows about that would allow me to reduce an image within LUA prior to the load?  My thinking is I keep a little database of different devices.  If it is an IPAD 2 I reduce the image by 50% in quality.  IPAD Air, maybe reduce by 70%.  Android Hudl 2, maybe reduce quality by 25%.

At present, I am doing something like this, but only at the server layer (e.g. after the image has arrived).  I currently reduce the file size prior to loading it into my database, but this is written in .Net code and uses a load of Microsoft built in functions that I am struggling to find in the Lua or Corona code base.

I basically want to create a new image, based on the user image, reduce everything by a percentage, save it and then load it!

Anyway, I am waffling on here.  Hope you understand my issue.  Any ideas?

Actually you may be over thinking it a bit.  Load the image, scale it to some fixed size, say you always want 1024px on the wide side.  Put that scaled image in a display.newGroup() and there is on of the display.save() function.

local tmpPic = display.newImage(“yoursavedimagefile”, display.contentCenterX, display.contentCenterY) – or any other way to get a display object from your captured image

local scale

if tmpPic.width > tmpPic.height then

     scale = 1024 / tmpPic.width

else

     scale = 1024 / tmpPic.height

end

tmpPic:scale( scale, scale)

display.save(tmpPic, { filename = “yourfilename.jpg”, baseDir = system.TemporaryDirectory, jpegQuality = 0.75 } )

or something like that (untested).

Rob

Rob’s suggestion is the technique I use when I need to ‘shrink’ an image for upload.  It works fine.

Actually you may be over thinking it a bit.  Load the image, scale it to some fixed size, say you always want 1024px on the wide side.  Put that scaled image in a display.newGroup() and there is on of the display.save() function.

local tmpPic = display.newImage(“yoursavedimagefile”, display.contentCenterX, display.contentCenterY) – or any other way to get a display object from your captured image

local scale

if tmpPic.width > tmpPic.height then

     scale = 1024 / tmpPic.width

else

     scale = 1024 / tmpPic.height

end

tmpPic:scale( scale, scale)

display.save(tmpPic, { filename = “yourfilename.jpg”, baseDir = system.TemporaryDirectory, jpegQuality = 0.75 } )

or something like that (untested).

Rob

Rob’s suggestion is the technique I use when I need to ‘shrink’ an image for upload.  It works fine.