Is this normal? Blur when dowsizing PNG

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
grimholtz
Posts: 5
Joined: 2011-01-10T15:55:12-07:00
Authentication code: 8675308

Is this normal? Blur when dowsizing PNG

Post by grimholtz »

Hi,

When I resize a PNG from 800x600 to a smaller size (same aspect ratio), I get blurring. The blurring is progressively worse as the size decreases. Is this output normal? I thought PNGs are vector graphics and so resizing wouldn't blur. These are the commands I'm using:

Code: Select all

convert -resize 16 -blur 0 original.png new.png
convert -resize 32 -blur 0 original.png new.png
convert -resize 64 -blur 0 original.png new.png
convert -resize 128 -blur 0 original.png new.png
convert -resize 256 -blur 0 original.png new.png
Here are the 5 outputted files and the original:

http://imgur.com/a/e28d1#5

Version info:

Code: Select all

Version: ImageMagick 6.6.9-7 2012-08-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
thank you...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is this normal? Blur when dowsizing PNG

Post by fmw42 »

PNG is not vector graphics, but raster image. You are thinking of PDF, which is vector, unless a raster image is imbedded.

Try the proper syntax for IM 6 which reads the input first.

convert original.png -resize XX -blur 0x0 new.png

or since blur is zero, which should be expressed as 0x0 (radiusxsigma) thus you have just specified radius=0 and it is not clear what sigma is being set to, so better to remove it

convert original.png -resize XX new.png

Do either of those work better for you?

IM 6.6.9.7 is rather old (over 150 versions old). You might try upgrading. You never know what bugs are involved. In fact, I think -blur may have been buggy for a while, though I do not recall the range of versions. Also PNG has undergone quite some development.
grimholtz
Posts: 5
Joined: 2011-01-10T15:55:12-07:00
Authentication code: 8675308

Re: Is this normal? Blur when dowsizing PNG

Post by grimholtz »

Thanks for the reply!

I built this version from source:

Code: Select all

Version: ImageMagick 6.8.5-3 2013-04-30 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib djvu fontconfig freetype jng jp2 jpeg lcms lqr openexr pango png ps tiff x xml zli
It's definitely faster and creates smaller filesizes for the same options :)

I changed my options as you suggest:

Code: Select all

convert original.png -resize XX new.png
the re-sized images are still blurred, although slightly better than the older ImageMagick version. I'm wondering if this is normal? Or should the resize be a crisp & clear as the original? (I'm maintaining aspect ratio and reducing size--not enlarging--so I do not understand why there would be blurring at all?)

thanks again.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is this normal? Blur when dowsizing PNG

Post by fmw42 »

the re-sized images are still blurred, although slightly better than the older ImageMagick version. I'm wondering if this is normal? Or should the resize be a crisp & clear as the original? (I'm maintaining aspect ratio and reducing size--not enlarging--so I do not understand why there would be blurring at all?)
Are you minifying or magnifying?

-resize has undergone quite some changes over time with lots of new -filter options and changes to the default filter.

You might try adding -filter XX before -resize.

see
http://www.imagemagick.org/Usage/filter/
http://www.imagemagick.org/Usage/filter/nicolas/

If you are enlarging and want sharpness at the expense of other artifacts, I would recommend -filter Catrom or Lagrange. But there are other choices that give compromises between sharpness, blur and other artifacts. Read the second link above from Nicolas Robidoux.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Is this normal? Blur when dowsizing PNG

Post by anthony »

The real question is... In what way is the image blurred? That is what are you comparing it to?

All resize operations blur or alias to some extent as resize is basically having to figure out new values that fall between the pixels of the old values. That is, the resize operator needs to map from one grid of pixels to a completely different grid of pixels, and where the grids do not line up!!! That is a next to impossible (read information lack or loss) situation.

This is why resize is such a difficult operation. It is by its nature imperfect, and thus falls back to qualitative (human) comparisons.

So I ask again... blurred when you compare it to what?

Vector formats don't used a grid, they use lines between exact points (vectors), as such they are drawn at whatever resolution (grid) you are wanting the image at. Consequently they don't blur, and can be smaller than a raster image.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply