Hello all:

I am trying to consolidate some ImageMagick tasks with some arrayed data.

I have this:

my $imagen0 = Image::Magick->new; $imagen0->Set(size=>'128x70'); $imagen0->ReadImage('canvas:transparent'); $imagen0->Annotate(font=>"/fonts/trebucbd.ttf", pointsize=>24, fill=> +$fontcolor1, gravity=>'Center', text=>$p12hrn0); my $imagen1 = Image::Magick->new; $imagen1->Set(size=>'128x70'); $imagen1->ReadImage('canvas:transparent'); $imagen1->Annotate(font=>"/fonts/trebucbd.ttf", pointsize=>24, fill=> +$fontcolor1, gravity=>'Center', text=>$p12hrn1); my $imagen2 = Image::Magick->new; $imagen2->Set(size=>'128x70'); $imagen2->ReadImage('canvas:transparent'); $imagen2->Annotate(font=>"/fonts/trebucbd.ttf", pointsize=>24, fill=> +$fontcolor1, gravity=>'Center', text=>$p12hrn2); ...10 total
and then this:
$image->Composite(geometry => '+188+675', image => $imagen0 ); $image->Composite(geometry => '+365+675', image => $imagen1 ); $image->Composite(geometry => '+542+675', image => $imagen2 ); ...10 total

And I am trying to simplify in a loop with this:

for my $i (@$times) { my $imagen($i) = Image::Magick->new; $imagen($i)->Set(size=>'128x70'); $imagen($i)->ReadImage('canvas:transparent'); $imagen($i)->Annotate(font=>"/fonts/trebucbd.ttf", pointsize=>24, +fill=> $fontcolor1, gravity=>'Center', text=>$i); } my $dayy = 675; my $dayx = 188; my $dayoff = 177; my $daygeo = ""; for my $i (@$times) { $daygeo = "+" . $dayx . "+" . $dayy; $image->Composite(geometry => $daygeo, image => $i ); $dayx = $dayx + $dayoff; }

The array $times is previously populated with text (Wednesday Night, Thursday, Thursday Night, ect.). I am guessing that it has something to do with creating an array for $imagen with ImageMagick, but I'm not quite sure how else to do this right now.

Thanks for your wisdom as always!

John


In reply to Loop array with ImageMagick by johnfl68

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.