Page 1 of 1

Annotate pages with customized page number (Perl)

Posted: 2013-07-16T06:10:23-07:00
by empiempi
I'm using Perl. I have an ImageMagick object containing 16 pages. I'd like to annotate each page with a text string that derives from the page number. However, I don't want to use the page number straight (unmodified), I want to format it in a certain way. If I wanted to use the page number straight (unmodified), I could use a single Annotate command using the '%p' escape: $image->Annotate(text=>'%p'... ). However, if I want to format the page number first (which I can do in Perl), I don't know how to use a single Annotate command with my customized text. I tried to save my formatted text in text files called "label_1.txt", "label_2.txt", "label_3.txt"... etc and then read their contents using the "@" text file character: $image->Annotate(text=>'@label_%p.txt'... ). But it seems that "@" makes the rest of the line literal, i.e. the "%p" is no longer interpreted by Annotate as a page number. Is there a way to Annotate multiple pages with custom-formatted text? Thanks.

Re: Annotate pages with customized page number (Perl)

Posted: 2013-07-28T18:37:14-07:00
by anthony
'@' means read text from file literally. This is done so as to provide a 'literial source' for the text.
if you want the '@' backslash it '\@....'
if you want to do text substitutions like page numbers, either do it in the file before hand, on the command line, or in the API call, using percent escapes.

Hmmm... I am not certain if the perl API does percent escapes or not. I am not certain it even provides access to the InterpretImageProperties() function that does percent escape substitutions.