Page 1 of 1
[SOLVED] PNG to JPG conversion: Resolution oddities?
Posted: 2017-02-13T21:37:44-07:00
by mhulse
(IM version in my signature)
Before conversion of a PNG to JPG, in Photoshop, I see:
5"x7.5"
300ppi
When I use this command:
Code: Select all
convert image.png -flatten -density 72 -depth 8 -quality 100 -units PixelsPerInch image.jpg
Photoshop shows me:
8.242"x12.363"
182ppi
Just curious why the images is 182ppi?
What I was expecting to see:
20.833"x31.25"
72ppi
Thanks!
Re: PNG to JPG conversion: Resolution oddities?
Posted: 2017-02-13T21:42:18-07:00
by fmw42
I think PS may keep its own fields for density and units and ignores those of IM.
Re: PNG to JPG conversion: Resolution oddities?
Posted: 2017-02-13T21:49:04-07:00
by mhulse
I think PS may keep its own fields for density and units and ignores those of IM.
Ahhhh, interesting!
Code: Select all
identify -verbose image.jpg
Image: image.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 1500x2250+0+0
Resolution: 182x182
Print size: 8.24176x12.3626
Units: PixelsPerInch
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Channel statistics:
Pixels: 3375000
Red:
min: 0 (0)
max: 255 (1)
mean: 65.8326 (0.258167)
standard deviation: 50.1159 (0.196533)
kurtosis: 2.71615
skewness: 1.80886
entropy: 0.853981
Green:
min: 0 (0)
max: 255 (1)
mean: 54.7403 (0.214668)
standard deviation: 47.045 (0.18449)
kurtosis: 2.34124
skewness: 1.68187
entropy: 0.830866
Blue:
min: 0 (0)
max: 255 (1)
mean: 43.6316 (0.171104)
standard deviation: 49.5595 (0.194351)
kurtosis: 2.39981
skewness: 1.76849
entropy: 0.812539
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 54.7348 (0.214646)
standard deviation: 48.925 (0.191863)
kurtosis: 2.76248
skewness: 1.76448
entropy: 0.832462
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Alpha color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 1500x2250+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 100
Orientation: Undefined
Properties:
date:create: 2017-02-13T20:47:08-08:00
date:modify: 2017-02-13T20:47:08-08:00
jpeg:colorspace: 2
jpeg:sampling-factor: 1x1,1x1,1x1
signature: 6dcb71004d2a4c440ef1f3f461b74a3dd548e5d9a10801c09d9e7012788d9c6a
Artifacts:
verbose: true
Tainted: False
Filesize: 2.492MB
Number pixels: 3.375M
Pixels per second: 30.68MB
User time: 0.110u
Elapsed time: 0:01.110
Version: ImageMagick 7.0.4-7 Q16 x86_64 2017-02-04 http://www.imagemagick.org
Oddly, looks like there's 182x182 in that output?
Thanks for your help Fred!
Re: PNG to JPG conversion: Resolution oddities?
Posted: 2017-02-13T21:50:56-07:00
by fmw42
If you post your PNG input file, I can test your conversion and open it in PS to confirm. You can upload to any free hosting service such as dropbox.com and put the URL here.
The issue may be that PNG only supports dots per centimeter and IM or PS may be automatically converting to dots per inch. Look at your input PNG in IM and PS and see if they are showing units the same?
Re: PNG to JPG conversion: Resolution oddities?
Posted: 2017-02-13T21:58:18-07:00
by mhulse
Awesome! Thank you so much for your help and time, I really appreciate it!
https://dl.dropboxusercontent.com/u/127 ... hecale.png
I obtained the full resolution image from here:
https://commons.wikimedia.org/wiki/File ... hecale.png
Thank you again for you help!
Btw, do you have a paypal donation page or email? I'd love to shoot you a small cash payment. You have been so helpful every time I have posted a question. I'm not rich, but would love to give back a little to show my thanks.
Re: PNG to JPG conversion: Resolution oddities?
Posted: 2017-02-13T22:11:31-07:00
by fmw42
Imagemagick says:
Resolution: 118.11x118.11
Print size: 12.7x19.05
Units: PixelsPerCentimeter
Photoshop says:
W=5 in
H=7.5 in
Res=299.999 pixels per inch
But you can change the units to cm in PS Image Size window.
W=12.7 cm
H=19.05 cm
Res=118.11 pixels per cm
So in fact they are equivalent.
Re: PNG to JPG conversion: Resolution oddities?
Posted: 2017-02-13T22:25:28-07:00
by mhulse
Interesting!
Thank you for checking that! Great observation.
So, this (post-conversion):
8.242"x12.363"
182ppi
Is actually 71.654 per cm!
So, if I understand correctly, the original is in pixels per cm, and after conversion, it's still using pixels per cm?
I guess I assumed using:
Would normalize the units? Is the "pixels per cm" hard-baked into the original image?
Maybe I should not worry about this, as PPI and PPCM are technically equivalent (that is, looking at the numbers).
Re: PNG to JPG conversion: Resolution oddities?
Posted: 2017-02-13T22:52:04-07:00
by fmw42
You told the output you wanted it to be 72 dpi. So IM converted from pixelspercm to the corresponding pixelsperin and set the density to 72.
I think 71.654 is just a precision error in the display of the data.
Re: PNG to JPG conversion: Resolution oddities?
Posted: 2017-02-13T23:03:39-07:00
by mhulse
fmw42 wrote: ↑2017-02-13T22:52:04-07:00
You told the output you wanted it to be 72 dpi. So IM converted from pixelspercm to the corresponding pixelsperin and set the density to 72.
I think 71.654 is just a rounding error in the display of the data.
Ahhhh, interesting! Thank you for the clarification.
I guess I assumed that I would see 72ppi instead of 182ppi. I think I need to contemplate the math here … I think I get where this is going, but I am not fully connecting the dots. Again, this is just me being dense.
Thanks again for the help Fred, I greatly appreciate it!!!!
Re: PNG to JPG conversion: Resolution oddities?
Posted: 2017-02-13T23:31:18-07:00
by fmw42
If you leave off density 72, then you get:
Your original PNG has:
Resolution: 118.11x118.11
Print size: 12.7x19.05
Units: PixelsPerCentimeter
Code: Select all
convert 2_Heliconius_hecale.png -flatten -depth 8 -quality 100 -units PixelsPerInch image1.jpg
Resolution: 300x300
Print size: 5x7.5
Units: PixelsPerInch
The resolution changes to 300 because 118 px/cm = 118*2.54 px/in = 300 px/in
If you add -density 72, you get:
Code: Select all
convert 2_Heliconius_hecale.png -flatten -depth 8 -quality 100 -density 72 -units PixelsPerInch image1.jpg
Resolution: 182x182
Print size: 8.24176x12.3626
Units: PixelsPerInch
The resolution changes to 182 because you changed the density to 72 px/cm 72*2.54 px/in = 182.88 px/in
Re: PNG to JPG conversion: Resolution oddities?
Posted: 2017-02-14T20:04:46-07:00
by mhulse
Thank you for the help Fred! I owe you one.