How to Extract Layers from a TIF File and convert to PNG with transparacy

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?".
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to Extract Layers from a TIF File and convert to PNG with transparacy

Post by snibgo »

You can use "magick identify -verbose myfile.png" and look for "Profiles:" to see if the profile is embedded.

When writing PNG files, IM will embed the profile unless the profile is sRGB. For sRGB profiles, IM just creates a sRGB chunk. (I don't like this, because there are different sRGB profiles, and embedding the correct one might be important.)
sandraR wrote:... if I try to open the [PNG] file in Photoshop it keeps giving me an alert that says "it has a file format that does not support embedded profiles", so this means that the profile did not get embedded.
But Photoshop isn't saying there is no profile. It seems to say it shouldn't have a profile. I don't understand that. Is your version of PS old?
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to Extract Layers from a TIF File and convert to PNG with transparacy

Post by fmw42 »

Both of these work fine for me using IM 7.0.8.28 Q16 Mac OSX and I can open them with no error messages in Photoshop CC

Code: Select all

magick -quiet "testfile.tif" \
\( -clone 0 -alpha set -channel a -evaluate set 0 +channel \) \
-delete 0,1 \
-background none \
-layers merge \
-resize 50% \
-profile /Users/fred/images/profiles/sRGB.icc \
"testfile1.png"

Code: Select all

magick -quiet "testfile.tif" \
\( -clone 0 -alpha set -channel a -evaluate set 0 +channel \) \
-delete 0,1 \
-background none \
-layers merge \
-profile /Users/fred/images/profiles/sRGB.icc \
-resize 50% \
"testfile2.png"

Code: Select all

magick -quiet "testfile.tif" \
\( -clone 0 -alpha set -channel a -evaluate set 0 +channel \) \
-delete 0,1 \
-background none \
-layers merge \
-resize 50% \
-strip \
-profile /Users/fred/images/profiles/AdobeRGB1998.icc \
-profile /Users/fred/images/profiles/sRGB.icc \
"testfile3.png"

Code: Select all

magick compare -metric rmse testfile1.png testfile2.png null:
72.8493 (0.00111161)

Code: Select all

magick compare -metric rmse testfile1.png testfile3.png null:
0 (0)

So no significant differences for all 3.
sandraR
Posts: 19
Joined: 2019-01-22T02:37:30-07:00
Authentication code: 1152

Re: How to Extract Layers from a TIF File and convert to PNG with transparacy

Post by sandraR »

snibgo wrote: 2019-02-27T08:01:04-07:00 You can use "magick identify -verbose myfile.png" and look for "Profiles:" to see if the profile is embedded.

When writing PNG files, IM will embed the profile unless the profile is sRGB. For sRGB profiles, IM just creates a sRGB chunk. (I don't like this, because there are different sRGB profiles, and embedding the correct one might be important.)
Snigbo: My photoshop is CC2019.
snibgo wrote: 2019-02-27T08:01:04-07:00 But Photoshop isn't saying there is no profile. It seems to say it shouldn't have a profile. I don't understand that. Is your version of PS old?
Snigbo: But you can embedd a sRGB profile with IM. My friend made it work from his computer.

Because if I do a really simple test with just replacing the profile.
My friend tried it on ImageMagick 6.9.9-40 on Mac OS X 10.14.2, and for him it worked to embedd the sRGB profile (although he needs to use "convert" since he uses an older IM version).
The simple test was:

Code: Select all

convert testfile.tif +profile icc -profile "/path/to/profiles/AdobeRGB1998.icc" -profile "/path/to/profiles/sRGB Profile.icc" testfile.png
But for me on my IM version it does not work to embedd the profile.

I think there might be a problem with the IM version I am currently running perhaps: version 7.0.8-24 on CentOS6.9....
sandraR
Posts: 19
Joined: 2019-01-22T02:37:30-07:00
Authentication code: 1152

Re: How to Extract Layers from a TIF File and convert to PNG with transparacy

Post by sandraR »

fmw42 wrote: 2019-02-27T10:52:53-07:00 Both of these work fine for me using IM 7.0.8.28 Q16 Mac OSX and I can open them with no error messages in Photoshop CC
fmw42:
I tried to add the -strip to the commandline instead of +profile icc - but it still is not working for me.
I think there might be a problem with the IM version I am currently running perhaps: version 7.0.8-24 on CentOS6.9.
Since my friend could embedd the profile just fine on his IM 6.9.9-40 on Mac OS X 10.14.2 when we did a simple test run for just adding a new embedded sRGB-profile.

I see you are using an newer version for IM=version 7.0.8-28, I will check if it is possible to upgrade my version...
Post Reply