0

Summary

I'm attempting to use ImageMagick to produce copies of an image with a range different pixel densities to increase the user-experience of my front-end projects.

Problem

After running the script, the respective PPI is successfully converted but I am expecting the file sizes to be different, as detail is being removed and based on prior research from this article, but they are all the same (or similar).

Base case

The base file has the following identity stats:

File: Image.JPG
 Resolution: 4896x3672
 PPI: 300,300
 Size: 7018920B
---------------------

Steps to reproduce

I run the following commands:

convert Image.jpg -density 144 -units PixelsPerInch Image_2x.jpg
convert Image.jpg -density 72 -units PixelsPerInch Image_1x.jpg
convert Image.jpg -density 4 -units PixelsPerInch Image_0x.jpg

Results

Then I check the identity stats once again with the following output:

File: Image.JPG
 Resolution: 4896x3672
 PPI: 300,300
 Size: 7018920B
---------------------
File: Image_2x.jpg
 Resolution: 4896x3672
 PPI: 144,144
 Size: 7019690B
---------------------
File: Image_1x.jpg
 Resolution: 4896x3672
 PPI: 72,72
 Size: 7019690B
---------------------
File: Image_0x.jpg
 Resolution: 4896x3672
 PPI: 4,4
 Size: 7019690B
---------------------

We can see that the PPI has changed for each respective image but the file sizes are all the same.

  • 1
    You're only changing the physical size of a single pixel, to change the file size you'll have to remove/add pixels, i.e. rescale the resolution, you can then adjust the ppi as well to make the picture appear the same size. – cafce25 Mar 12 '23 at 22:41
  • 1
    PPI is metadata - it tells whatever is rendering the image how to scale it, the data in the file doesn't change. – Stu Mar 12 '23 at 22:41
  • JPGs are not affected by -density except when printing. -density is used to enlarge vector formats such as PDF, not raster formats such as JPG or PNG – fmw42 Mar 13 '23 at 00:19

0 Answers0