Copyright symbol in text

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
RLee

Copyright symbol in text

Post by RLee »

Using the command line with ImageMagick 6.3.7 12/25/07 Q16 on Windows. Trying to follow the example (.../Usage/annotating) on creating a copyright watermark. It has steps like:

convert -size 300x50 xc:grey30 -font Arial -pointsize 20 -gravity center \
-draw "fill grey70 text 0,0 'Copyright'" \
stamp_fgnd.png

I replaced 'Copyright' with '©2007 (my name)' in each step, but the copyright symbol is missing in the final image. I've tried including '-encoding Unicode' but that didn't help. I've confirmed with a hex editor that the correct Unicode encoding (A9) is present in the text. I've confirmed that the Arial font has no problems rendering the symbol. What's the trick?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Copyright symbol in text

Post by Bonzo »

This works for me with windows XP:

Code: Select all

convert -size 300x50 xc:grey30 -font Arial -pointsize 20 -gravity center -fill grey70 -annotate +0+0 "©2007" stamp_fgnd.png
Using php on my local server:

Code: Select all

exec("convert -size 300x50 xc:grey30 -font Arial -pointsize 20 -gravity center -fill grey70 -annotate +0+0 \"©2007\" stamp_fgnd.png");
IM version 6.3.7 11/14/07
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Copyright symbol in text

Post by anthony »

The main problem is that shells often do not handle meta-characters or even UTF-8 multi-byte characters. The best solution is to avoid the issue by either reading the string from a file or a pipeline, as I showed in the later IM Examples of the page you were looking at.
http://imagemagick.org/Usage/text/text/#unicode
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
RLee

Re: Copyright symbol in text

Post by RLee »

Thanks, Anthony. Using a file containing the text, I can indeed preserve the character. It appears that I can obtain the desired equivalent of the first annotation step via:

Code: Select all

convert -background grey30 -fill grey70 -font Arial -pointsize 15 -gravity center label:@copyright.txt stamp_fgnd.png
The second annotation step has me stumped, though. The instructions say:

Code: Select all

convert -size 300x50 xc:black -font Arial -pointsize 20 -gravity center \
            -draw "fill white  text  1,1  'Copyright'  \
                               text  0,0  'Copyright'  \
                   fill black  text -1,-1 'Copyright'" \
            +matte stamp_mask.png
Simply substituting label:@copyright.txt for 'Copyright' is invalid, not surprisingly. Various attempts to adapt Bonzo's approach (as shown below) instead of -draw "..." either produce an error or an image which contains, literally, label:@copyright.txt.

Code: Select all

convert -background black -font Arial -pointsize 15 -gravity center \
        -fill white -annotate +1+1 label:@copyright.txt \
	            -annotate +0+0 label:@copyright.txt \
        -fill black -annotate -1-1 label:@copyright.txt \
        +matte stamp_mask.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Copyright symbol in text

Post by anthony »

The label:@copyright is an operator on its own NOT A STRING. It creates a new image which you can overlay onto the background image.

Read IM Examples, Text to Image conversion.

PS: It will create a new image based on the text file "copyright.txt"
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply