Discrepancy in File Size reading between Photoshop and OS+ImageMagick

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?".
stupid_shinji
Posts: 13
Joined: 2018-04-26T09:37:06-07:00
Authentication code: 1152

Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by stupid_shinji »

Hello, I am a new user running ImageMagick 6.9.9-26 Q16 on Mac El Capitan.

I am really enjoying it thus far, however, I have an issue when using it. I have been using ImageMagick to batch resize images for my employer. I have had no problems running the commands and getting the results I am looking for. The issue I get is the way Photoshop and Finder/ImageMagick interpret the file size.

Here is the info for the file

207991_C.tif[0] TIFF 7200x5401 7200x5401+0+0 8-bit sRGB 222.5MiB 0.000u 0:00.000
207991_C.tif[1] TIFF 7200x5400 7200x5400+0+0 8-bit sRGB 222.5MiB 0.000u 0:00.000

In the Mac Finder, it reads as 233.3 MB however when I open the image in Photoshop it reads 111.3 MB. This is the exact same file with exactly the same characteristics. The dimensions read the same too. When I open the rest of the images that were resized they read as half the OS size in Photoshop as well. Is there a way to not have this discrepancy? I just ran resizing geometry commands, nothing more nothing less. I also did a convert -depth 8 but it still read as half the file size in Photoshop.

Any help is greatly appreciated.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by fmw42 »

If you resized images, then it produces more colors, which could increase the file size. It is not clear to me what you did exactly or what you compared. Can you provide any Imagemagick processing commands you used and example images that you compared. Also since you are using Q16, Imagemagick may read the file and convert to 16-bits when Photoshop only treats the file as 8-bits. I cannot be sure of any of this without understand your issue better.
stupid_shinji
Posts: 13
Joined: 2018-04-26T09:37:06-07:00
Authentication code: 1152

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by stupid_shinji »

fmw42,

Thank you for the amazing feedback. I really appreciate these explanations. I feel that it will get me closer to a solution.

I will provide more concrete and detailed documentation of my methodology. I'll get a smaller sample size and get the independent and dependent variables together and more clearly defined.

Could you explain to me what exactly is Q16 and what it does or doesn't do? Also the source image was a Phase One IIQ that started as 16-bit and was outputted from Capture One 11 to an 8-bit RGB tif.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by snibgo »

A file has a certain size in bytes. A disk may have allocation units, so the space taken on disk may be larger, but not as different as 111.3 MB and 222.5 MiB.

Perhaps the Photoshop reading is the amount of memory, not the filesize.
snibgo's IM pages: im.snibgo.com
stupid_shinji
Posts: 13
Joined: 2018-04-26T09:37:06-07:00
Authentication code: 1152

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by stupid_shinji »

snibgo,

Thank you for the input.

I think it might be a quantam range issue as was pointed out before. My ImageMagick version is computing with Q16 so even though I am reading an 8-bit file ImageMagick and the OS are interepring it as if it is 16-bit. Is there a way to change/modify my ImageMagick version to do Q8 at all times?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by snibgo »

If you want to save files as 8 bits per channel per pixel, use "-depth 8".

If you want Q8 all the time, install the Q8 version.
snibgo's IM pages: im.snibgo.com
stupid_shinji
Posts: 13
Joined: 2018-04-26T09:37:06-07:00
Authentication code: 1152

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by stupid_shinji »

snibgo,

Do you know how I can install this version? I'm having some difficulty finding it and I tried to reconfigure mine to Q8 but it didn't work.

Also, I did use the "-depth 8" command but I still had the same issue with the Photoshop and OS file read.

Thank you for your help
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by fmw42 »

On a Mac, you would have to install your delegates from say MacPorts and then compile IM as Q8 from source. See viewtopic.php?f=1&t=21502&p=88202&hilit ... rts#p88202 and viewtopic.php?f=1&t=29100 and change --with-quantum-depth=16 to --with-quantum-depth=8 in the ./config file

