ImageMagick Help - Need to Change DPI

I have a 1000x1000 300 dpi image that I need to convert to a 100x100 sketch of 96 dpi. How to do it in ImageMagick? I get the smallest possible file size at the highest possible quality.

Doing something like this:

convert myimage.png -quality 100 -resize 100 PNG8:mynewimage.png 

.... resizes, but supports DPI. If I can change this to 96dpi, I should get a smaller file size.

I tried -density , etc., but can't get them to work for me. Maybe I put the commands in the wrong order or passed the wrong parameters. Any help is greatly appreciated. Thanks.

+6
imagemagick
source share
1 answer

Short version: if you want to receive a 100x100 image in PNG format, then you already have the best price with a minimum file size. You can do nothing better than without) lossy encoding (JPEG) or b) reducing the color depth of your image.

For a slightly more detailed explanation, right from Wikipedia: β€œDots per inch (DPI) is a measure of the spatial print or the density of dots in a video, in particular the number of individual dots that can be placed in a line within 1 inch (2.54 cm). "DPI values ​​tend to correlate with image resolution, but are only indirectly related."

DPI has nothing to do with getting a smaller file size; your 100x100 image measures 100x100 pixels, regardless of whether you see it on the screen 300 dpi or 96 dpi (it will just look smaller on the screen 300 dpi). The amount of information is the same anyway.

"- density" does not help either, since it only works when "encoding a bitmap when formatting (reading) vector formats such as Postscript, PDF, WMF and SVG into a bitmap image." These formats are resolution independent, so it makes sense to tell ImageMagick DPI to which you want to rasterize the image. However, your DPI should be a function of the output device you plan to use. In your case, since you start with an already rasterized image, this is useless.

PNG is a lossless format, so the -quality parameter controls the zlib compression level; any advances in image size will be minimal, but it's worth using.

+5
source share

All Articles