Alex Rivera | Logout

Reducing the file size of a very large images, without changing the image dimensions

Asked 2010-02-13T11:34:44.193
51

Consider an application handling uploading of potentially very large PNG files.

All uploaded files must be stored to disk for later retrieval. However, the PNG files can be up to 30 MB in size, but disk storage limitations gives a maximum per file size of 1 MB.

The problem is to take an input PNG of file size up to 30 MB and produce an output PNG of file size below 1 MB.

This operation will obviously be lossy - and reduction in image quality, colors, etc is not a problem. However, one thing that must not be changed is the image dimension. Hence, an input file of dimension 800x600 must produce an output file of dimension 800x600.

The above requirements outlined above are strict and cannot be changed.

Using ImageMagick (or some other open source tool) how would you go about reducing the file size of input PNG-files of size ~30 MB to a maximum of 1 MB per file, without changing image dimensions?

Edit
Report

3 Answers

5

It depends a lot on what you want at the end, I often like to reduce the number of colors while perserving the size. In many many cases the reduced colors does not matter. Here is an example of reducing the colors to 254.

convert -colors 254 in.png out.png
answered 2012-11-30T19:10:34.203
4

Since the size of an image file is directly related to the image dimensions and the number of colours, you seem to have only one choice: reduce the number of colours.

And ~30MB down to 1MB is a very large reduction.

It would be difficult to achieve this ratio with a conversion to monochrome.

answered 2010-02-13T11:42:00.030
0
  • Step 1: Decrease the image to 1/16 of its original size.
  • Step 2: Decrease the amount of colors.
  • Step 3: Increase the size of the image back to its original size.
answered 2010-02-20T10:10:13.347

Your Answer