Page 1 of 1

watermark just 2nd page of tiff and keeping both pages

Posted: 2013-08-25T16:13:44-07:00
by arepea
I have been unable to figure out a DOS command line to
take a 2 page tiff
put a watermark on just the 2nd page of the tiff (annotate would be fine too)
save resulting tiff with both pages , preferably as a 'Save As' to replace the original tiff.

We have many tiffs to process each day, so batching is how we need to go. Can be bat, vbscript , jscript, wscript, cscript, powershell.
At one point I got the only 2nd page to change but the saved file contained just the one page.

Re: watermark just 2nd page of tiff and keeping both pages

Posted: 2013-08-25T17:10:49-07:00
by fmw42
You need to separate the pages and process the second and put it back with the first page.

convert image.tiff ( -clone 1 add-your-watermark-or-text \) -delete 1 image.tiff

The image.tiff has two layers or pages (numbered from 0) that IM will read when calling image.tiff -- page 0 and page 1. The parenthesis says make a copy of page 1 (the second page) and do whatever you need to add a watermark or text. Then delete the original page 1. Then write out the two pages back to your original image name.

The command would be different if you have more than two pages and need to watermark only one of the pages. You would need to know which page to watermark and to extract that page and substitute it back in the same order with the other pages.

I would recommend that you temporarily use a new output name, say image1.tiff until you work out the kinks of your watermark process.

One of the Windows users can probably give you more information about making this into a batch (.bat) file.

Watermarking can be added with an image by composition in side the parenthesis -- see http://www.imagemagick.org/Usage/compose/#watermark

or text can be added either directly using -annotate (or -draw) or by making a new text image with transparent background and composing that over the second page within the parenthesis --- see
http://www.imagemagick.org/Usage/text/
http://www.imagemagick.org/Usage/basics/#parenthesis


If you need further help, please identify your version of IM and provide some links to your input tiff and information about how you would want to create the watermark.

Re: watermark just 2nd page of tiff and keeping both pages

Posted: 2013-08-25T17:26:00-07:00
by GreenKoopa
On Windows, parenthesis don't need escaping with backslashes.
http://www.imagemagick.org/Usage/windows/#conversion

Alternatively to operating on the second image/page, Fred's command could be changed to watermark the last page.
http://www.imagemagick.org/Usage/basics/#list_ops

Re: watermark just 2nd page of tiff and keeping both pages

Posted: 2013-08-25T17:34:35-07:00
by snibgo
The only difference for Windows is that neither parenthesis should generally be escaped (in Unix, with backslash), thus:

Code: Select all

convert image.tiff ( -clone 1 add-your-watermark-or-text ) -delete 1 image.tiff
The exception is that within a Windows "if () else ()", parentheses may need to be escaped, with caret for Windows, ie "^(" and "^)".

If you have many files, you can put this inside a loop, eg a FOR loop in Windows batch.

You should think about your workflow. If you watermark the original files, you don't want to re-watermark them the same day, or the next day. Writing watermarked files to a different directory may be better.

Re: watermark just 2nd page of tiff and keeping both pages

Posted: 2013-08-25T17:59:12-07:00
by arepea
Thanks for the replies, I didn't expect them so quickly so had not turned on the tiff pc :) .
I was hoping that one of the scripting languages would be able to call an object reference to the 2nd page, but if not doable then batch file it is.
I need the files to keep their names as they will be referenced and used by another program which requires the files to be in a certain directory.
So I think what i might do is move the tiffs to a working directory and then have the batch file do something like

Code: Select all

convert  %1 ( -clone 1 composite  -watermark 30% -gravity North c:\wip\Watermark.gif %1 %2\%1  ) -delete 1 %1
The source file name and destination directory would be passed in on the command line.

hmm, the tiffs are 240dpi b&w and the addition is a static 3 lines of text longest line 70 characters - is watermark best way to do or would draw or caption be better?

Re: watermark just 2nd page of tiff and keeping both pages

Posted: 2013-08-25T18:42:22-07:00
by snibgo
For a scripting language like COM or perl or PHP, see the appropriate forum in index.php

If you want the text to be readable, this isn't really a watermark. Watermarks are generally designed to be hardly visible at all.

See http://www.imagemagick.org/Usage/text/ for lots of possibilities.

Re: watermark just 2nd page of tiff and keeping both pages

Posted: 2013-08-25T18:53:23-07:00
by fmw42
convert %1 ( -clone 1 composite -watermark 30% -gravity North c:\wip\Watermark.gif %1 %2\%1 ) -delete 1 %1
You cannot call composite or another convert within a convert command. You will need to use the convert syntax.

see
http://www.imagemagick.org/Usage/compose/#watermark

convert image.tiff ^
( -clone 1 watermark.gif -compose modulate -define compose:args={brigthness}[,{saturation}] -composite ) ^
-delete 1 image.tiff

Also in windows, % needs to be escaped as %%.

