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

In reply to Merging 2 tiff images into a single image by zameer

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.