Page 1 of 1

Tile n-pages of TIFF into 1 image

Posted: 2013-05-20T12:11:02-07:00
by foobar
I am working on a web app that currently displays images in an archive by passing through output from convert directly to the browser. The PHP code that does this looks like this:

$cmd = "$convert '$imgpath' $options png:- ";
passthru( $cmd );

I have recently discovered that some of the source images are TIFFs that have two "pages", (they are scans of IDs -- one page is the front, the other is the back,) but only one page is being displayed. I would like to have convert take the second page and attach it on to one side of the first page such that both the front and back can be output as a single image.

I am aware that this can be done fairly easily using intermediate files, but I would really like to do it without using intermediate files for a variety of reasons. Multiple nested convert processes are fine as long as they don't generate temp files. What I mean by nested processes:

"convert arg1 -flag='$( another convert/something else call )' input_file png:-"

I would appreciate any ideas anyone has on how to do this.

I am using Linux, specifically Centos 5. I have these two versions of ImageMagick handy:

Version: ImageMagick 6.8.4-8 2013-04-10 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC
Delegates: bzlib freetype jng jpeg lcms png ps tiff x zlib

Version: ImageMagick 6.4.9-10 2009-10-07 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

I can compile another version if necessary.

Re: Tile n-pages of TIFF into 1 image

Posted: 2013-05-20T12:21:04-07:00
by snibgo
"+append" should do it. If the input has one image, "+append" does nothing. If it has many images, they are placed side by side. As a command line:

Code: Select all

convert in.tif +append out.png

Re: Tile n-pages of TIFF into 1 image

Posted: 2013-05-20T12:56:33-07:00
by foobar
That did it! Thank you!

(I actually did RTFM quite a bit -- I even have a browser tab open from before I posted the question to the part of the manual that describes -append/+append. I have even read the part about this option at least a couple times. I have no idea why it didn't click in my mind that this would work. Perhaps I should have my head examined.)

Re: Tile n-pages of TIFF into 1 image

Posted: 2013-05-20T13:30:18-07:00
by snibgo
I happens to me. I sometimes figure out a complex solution to a problem, completely overlooking a simple solution -- a solution that I always knew but had forgotten.

I sometimes think I have forgotten more than I ever knew.