Frage

I am using imagemagick to -resize an 8 MB image. The command is

convert "big.png" -resize "14384x49152" "result-resize.png"

Unfortunately the size of result-resize.png grows from 8MB to 31MB.

The only workaround for me is to apply a png optimizer afterwards. But I am batch processing many images this uses a lot of processing time.

So is there a alternative unix image resize program? Or would one know a different workaround?

(I tried many options and only "-filter Box" got back to 8MB at the expense of a very noticeable quality reduction).

War es hilfreich?

Lösung 2

Imagemagick is fairly versatile and I haven't come across any other tool that is close to the capabilities of imagemagick. The tool is fine, the problem might be with what you are trying to do with it.

Since I do not have the image which you are using I have used an PNG image of my own. Two possible problems I see with information you have provided.

  1. The resize arguments you have given are absolute and very large (14384x49152). This means the convert command will return an image of smaller size only if your input image has a resolution greater than 14384x49152. I'm not sure what you case you have for such a large resolution, but if you are going to increase the resolution then correspondingly the size will also increase. And since most images are smaller than 14384x49152 your command will almost always output and image of bigger size than your input.

  2. Your output image is again in a PNG format, which is a lossless format. If you do not strictly need PNG's use a lossy format like JPEG will allow you to control the quality and hence the size of the image. Then renaming the extension to jpeg in the convert command would give you a significant reduction straight away.

Andere Tipps

I had trouble with the computing cost of imagemagick on my VPS, and also had some quality issues with resizing JPGs for thumbnails. I switched to a library called ExactCODE which uses much less processing power (and time) and produces the results that were just what I needed. Not sure if they would also solve your problem but they are worth a look as an alternative:

http://www.exactcode.com/site/open_source/exactimage/

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top