Image::Magick
Posted: 2014-05-21T00:39:19-07:00
hello,
trying to understand the perl syntax I gathered some bits from the internet to make an array from a .csv file.
I'd like to combine all the images that are in a row,
I'm not sure if I can do them all at once as I've only combined 2 images before.
what would be the syntax in Image::Magick ?
that works in that it reads and writes but I'm struggling with the compose syntax.
trying to understand the perl syntax I gathered some bits from the internet to make an array from a .csv file.
I'd like to combine all the images that are in a row,
I'm not sure if I can do them all at once as I've only combined 2 images before.
Code: Select all
composite -compose atop 1.png 2.png out.jpg
Code: Select all
#!/bin/perl -w
use strict;
use Text::CSV_XS;
use Image::Magick;
use diagnostics;
my $file = $ARGV[0] or die "Need to get CSV file on the command line\n";
my $csv = Text::CSV_XS->new ({
binary => 1,
auto_diag => 1,
});
my $image = Image::Magick->new;
my @frm=();
my $ct=0;
my @x=();
my $f="";
my $y=0;
my $pic="";
open(my $data, '<:encoding(utf8)', $file) or die "Could not open '$file' $!\n";
while (my $fields = $csv->getline( $data )) {
for ($ct=0;$ct<=6;$ct++)
{
$frm[$y][$ct]=$fields->[$ct];
}
$y+=1;
}
if (not $csv->eof) {
$csv->error_diag();
}
close $data;
$pic=$image->Read($frm[6][1]);
$pic=$image->Write('x1.jpg');