Page 1 of 1
Reduce image resolution
Posted: Tue Dec 30, 2014 6:21 am
by shoshinsha
Hi All,
Would like to know if there is any way to reduce image resolution?
I'm using mobilePickPhoto to take/pick a photo, but the maxWidth and maxHeight parameters are only available on iOS devices.
So I'm trying to figure out a way to do so for Android.
Although I'm able to downsize the image "physically" (the height and width on screen), but when the image is uploaded (to our server), it is still of the original size.
Thanks and regards,
Vikki.
Re: Reduce image resolution
Posted: Tue Dec 30, 2014 6:35 am
by Simon
Hi Vikki,
After you resize the image
Code: Select all
set the imagedata of image "myImage" to the imagedata of image "myImage"
Super cool
Simon
Re: Reduce image resolution
Posted: Tue Dec 30, 2014 11:16 am
by shoshinsha
Hi Simon,
Thanks for the workaround. But if I use the set imagedata function my image will be broken after uploaded to the server...
And the image is sometimes not "processed" (image area is shown as blank after taking a picture). The image could not be "reference" to another card too.
On my stack:
Code: Select all
on upload_take_photo
mobilePickPhoto "camera", 500, 667
if the result = "" then
put the last image into image "mypic" of card "campaign1"
send "resize_img" to me in 0 second ##the function to resize the image
set the imagedata of image "mypic" of card "campaign1" to the imagedata of image "mypic" of card "campaign1"
...
end upload_take_photo
The image after uploaded:
http://vo.my/p/4U/4UWISP/f/Image.jpg
Thank you.
Re: Reduce image resolution
Posted: Tue Dec 30, 2014 4:58 pm
by MaxV
Why do you
send the message "resize_image"?
Code: Select all
on upload_take_photo
mobilePickPhoto "camera", 500, 667
if the result = "" then
put the last image into image "mypic" of card "campaign1"
resize_img
set the imagedata of image "mypic" of card "campaign1" to the imagedata of image "mypic" of card "campaign1"
...
end upload_take_photo
Re: Reduce image resolution
Posted: Wed Dec 31, 2014 12:07 am
by William Jamieson
I ran into this the other day. For some reason my Livecode crashes when I have a 4MB photo placed on the stack as the last image after using MobilePickPhoto
Here was my solution that worked really well, really fast, and ready to be put into the server.
I downsize the photo immediately into a size that is reasonable by using
Code: Select all
MobilePickPhoto "camera"
put the long id of the last image of this card into tID
set the layer of tID to 1 --I remove the image from sight
wait 10 milliseconds with messages --This takes a lot of processing power for my little android processor so I let it take a breath
lock screen
put myIdealHeight / the height of tID into tRatio --Maintains the aspect ratio
put the width of tID into tW
export snapshot of tID at size ((tW * tRatio), myIdealHeight) to myPhotoVariable as JPEG
delete tID
unlock screen
---Now do what ever you need with the binFile, put it in a URL, a folder, post it to a server, put it in an image object, send it to another mobile device, store it in a custom property (don't know why you would do that) etc. Once the file size is smaller, it is easier for the processor to work with so you wont have to worry about lag time.
This code hasn't failed yet. Even tried using on my tablet from times BC and still worked. Takes about 50-80 milliseconds for me.
Hope this helps!
Cheers,
-Will
Re: Reduce image resolution
Posted: Mon Jan 05, 2015 2:29 am
by shoshinsha