But before you do that, please supply your IM command and an example file. I can open it on my Mac Sierra in IM and Photoshop and see what differences I see.
stupid_shinji
Posts: 13
Joined: 2018-04-26T09:37:06-07:00
Authentication code: 1152

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by stupid_shinji »

fmw42,

Thanks for the feedback once again.

Here is what I did

identify

208021.tif[0] TIFF 11835x8423 11835x8423+0+0 8-bit sRGB 285.264MiB 0.000u 0:00.000
208021.tif[1] TIFF 160x114 160x114+0+0 8-bit sRGB 285.264MiB 0.000u 0:00.000
208036.tif[0] TIFF 7890x11835 7890x11835+0+0 8-bit sRGB 267.213MiB 0.010u 0:00.000
208036.tif[1] TIFF 107x160 107x160+0+0 8-bit sRGB 267.213MiB 0.000u 0:00.000
identify: Wrong data type 3 for "PixelXDimension"; tag ignored. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Wrong data type 3 for "PixelYDimension"; tag ignored. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Incompatible type for "FileSource"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/912.
identify: Incompatible type for "SceneType"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/912.
identify: Unknown field with tag 42033 (0xa431) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Unknown field with tag 42034 (0xa432) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Unknown field with tag 42036 (0xa434) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Wrong data type 3 for "PixelXDimension"; tag ignored. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Wrong data type 3 for "PixelYDimension"; tag ignored. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Incompatible type for "FileSource"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/912.
identify: Incompatible type for "SceneType"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/912.
identify: Unknown field with tag 42033 (0xa431) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Unknown field with tag 42034 (0xa432) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Unknown field with tag 42036 (0xa434) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/912.

mogrify -path /Users/kiosk1059/Pictures/Imagemagick/ImageMagick_Case/ImageMagick_Resized -density 300 -resize 'x3600' -resize '3600' *.tif

identify

208021.tif[0] TIFF 3600x2562 3600x2562+0+0 8-bit sRGB 52.8128MiB 0.000u 0:00.009
208021.tif[1] TIFF 3600x2565 3600x2565+0+0 8-bit sRGB 52.8128MiB 0.000u 0:00.000
208036.tif[0] TIFF 3600x5400 3600x5400+0+0 8-bit sRGB 111.057MiB 0.000u 0:00.000
208036.tif[1] TIFF 3600x5382 3600x5382+0+0 8-bit sRGB 111.057MiB 0.000u 0:00.000
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by fmw42 »

Your input tiff may be compressed. If you do not set -compression in your IM command, then it may come out as uncompressed and thus a larger file size. Check the compression in your input and output tif files.
stupid_shinji
Posts: 13
Joined: 2018-04-26T09:37:06-07:00
Authentication code: 1152

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by stupid_shinji »

fmw42,

Thank you for the prompt feedback. It seems that this is the issue as when I processed the RAWs from Capture One, I selected to have Uncompressed TIFF. I processed the file again this time with LZW compression selected and the file read sizes were more accurate after using IM commands.

Unfornutely, my supervisor is against using LZW compression in any capacity. I tried to explain that Photoshop must be compressing at some capacity or another. She said that we work with flattened files so it's not necessary to compress. Thank you for your time and for helping me through this rabbit hole.

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

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by fmw42 »

If you start with an uncompressed file, then when converting with Imagemagick set -compression none to get an output uncompressed file.

I see no connection between flattening and compression. If you want to save space, you should use lzw compression or one of the other non-lossy compressions. Since they are non-lossy, you lose nothing in terms of quality. My opinion.

When you start are your TIFFs 24-bit color or 8-bit color (or grayscale)? If you start with 8-bit color and resize that will add more colors and you will get a 24-bit color result. If you want to keep the 8-bit color, then you need add -type palette to your processing command to keep the result at 8-bits color.
stupid_shinji
Posts: 13
Joined: 2018-04-26T09:37:06-07:00
Authentication code: 1152

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by stupid_shinji »

