2

I am writing a quick little java class that resizes an image into various smaller sizes (thumbnail large/small/etc). I have seen examples that have RenderingHints in it. The output file is significantly larger than without.

My question is: Is it necessary to use RenderingHints if the images that are being resized have no text?

int IMG_WIDTH = 100;
int IMG_HEIGHT = 100;

BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type);
Graphics2D g = resizedImage.createGraphics();
g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null);
g.dispose();    
g.setComposite(AlphaComposite.Src);

g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

I started with a 45kb image, and the output difference is a 3kb file (without RenderingHints) versus a 24kb file (with RenderingHints)

sdolgy
  • 6,963
  • 3
  • 41
  • 61

1 Answers1

0

I suppose, after reading the following stackoverflow.com question/answer:

I am inclined to think that RenderingHints will provide no benefit for me when the photos contain no text ... In which case, no text = no RenderingHints = smaller resized image

Community
  • 1
  • 1
sdolgy
  • 6,963
  • 3
  • 41
  • 61