0

If I make a screenshot of the the top left corner of the Safari window using Shift-Command-4 > Drag and paste it here on Stack Overflow, the red-yellow-green "traffic lights" and the icon next to them look twice larger compared to their real size.

enter image description here

According to magick identify -format "%w x %h, %x x %y\n" image.png, it is 314 x 88 pixels, 144 x 144 PPI.

To paste it here on Stack Overflow and preseving its real width and height, I can use ImageMagick,

magick -units PixelsPerInch image.png -resample 72 image_imagemagick.png

or I can use the Preview app, which is incuded with macOS.

Menu bar > Tools > Adjust Size > Change Resolution from 144 to 72, and then change Width and Height to 50% > Press OK > Save it as image_preview.png.

enter image description here

According to magick identify -format "%w x %h, %x x %y\n" *.png, both the resulting images, image_imagemagick.png and image_preview.png, are 157 x 44 pixels, 72 PPI.

And now my questions.

  • First, if you look at both images precisely, you will see they are not really the same.

    enter image description here

    enter image description here

    The first image, which is by ImageMagick, is blurrier. How, using ImageMagick, to produce a better one?

  • Second, is it correct that using ImageMagick is more "robust" in terms that resampling doesn't require us to manually adjust Width and Height? It seems the answer is "Yes, of course", but I want to be sure. It was somewhat an unpleasant surprise to me that to produce the same image as with ImageMagick, Preview requires, for some reason that I don't understand, to adjust Width and Height manually, whereas the Resample checkbox is already checked.

The original image is here: https://github.com/jsx97/test/blob/main/image.png. ImageMagick 7.1.1-31 Q16-HDRI aarch64 22148.

10
  • Why is your original image deleted? When I click you link, it show deleted. Imagemagick may be using a different default resampling method. You can change that by using -filter XXX before the -resize. try -filter lanczos or -filter triangle or -filter point. See magick -list filter for a list of filters. or just magick image -filter XXX -resize 50% -density 72 output
    – fmw42
    Commented May 5 at 16:27
  • This is strange. It seems this website deletes images once they are downloaded! Here is a copy: file.io/inlecsqRBIrI, and one another on GitHub: github.com/jsx97/test/blob/main/image.png
    – user22996855
    Commented May 5 at 16:31
  • @fmw42 Thanks, I will try alternative filters. What about the second question, am I right there?
    – user22996855
    Commented May 5 at 16:35
  • Second question is no. -resize requires the width and height in pixels, but keeps the density. -resample requires the desired density and maintains the width and height in inches, but the pixel size will change. See imagemagick.org/script/command-line-options.php#resample and imagemagick.org/script/command-line-options.php#resize
    – fmw42
    Commented May 5 at 18:19
  • I do not think you want -resample as it changes the pixel size. I would suggest doing what I suggested above. magick image -filter XXX -resize 50% -density 72 output. That should duplicated what you get from Preview, if you use the right filter. I do not know what Preview uses for its processing. Using this will maintain the image size in pixels and change the density to what you want. Pixel size is used for digital display, but density is only important for printing.
    – fmw42
    Commented May 5 at 18:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.