fmw42,

They are processed into 8-bit tifs. I can understand how it is adding more colors. I tried your command of "-type palette" as well as "-type optimize" however neither worked. I still have the same problem with the read sizes being different.

I agree with you and neither do I see a connection between flattening and compression. It seems that the only thing that worked was doing an LZW compression but my supervisor is against that. Thank you for your time and aid. It was extraordinarily helpful.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by fmw42 »

Can you provide an example set of Images and your command line. I am on a Mac and can test your files if you want?
stupid_shinji
Posts: 13
Joined: 2018-04-26T09:37:06-07:00
Authentication code: 1152

Re: Discrepancy in File Size reading between Photoshop and OS+ImageMagick

Post by stupid_shinji »

fmw42,

This is what I typed (these are the source tif files)
Identify

208029.tif[0] TIFF 8778x11803 8778x11803+0+0 8-bit sRGB 296.483MiB 0.010u 0:00.020
208029.tif[1] TIFF 119x160 119x160+0+0 8-bit sRGB 296.483MiB 0.000u 0:00.000
208036.tif[0] TIFF 7890x11835 7890x11835+0+0 8-bit sRGB 267.213MiB 0.020u 0:00.009
208036.tif[1] TIFF 107x160 107x160+0+0 8-bit sRGB 267.213MiB 0.000u 0:00.000
208056.tif[0] TIFF 8708x11608 8708x11608+0+0 8-bit sRGB 289.261MiB 0.000u 0:00.000
208056.tif[1] TIFF 120x160 120x160+0+0 8-bit sRGB 289.261MiB 0.000u 0:00.000
identify: Wrong data type 3 for "PixelXDimension"; tag ignored. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Wrong data type 3 for "PixelYDimension"; tag ignored. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/912.

In the Mac Finder

208029 reads with a file size of 310.9 MB
208036 reads with a file size of 280.2 MB
208056 reads with a file size of 303.3 MB

There is already an observable discrepancy with the provided info but an acceptable discrepancy nonetheless.

Here is the command I used mogrify -path /Users/kiosk1059/Pictures/00_R\&D/Imagemagick/00_Currents -density 300 -resize '7200' -resize 'x7200' *.tif

This got me the dimensions I wanted. However, the image reads twice as large in the Finder than it does when opened in Photoshop.
Identify

208029.tif[0] TIFF 5355x7200 5355x7200+0+0 8-bit sRGB 220.626MiB 0.000u 0:00.000
208029.tif[1] TIFF 5355x7200 5355x7200+0+0 8-bit sRGB 220.626MiB 0.000u 0:00.000
208036.tif[0] TIFF 4800x7200 4800x7200+0+0 8-bit sRGB 198.069MiB 0.020u 0:00.020
208036.tif[1] TIFF 4815x7200 4815x7200+0+0 8-bit sRGB 198.069MiB 0.000u 0:00.000
208056.tif[0] TIFF 5401x7200 5401x7200+0+0 8-bit sRGB 222.5MiB 0.010u 0:00.009
208056.tif[1] TIFF 5400x7200 5400x7200+0+0 8-bit sRGB 222.5MiB 0.000u 0:00.000

In the Photoshop

208029 now displays with a file size of 110.3 MB
208036 now displays with a file size of 99.9 MB
208056 now displays with a file size of 111.3 MB

It seems that in the Finder/IM it is displaying as twice as large
and in Photoshop as half as big but it also seems to at least be consistent

When I do a "Save As" in Photoshop the image then displays the same file size in Finder as it did in Photoshop e.g 208056 now displays with a file size of 111.3 MB in both the Finder/ IM and Photoshop.

Now Identify 208056

208056.tif TIFF 5401x7200 5401x7200+0+0 8-bit sRGB 111.284MiB 0.000u 0:00.009
identify: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/912.
Post Reply