see
http://www.imagemagick.org/Usage/windows/

Re: watermark just 2nd page of tiff and keeping both pages

Posted: 2013-08-26T10:02:27-07:00
by arepea
snibgo wrote: If you want the text to be readable, this isn't really a watermark. Watermarks are generally designed to be hardly visible at all.
See http://www.imagemagick.org/Usage/text/ for lots of possibilities.
using ImageMagick-6.8.6-9 . So I should use

Code: Select all

convert %1 ( -clone 1 composite -label:@c:\wip\Text2Show.txt -gravity North  %1 %2\%1 ) -delete 1 %1
? I don't have access to the pc right now, but that doesn't seem quite correct. ( using " http://www.imagemagick.org/Usage/annota ... mark_image , Composited Label: " as guide)

Re: watermark just 2nd page of tiff and keeping both pages

Posted: 2013-08-26T10:44:26-07:00
by fmw42
convert %1 ( -clone 1 composite -label:@c:\wip\Text2Show.txt -gravity North %1 %2\%1 ) -delete 1 %1
See my post above. You cannot put composite in a convert command nor another convert. Also it is not -label: but just label:

convert image.tiff ^
( -clone 1 -background none -fill somecolor -font somefont -pointsize somepointsize label:@c:\wip\Text2Show.txt ) ^
-gravity North -geometry +X+Y -compose over -composite -delete 1 image.tiff

see the links I posted above as well

Re: watermark just 2nd page of tiff and keeping both pages

Posted: 2013-08-26T12:56:17-07:00
by arepea
fmw42 wrote:
convert %1 ( -clone 1 composite -label:@c:\wip\Text2Show.txt -gravity North %1 %2\%1 ) -delete 1 %1
See my post above. You cannot put composite in a convert command nor another convert. Also it is not -label: but just label:

convert image.tiff ^
( -clone 1 -background none -fill somecolor -font somefont -pointsize somepointsize label:@c:\wip\Text2Show.txt ) ^
-gravity North -geometry +X+Y -compose over -composite -delete 1 image.tiff

see the links I posted above as well
So it would be " label:" and not "-label:" but "-composite" and not " composite" . okaaay. Thanks.

Re: watermark just 2nd page of tiff and keeping both pages

Posted: 2013-08-26T13:52:11-07:00
by fmw42
arepea wrote:
fmw42 wrote:
convert %1 ( -clone 1 composite -label:@c:\wip\Text2Show.txt -gravity North %1 %2\%1 ) -delete 1 %1
See my post above. You cannot put composite in a convert command nor another convert. Also it is not -label: but just label:

convert image.tiff ^
( -clone 1 -background none -fill somecolor -font somefont -pointsize somepointsize label:@c:\wip\Text2Show.txt ) ^
-gravity North -geometry +X+Y -compose over -composite -delete 1 image.tiff

see the links I posted above as well
So it would be " label:" and not "-label:" but "-composite" and not " composite" . okaaay. Thanks.

Not quite, note the blue

convert image.tiff ^
( -clone 1 -background none -fill somecolor -font somefont -pointsize somepointsize label:@c:\wip\Text2Show.txt ) ^
-gravity North -geometry +X+Y -compose over -composite -delete 1 image.tiff

see
http://www.imagemagick.org/Usage/text/#label
http://www.imagemagick.org/Usage/layers/#convert

Re: watermark just 2nd page of tiff and keeping both pages

Posted: 2013-08-26T14:27:48-07:00
by arepea
fmw42 wrote:
arepea wrote: So it would be " label:" and not "-label:" but "-composite" and not " composite" . okaaay. Thanks.
Not quite, note the blue
convert image.tiff ^
( -clone 1 -background none -fill somecolor -font somefont -pointsize somepointsize label:@c:\wip\Text2Show.txt ) ^
-gravity North -geometry +X+Y -compose over -composite -delete 1 image.tiff

see
http://www.imagemagick.org/Usage/text/#label
http://www.imagemagick.org/Usage/layers/#convert
I think I understand what you are saying, but it is a moot point. This is running on a W03Server pc and fonts do not work under Windows (even though convert -list font will list all the fonts, font as a parameter will not work). So it is back to trying to figure out how to use watermark. I used the following:

Code: Select all

convert testme.0fb ( -clone 1 virtual-stamp.tif -compose modulate -define compose:args=75%,75% -composite ) -delete 1 image.tiff
which resulted in an error display of
convert.exe: Unknown field with tag 292 (0x124) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/824.
BUT , I got my tiff :)

Re: watermark just 2nd page of tiff and keeping both pages

Posted: 2013-08-26T14:29:13-07:00
by fmw42
That is just a warning that the Tiff file has meta data that IM does not understand. It will not prevent the processing.


If you have trouble with fonts, then instead of giving it a font name, use path2font/fontfile where typically the suffix will be .ttf

Note the argument is -font fontname or -font path2font/fontfile

be sure you use -font and not font.