aspose file tools*
The moose likes Applets and the fly likes Image compression on client side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Image compression on client side" Watch "Image compression on client side" New topic
Author

Image compression on client side

Ramesh Sengani
Ranch Hand

Joined: Nov 23, 2011
Posts: 36
Hi,

I am working in social site ,In which client can upload multiple images of any size.

But problem is while uploading much more size image, application giving error related to perm space. To solve this issue i am planning to compress image on client side. For that i feel applet is one option.

but i dont know how i combine applet code with jquery.? OR is there any option for image compression in client side or server side?


Need help


Thanks in advance
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
How much permgen space are you allocating to the JVM?

Resizing an image is probably easier (and less memory hungry) if you do it through ImageMagick via a script.
Ramesh Sengani
Ranch Hand

Joined: Nov 23, 2011
Posts: 36
i am giving permgen space : 256 m .

Is not any API for image compression ?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
If you dig into the JPEG compression parameters of javax.imageio.ImageIO.write then you can specify the compression factor. If you search these forums you'll find relevant code examples of that.
Ramesh Sengani
Ranch Hand

Joined: Nov 23, 2011
Posts: 36
Thanks Tim for reply on post.

But i need on client side. As per your post you are saying about java code means applet.But i am not get proper direction how i make that possible ..need some more clarification
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2376
    
  28

Why do you think compressing the uploaded image is going to solve your permgen issue? Permgen issue generally happens because you load too many classes into the JVM (but can happen because of other reasons too). How is adding new classes to the code going to reduce the permgen usage?

You might want to increase your permgen a little bit and then monitor it while running your app under moderate load to check if it increases with usage. If it stays flat, just use the permgen setting that works for you.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4658
    
    5

The basic idea here, that client side compression will help is fatally flawed.

At least 99% of images that users are likely to upload are JPEG files. They are already compressed. Compressing them again will not reduce their size, and will typically increase the file size.

You need to approach your problem from a different direction.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Image compression on client side