Watermarking a TIFF only happens on the thumbnail

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?".
Post Reply
Cable35
Posts: 9
Joined: 2018-12-05T09:45:42-07:00
Authentication code: 1152

Watermarking a TIFF only happens on the thumbnail

Post by Cable35 »

I am using the below code to watermark images. I ran into a TIF file that the watermark image is placed on the thumbnail of the image. If i open the image in Photoshop i do not see the watermark. If i look at the image with Windows Viewer or Apple Preview app i see the watermark.

I do see these warnings:
convert: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/1007.
convert: Unknown field with tag 42033 (0xa431) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/1007.

Images to test with:
https://www.dropbox.com/sh/qnxobplnd684 ... SVf2a?dl=0

CentOS
Version: ImageMagick 7.0.8-15 Q16 x86_64 2018-12-07 h

# get dimensions of incoming file and save as a variable
dim=`convert -quiet "$1"[0] -format "%wx%h" info: 2>/dev/null`

echo $dim
echo $1 #incoming file
echo $2 #outgoing file

/usr/local/bin/convert \( "$1"[0] -background white -flatten -depth 8 \) \
\( -clone 0 -fill "gray(20%)" -colorize 50 \) \
\( /home/cgray/scripts/watermark.png -alpha extract -auto-level \
-write mpr:tile +delete -size $dim tile:mpr:tile \) \
-alpha off -compose over -composite \
"$2"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Watermarking a TIFF only happens on the thumbnail

Post by fmw42 »

With ImageMagick 7, use magick not convert.

I do not understand the issue. Your input tif already has the watermark on it.

Your incoming.tif file has several layers and you are only processing the first one. Photoshop does its own thing with multi-layer images. I have no idea how your input TIFF was created and so cannot comment on how Photoshop is presenting. But it likely is re-creating the preview from the different layers and other information in the TIFF profiles. You should ask on a Photoshop forum about why it does not show the watermark. This is an ImageMagick forum.

However, if I separate the layers of your incoming.tif and display layer 0 in PS, it does show the watermark.

When I apply your command and look at the output in PS, it shows the watermark.

Those are just warnings about TIFF tags that ImageMagick does not understand. They will not affect the output. You can avoid them by adding -quiet to your command.

You can avoid getting the dimensions by using -draw "color 0,0 reset". See https://imagemagick.org/Usage/canvas/#tile

Here is a rewrite of your command using that approach:

Code: Select all

magick -quiet \( incoming.tif[0] -background white -flatten -depth 8 \) \
\( -clone 0 -fill "gray(20%)" -colorize 50 \) \
\( watermark.png -alpha extract -auto-level -write mpr:tile +delete \
-clone 0 -tile mpr:tile -draw "color 0,0 reset"  \) \
-alpha off -compose over -composite \
result.tif
Cable35
Posts: 9
Joined: 2018-12-05T09:45:42-07:00
Authentication code: 1152

Re: Watermarking a TIFF only happens on the thumbnail

Post by Cable35 »

In my photoshop 2017 i have three layers. When you say PS you mean Photoshop?
prdouct
shadow
background

I cannot see the watermark text on any of those layers in Photoshop.

Thank your for the rewrite. I will use this instead of getting the dimensions of the image.

Thank you for the feedback. I will update my Photoshop and test again.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Watermarking a TIFF only happens on the thumbnail

Post by fmw42 »

Yes, PS is Photoshop. They do some strange things with layers. And the watermark, may not be contained in the layer data but could be in one of the proprietary profiles in the Tiff file. Furthermore, I have no idea how the file was created, so cannot say where or why the watermark does not show. If I extract each layer/page from the TIFF file in ImageMagick and then display it in Photoshop, I can see the watermark in the extracted layer 0 of the original file.
Cable35
Posts: 9
Joined: 2018-12-05T09:45:42-07:00
Authentication code: 1152

Re: Watermarking a TIFF only happens on the thumbnail

Post by Cable35 »

Can you explain what you mean by separate the layers in PS so you can see the watermark?

So far i do not see the watermark it in my copy of PS.

Thanks!
Cable35
Posts: 9
Joined: 2018-12-05T09:45:42-07:00
Authentication code: 1152

Re: Watermarking a TIFF only happens on the thumbnail

Post by Cable35 »

I am sorry, i did not fully read your last response. You used image magick to extract the layers.
Post Reply