Akom's Tech Ruminations

Various tech outbursts - code and solutions to practical problems

Splitting a large image to print on multiple sheets Code and Hacks

Posted by Admin • Wednesday, December 23. 2009 • Category: Code and Hacks

This really seems like such a simple task, doesn't it? All I wanted was to print a large (48 megapixel) raytraced image I generated onto several pages, and then tape them together to make a poster.

In my efforts to find a convenient tool to do this, I've attempted the following:
  • Kinko's: (or any neighborhood print shop). I am listing this option because it eliminates the need to do this altogether - they can print an image on a huge poster all at once. This 'should' work, and is probably the best but most expensive option. In my experience, Kinko (Fedex) simply could not receive the image, perhaps they can't handle large uploads.
  • Online Printers: You are probably seeing some options in the google ads on this page already. Of course, I wanted it right now, so that was not an option
  • Rasterbator: A great tool, but not what I need. It creates nice looking multi-page PDF's from low-res images by using the old school newspaper graphic dot approach.
  • Adobe Illustrator (CS3): It seems to have a "print on multiple pages" option in the print dialog, but I've tried every single setting, and it always loses about a 1/4" off the sides, making them un-stitchable. Maybe I'm just Adobe-dumb. Illustrator also insisted that I trust it to manage the print colors rather than trust my printer (a solid-ink Phaser), and the printouts came out practically all brown until I told it to trust the printer. It easily wasted $30 of solid ink before I gave up on Illustrator
  • Photoshop: It can be done. Easiest way is to add guides (view menu) using percentages (eg 50%, 25%, as needed), then select the area between guides (snaps to guides), and copy into new images. This is labor intensive, but if you're careful with mouse movement you should get the right pieces. If you're printing on a small quantity of sheets, this is the best option probably. You can also paste each copied sliver into the same second image - you will then retain any options you've set for that document (such as layout, color quality, etc). Maybe there is a plugin for photoshop that does this automatically?
  • Gimp: Apparently there is a poster plugin of some sort, but in my haste to get this out the door I didn't have the time to understand how to install/compile/use Gimp plugins
  • ImageMagick: This is what I ultimately used. Being a command-line tool it doesn't have a nice visual "layout and split" interface. But what it does have to offer is reliable operation, unix style - one thing, done right. Read more for details on how, below.
  • PDF: What I have not tried is to use the ImageMagick approach above, then auto-convert each image into a PDF and stitch them into one document so they can be printed all at once. I'm not sure if this can be done (easily). If I have to do this again, I'll look into this. (Update: This is no longer necessary, see Geeqie note below)

Image Magick

Image Magick is a linux-centric collection of image processing tools. The two I am actually familiar with are "mogrify" and "convert". The former messes with images in-place, the latter creates new images.

The option of interest is "-extract". Here is the Manual

In my example, I am starting with a nicely proportioned 8000x6000 pixel image. I am printing it on 4x4 standard pages (8.5"x11"), laid out horizontally obviously (landscape print for each piece). So I need to run "convert" 16 times, with 4 values for x (0, 2000, 4000, 6000) and 4 values for y (0, 1500, 3000, 4500). I don't want to type the command line 16 times, so here is a bash script:
for y in 0 1500 3000 4500 ; do
  for x in 0 2000 4000 6000 ; do 
    echo $x $y
    convert  -extract 2000x1500+${x}+${y} original.png split-${x}-${y}.png 
 done
done

For the purist, this may be more acceptable, as it is fully generic
# Source Image Dimensions
WIDTHTOTAL=6000
HEIGHTTOTAL=4500
# Cut Part Dimensions (should be an even fraction of source dimensions)
WIDTH=1500
HEIGHT=2000
for y in `seq 0 $HEIGHT $HEIGHTTOTAL`;  do
  for x in `seq 0 $WIDTH $WIDTHTOTAL` ; do 
    echo $x $y
    convert  -extract ${WIDTH}x${HEIGHT}+${x}+${y} original.png split-${x}-${y}.png 
 done
done


Simple and effective, and now you have 16 images ready to be printed. The "2000x1500" is the resolution of resulting images, and the two lists are the starting offsets within my 8000x6000 image, in pixels.

Now, of course this doesn't print the images, and printing (say, from photoshop) is still somewhat time-consuming, but at least you know it will be perfectly split. You will still need to cut the margins off the sheets, but that's what you get for doing this yourself.

Update: GQView (a linux image viewer) can print images in bulk. (And therefore so can Geeqie)So if you have the split images in a directory, you can print "all" or "selected" files according to the layout rules you specify. I did not find an option to split the images directly in GQView, but the shell script above covers that fine.

0 Trackbacks

  1. No Trackbacks

3 Comments

Display comments as (Linear | Threaded)
  1. Thanks for this. If nothing else it stopped me wasting time looking for a ready made solution. Using lpr to print, the man page says that large images should print across multiple pages, but that didn't work for me. Either I got the whole image shrunk to fit on one page or the first page only, showing the bottom left corner of the image at the right scale. Sometimes doing things manually is faster than trynig to work out how to do them automatically.

    By the way. lp/lpr is pretty handy once you've got the images split. A simple:
    lp split-*
    should print them all out (assuming lpr is set up, which I found fairly easy, but YMMV)
  2. I would like to do this for my sons birthday... Print out life size replicas of star wars charactors... I came across a program PosteRazer? It's just for breaking up your image and letting you print them on multiple sheets of paper. Do you know anything about this program?
  3. Microsoft Paint will do the job.
    See http://scottiestech.info/2009/08/08/how-to-easily-print-a-large-image-to-multiple-pages-in-windows/

    Open the image you’d like to print in Paint
    Select: Print -> Page Setup (Vista and 7), or File -> Page Setup (in XP)
    Under Scaling, select Fit to and change the setting to something like “2 by 2 page(s)”
    Click OK
    Print the image from Paint, and make sure to select “All Pages”

    Too easy - huh?

Add Comment


You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

What is the primary language of this blog? (Anti-SPAM question)


Submitted comments will be subject to moderation before being displayed.