By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,712 Members | 1,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,712 IT Pros & Developers. It's quick & easy.

Merging TIFFs into a Multi-Page Tiff

P: 1
We have the following input data file:

KEY File name OrderNo.

001 001_1.tiff 900001
002 002_1.tiff 900002
002 002_2.tiff 900002
002 002_3.tiff 900002
003 003_1.tiff 900003
004 004_1.tiff 900004
004 004_2.tiff 900004

etc

We need to write a Perl script where for multiple records with the same KEY (eg 002 and 004) we need to merge the single record TIFFs into a new file (eg merge 002_1.tiff + 002_2.tiff + 002_3.tiff = 002_new.tiff and also 004_1.tiff + 004_2.tiff into 004_new.tiff).
Any ideas how we can merge the tiff files and also read ahead to the next record to see if KEY value has changed - on change of KEY merge ALL the single records and create a new file.
We'll really appreciate any advice.
Thanks.
Soyab
Aug 13 '10 #1
Share this Question
Share on Google+
2 Replies


P: 1
I'll leave the easy stuff (indicated between *asterixes* below) to you. Here's the hard part:-

Expand|Select|Wrap|Line Numbers
  1. use Imager;
  2. my @images;
  3.  
  4. while (*loop_over_your_input*) {
  5.  my $img = Imager->new(file=>$tiffile) or die Imager->errstr();
  6.  if(*ID is different*) {
  7.    Imager->write_multi({ file=> $outputf }, @images) or die "Cannot write: ", Imager->errstr;
  8.    @images=($img); # next one to do
  9.  } else {
  10.    push @images,$img;
  11.  }
  12. }
  13. # *Don't forget to do the last one (hint - add ||!$onepastend++ to your loop above)
  14.  
I'm aware this is an antique question, but it's top in google for this subject, so hopefully my reply will help others :-)
Sep 14 '11 #2

miller
Expert 100+
P: 1,089
Thanks for the info. Additionally, one could use Image Magick to merge the related tiffs into a single image.

- Miller
Sep 15 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.