0

I've got a batch process that converts uploaded images using wand to generate thumbnails and resized versions. The problem is that the converted images get a lot larger than the original image. An uploaded jpg (1024x768) that was 239kB ends up over 1.2MB at 800x600. If I just resize but don't change format, the image is 132kB. Here's the relevent bit of code from my script.

im1 = Image(blob=file) sizemedium = '800x600' im1.transform(resize=sizemedium) im1.format ='png' medfile = im1.make_blob()

sliptonic
  • 460
  • 3
  • 11

2 Answers2

2

Keep the format. PNG uses a different way of "encoding" color and is not very optimized for photos (it is better for illustrations, icons and clip art).

You'll see it works fine if there is a limited number of colors in the image.

Rule-of-thumb for image formats is to use JPEG for photos, PNG for anything else.

Bart Friederichs
  • 33,050
  • 15
  • 95
  • 195
0

The thing is that PNGs can be larger than JPGs, specially when you are storing photos, so that might be the problem. If you do not need a PNG for a specific reason I would just keep the JPG format.

cnluzon
  • 1,054
  • 1
  • 11
  • 22