zameer has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to merge 2 tiff images (check images - front and back) into a single tiff file using Imager.pm. Merged image file size is slightly greater than the sum of the images but its resulting into a single image (either the front or back image depending on the order of merge). Can someone please help in resolving this issue?
Code snippet I am using:
#! /usr/bin/perl use Imager; my @im; my $tiffile = "./merged_image.tif"; unlink $tiffile; my @images = glob("./*.tif"); print @images, "\n"; my $i=0; for my $file (@images) { my $im = Imager->new(); $im->read(file=>$file) or die "$0: Cannot read image $file: ",$im->e +rrstr,"\n"; my @alltags = $im->tags; foreach $tag ( @alltags ) { print $tag->[0], ":", $tag->[1], "\n"; } push(@im, $im); $i = $i + 1; } ## writing the above images to a single file Imager->write_multi({ type=>'tiff', file=>$tiffile, }, @im) or die "$0: cannot save to $output: ",$Imager::ERRSTR,"\n"; #checking merged image properties my $im = Imager->new(); $im->read(file=>$tiffile) or die "$0: Cannot read image $file: ",$im-> +errstr,"\n"; my @alltags = $im->tags; foreach $tag ( @alltags ) { print $tag->[0], ":", $tag->[1], "\n"; } Output: haikz@eidspstd99:/usr/home/shaikz ==> ./test2.pl ./009600209943_2.tif./009600209943_3.tif tiff_bitspersample:1 tiff_photometric:0 tiff_resolutionunit:2 tiff_resolutionunit_name:inch i_xres:200 i_yres:200 i_format:tiff tiff_compression:fax4 tiff_bitspersample:1 tiff_photometric:0 tiff_resolutionunit:2 tiff_resolutionunit_name:inch i_xres:200 i_yres:200 i_format:tiff tiff_compression:fax4 tiff_bitspersample:1 tiff_photometric:0 tiff_resolutionunit:2 tiff_resolutionunit_name:inch i_xres:200 i_yres:200 i_format:tiff tiff_compression:fax4
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Merging 2 tiff images into a single image
by jethro (Monsignor) on Jul 05, 2012 at 17:33 UTC | |
by zameer (Initiate) on Jul 05, 2012 at 21:16 UTC | |
|
Re: Merging 2 tiff images into a single image
by zentara (Cardinal) on Jul 05, 2012 at 17:42 UTC | |
by zameer (Initiate) on Jul 05, 2012 at 21:18 UTC |