I've checked this script over and over and everything looks ok, but I don't see any TEXT results other than the red line from Draw( ...line... ) call. I placed it in my cgi-bin along with a simple graphic (im_before.jpg) as the default image and I tell it to write to the home directory and display the home image after the refresh.

If this helps any, I run perl 5.8.7 or 5.8.8. My server is CentOS Ent. 3.9 i686 I have Image::Magick 6.2.2 according to my hostmaster, by the way I can't see the dang thing showing in my list of installed modules (from cpanel 11.x) for some crazy reason, but that line I mentioned proves to me something is working (I also have other ImageMagick programs working just fine, but no annotate).

Can someone please test this or find where I'm wrong.

#!/usr/bin/perl use strict; use CGI ':standard'; use warnings; use CGI::Carp "fatalsToBrowser"; my $do=param('do'); if ($do eq 'showme') { ShowImage(); } elsif ($do eq 'write') { Writeit(); } else { askme(); } sub askme { print header, start_html('Demonstarting Image Magick\'s An +notate function'); print h3('Enter the following fields to use or leave blank to use defa +ults'), br; print start_form(-method=>"post", -action=>"annotate.cgi", -enctype=>" +multipart/form-data"); print 'Enter Text to use: <input type="text" name="text" />', br; print 'Find image to use:<input type="file" name="image" /> '; print hidden(-name=>"do", -value=>"write"), p, submit(-value=>" Sav +e "), 'just click "save" and leave blank to use defaults', end_form() +, end_html(); exit; } ##end_askme## sub Writeit { my ($file, $ext, $text, $buffer); if (param('image')) { $file=param('image'); if ($file =~ m/^(.+)\.(jpg|jpeg|gif|bmp)$/i ) { $ext=$2; $ext="im_used.$ext"; open (OFILE, "> $ext"); while (my $bytesread = read ($file, $buffer, 1024)) { print OFILE $buffer; } close OFILE; } else { print header, 'Image may be of wrong format'; } +} else { $ext='im_before.jpg'; } if (param('text')) { $text=param('text'); } else { $text='Hello! Testi +ng Annotate'; } use Image::Magick; my ($image, $x); $image = Image::Magick->new; $image->Read($ext); warn "$x" if "$x"; $image->Annotate(text=>$text, x=>0, y=>5, fill=>'#FF0000', pointsize=> +10); warn "$x" if "$x"; $image->Annotate(text=>$text, x=>15, y=>20, fill=>'blue', pointsize=>6 +0); warn "$x" if "$x"; $image->Annotate(pointsize=>40, fill=>'green', text=>$text); warn "$x" + if "$x"; $image->Comment(comment=> 'MAKE IT WORK!!'); warn "$x" if "$x"; $image->Draw(primitive=> 'line', stroke=>'red', points=>'12,12 300,100 +'); warn "$x" if "$x"; $image->Draw(primitive=> 'text', points=>'40,40 "TEXT ADD"'); warn "$x +" if "$x"; $image->Set(quality=>"89"); warn "$x" if "$x"; $image->Write("../im_after.jpg"); warn "$x" if "$x"; no Image::Magick; print header( -refresh=>"2; URL=annotate.cgi?do=showme&text=$text"), h +3('Saving Image...'), 'you will be redirected shortly.'; } ##end_sub_Writeit## sub ShowImage { print header(), start_html('Showing Annotate Results'), br 'your text +was: "', param('text'), '"'; print h3('This is the result'), '<img src="../im_after.jpg" />'; print br, '<a href="annotate.cgi">click here to try another</a>', p, ' <a href="annotate.cgi?do=write">click here to use defaults</a>', end_h +tml(); exit; } ##end_sub_ShowImage##

In reply to Annotate with Image::Magick by JayBee

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.