Hi All,
Having a devil of a time with this one.
I am trying to add a line of text to a JPEG image using Image::Magick. Where I am coming unstuck is that I want to use the copyright symbol. The following almost works:
#!/usr/local/bin/perl use strict; use warnings; use Image::Magick; my($image, $x); $image = Image::Magick->new; $x=$image->Read('SV000360.JPG'); warn "$x" if "$x"; my($xSize, $ySize) = $image->Get('width', 'height'); print "Width: $xSize\t Height: $ySize\n"; my $text = chr(hex (0xa9)); $text.="© Some person."; my $yPos=$ySize-50; print "Text:$text\n"; $x=$image->Annotate(font=>"/usr/share/fonts/msttcorefonts/verdana.ttf" +, pointsize=>40, weight=>10, fill=>'yellow', text=>"$text",strokewidt +h=>10, undercolor=>'green', x=>50, y=>$yPos); warn "$x" if "$x"; #$image->Draw(stroke=>'red', primitive=>'rectangle', points=>'20,20 20 +0,200', x=>100, y=>100); $x=$image->Write('SV000360_II.JPG'); warn "$x" if "$x";

If I leave off the "$text=chr(hex(0xa9))" line, the "©" symbol comes out as garbage. If I put that line in, I get the "©" symbol, but it is preceded by another garbage symbol. What am I doing wrong here?

In reply to Adding Copyright (C) symbol to an image using Image::Magick by leighsharpe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.