Compressing Images to be stored in Cloud

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Compressing Images to be stored in Cloud

Post by William Jamieson » Sat Jul 05, 2014 4:48 pm

I am making an application where users will be able to upload images that range anywhere from 80x80 pixels to 8000x8000 pixels. I will be storing these images using LiveCloud. Because I do not want to take up a lot of space on the cloud, I would like to compress the images that are larger before uploading them but as of right now, I do not know the process for that, and if that will be available for all platforms.

For example: If a user uploads an image that is 3000x3000 and is 5Mb in PNG format, I would like to compress it to 1500x1500 in less than 1Mb in PNG format.

What is the best way to accomplish this. The only commmand that I have seen that relates to this that is built into Livecode is "Crop." I know with JPEGs we also have the property "JPEGQuality". I have a feeling however that this will not preserve the alpha layer of a PNG image.

Does anyone have any experience with compressing images? If so, how did you do it?

Thank you for you input!

-Will
Last edited by William Jamieson on Sat Jul 05, 2014 5:01 pm, edited 1 time in total.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Compressing Images to be stored in Cloud

Post by Simon » Sat Jul 05, 2014 4:55 pm

Hey Will,
JPEG is a compression format.
It's already as small as it can get.
Go ahead and zip one, see how small it wont get.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Compressing Images to be stored in Cloud

Post by Klaus » Sat Jul 05, 2014 5:02 pm

Hi Will,
William Jamieson wrote:I have a feeling however that this will not preserve the alpha layer of a PNG image.l
yes, the JPEG format does NOT support alpha channels!

But also PNG is a compressed image format, try the same as Simon suggested with a PNG image :D


Best

Klaus

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: Compressing Images to be stored in Cloud

Post by William Jamieson » Sat Jul 05, 2014 5:12 pm

That is a really good point. Maybe I am not understanding how image compression works. I just thought that the images could become smaller because of what I have seen from other online services such as Wix.com and facebook.com (not anymore) and various other online services.

For example: If you go to Wix.com, sign up to create a free site, start creating a site, upload an image to be used in their editor, then in the editor re-download the image, the image will come back a fraction of the size per which you uploaded it. Also, Adobe Photoshop has 12 settings of compression for all compression formats.

So maybe I am not descibing what I am seeing correctly, or maybe it is impossible, but I am looking for the same function that allows that Wix and Adobe to make image files in a variety of sizes, in Livecode. Is that possible or did I miss the point?

-Will

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Compressing Images to be stored in Cloud

Post by Klaus » Sat Jul 05, 2014 5:19 pm

Hi Will,

unfortunately Livecode does not provide the tools for (smarter) image compression that dedicated image editors do.


Best

Klaus

Edit:
Maybe you can use a command line tool like "imageMagik" to do these tasks.
You could provide it with our app, no idea about the license however.

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: Compressing Images to be stored in Cloud

Post by William Jamieson » Sat Jul 05, 2014 5:27 pm

Yes, Imagemagick looks promising. I will look it up right now. Thank you for your suggestion Klaus!

I know that there is a livecode tutorial for using imageMagick here: http://livecode.com/academy/livecode-bu ... cademy/51/

I also looked on http://www.imageMagick.org and it said that it can resize PNGs so this looks like it might be the solution. As for the license, it is open source so there might not be any issues with licensing.

Thanks for your help Simon and Klaus!

-Will

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Compressing Images to be stored in Cloud

Post by Simon » Sat Jul 05, 2014 8:07 pm

Hey Will,
For example: If a user uploads an image that is 3000x3000 and is 5Mb in PNG format, I would like to compress it to 1500x1500 in less than 1Mb in PNG format.
Ah, resize... that will make the file smaller.

With an image object lock it's size and position (1500x1500) import the image (3000x3000) and then "export snapshot".
That will give you a smaller image in both weight and size (no guarantee on 1 MB).

Simon
Last edited by Simon on Sat Jul 05, 2014 11:23 pm, edited 1 time in total.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Compressing Images to be stored in Cloud

Post by SparkOut » Sat Jul 05, 2014 11:03 pm

