Reduce image resolution
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 35
- Joined: Fri Jul 18, 2014 5:17 am
Reduce image resolution
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.
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
Hi Vikki,
After you resize the image
Super cool 
Simon
After you resize the image
Code: Select all
set the imagedata of image "myImage" to the imagedata of image "myImage"

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- Posts: 35
- Joined: Fri Jul 18, 2014 5:17 am
Re: Reduce image resolution
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:
The image after uploaded: http://vo.my/p/4U/4UWISP/f/Image.jpg
Thank you.
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
Thank you.
Re: Reduce image resolution
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
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- VIP Livecode Opensource Backer
- Posts: 212
- Joined: Fri Feb 01, 2013 1:31 am
- Contact:
Re: Reduce image resolution
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
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
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.
Hope this helps!
Cheers,
-Will
-
- Posts: 35
- Joined: Fri Jul 18, 2014 5:17 am
Re: Reduce image resolution
It works!
Thanks, Will!!



Thanks, Will!!