jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes Servlet generating an image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet generating an image" Watch "Servlet generating an image" New topic
Author

Servlet generating an image

Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

I have this servlet which generates an image dynamically and sends it to the client. This image can be sent as a PNG or JPEG; which is more convenient if quality of the image is not a major concern?
- Manish
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

If you're not measuring based on quality, how are you defining 'convenience'?
I'd tend to say JPEG over PNG, since I'm not sure that PNG is widely accepted.
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

Originally posted by David O'Meara:
[QB]If you're not measuring based on quality, how are you defining 'convenience'?
QB]

Speed or network bandwidth!
- Manish
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Which is purely size. In this case you are really looking at apples and oranges.
My understanding is that PNG is close to GIF in that it gets better performance with images that have a limitted number of colors, like cartoon type graphics.
JPEGs are better for photo style images with large numbers of colors and color gradients.
Viewed that way, if you are creating images in a servlet is might be the case that they are closer to the cartoon style and would therefore be better as PNGs. You may find that a JPG of a comparable size has significant dithering and is less useful.
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

You are right! Images would be mostly Maps/Vharts etc, so I think PNG would be a better option as compared to JPEG.
Are there any stats avaialable about the PNG support by browsers?
- Manish
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet generating an image