What is the intention with regard to storage of the images? People will be uploading them - are they expecting to retrieve the same image back at any time?
If they are just going to be stored for display on screen as part of a web page then you can have themuupload a file 8000 x 8000 px and you can realistically convert to a much lower size. If the users are expecting to retrieve the image at the original quality, for photo printing for example, then you can't do much to save space.

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: Compressing Images to be stored in Cloud

Post by newtronsols » Sun Jul 06, 2014 10:09 pm

I've been testing using Livecloud and had been thinking about storing signatures created on Android with a form. But I wondered about UK security see http://ico.org.uk/ and database sizing implications. But as Livecloud's not able to be used for commercial projects 'yet' I have remained in a testing mode.

I think combining Livecode and Livecloud is fairly easy/elegant when you know how. I've kept testing via Android for reliability to see if I lose the connection - but so far so good. Sometimes I get a slowdown factor [but it could be my own wifi connection to my phone - highly likely!]. I should really sync local to cloud data and also prevent a duplicate click to send the same data more than once.

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: Compressing Images to be stored in Cloud

Post by William Jamieson » Tue Jul 08, 2014 2:00 am

The intention behind it is to be able to store large amounts of photos uploaded from people's mobile phones, which are typically 1-3MB, without having to take up a lot of storage space. Image quality is not of the most importance, but must be good enough to display clearly on a desktop screen.

@NewTronsols: I know nothing about security protocols. All I know is that Livecloud uses a 256 bit end to end encryption (meaning encrypted on the device, and on the server) while doing a few other things to keep people from breaking in. If you have any suggestions, I encourage you to talk to Mark about it because from what I know, he is always looking for ways to improve the security of the platform.

THE SOLUTION: Mark and his team at Canela software are talking about extending the features of Livecloud, one of them being image processing on the server side. I am sure if he gets enough people requesting it, he will move it up on the priority list. That way, this forum post becomes absolutely obsolete as it will be automatically taken care of by the LiveCLoud platform. So if you want automatic image resizing, then please go to http://www.livecloud.io, download Livecloud and ask mark to include it as a feature.

Otherwise, we can spend hours hashing out the API with imageMagick. :?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Compressing Images to be stored in Cloud

Post by FourthWorld » Tue Jul 08, 2014 2:41 am

If the client is made with LiveCode you can do the compression before the upload, making for a smoother user experience while eliminating a potential bottleneck on the server.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: Compressing Images to be stored in Cloud

Post by newtronsols » Tue Jul 08, 2014 7:14 pm

William,

My reference was about holding other people's data in the UK [in the cloud or otherwise] needing to register with ico.org.uk e.g. http://ico.org.uk/ESDWebPages/DoSearch?reg=446818 I had already assumed livecloud is encrypted and secure enough to hold personal data. The onus would be on me to register my use of other people's data.

My personal concern was about the idea of 'me' holding other people's signatures as a graphic in the cloud - whether to do it or not. By not keeping a graphic signature the database size for my idea would remain very small and less risky for users.

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: Compressing Images to be stored in Cloud

Post by William Jamieson » Tue Jul 08, 2014 10:06 pm

@Richard:
Would you happen to know a quick and easy way to resize and change the filesize of PNGs and GIFs Richard?

BTW I hope to see you at RunRev Live 14 in San Diego. Just got my ticket!

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: Compressing Images to be stored in Cloud

Post by William Jamieson » Tue Jul 08, 2014 10:10 pm

@NewTronsols

From what I have read, it looks like a good decision for you to not store it on the cloud. Especially considering that if somehow the signature is lost by an event such as switching devices, the user will always be able to recreate their signature with ease. But I really don't know anything about your application, but that is how I would feel if I was your user. Hope that helps.

-Will

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: Compressing Images to be stored in Cloud

Post by newtronsols » Tue Jul 08, 2014 11:21 pm

William,

Yes i agree. The only reason I was considering was that I am struggling to get a decent 3 page pdf from an exported card image on android. So I was thinking of passing the form data + signature to recreate on a pc to print pretty pdfs. Still trying to figure out if Quartam works on android. I had hoped to get a simple working android demo from them.

Frustrated 'a little' that pdf will never work on Android with generic Livecode - I can never understand biz decisions with 85% of the global market on Android.

Perhaps via html5 Livecode will one day match http://demos.telerik.com/kendo-ui/

Post Reply