tags:

views:

486

answers:

4

I would like to split a large PNG file into A4 pages so they can be printed out easily.

I would like to use a Linux command line script to do this:

shell> split-into-a4-sized-pages some-big.png

A: 

You can use convert of ImageMagick to scale the image; there are probably other tools in ImageMagick to clip the image if you want.

A: 

I don't know of any ready-made command line tool to do this. Unless you use it all the time, ImageMagick may take longer to figure out the right combination of commands and options, than to write a quickie program.

An easy way, if you know Python at all, is write a few-line program using PIL (Python Imaging Library). To read an image takes one line. To extract chunks of some width and height at specified location to save as new image files, is also easy. Add a couple for loops to scan rows and columns of A4-sized chunks, and you're done.

If you don't know Python, just about all quick-to-write programming languages have a similar capability. The GD library comes to mind; it has bindings for several languages.

DarenW
A: 

Try using imagemagick's crop to your desired size.

Say you have a 480x480 Lenna image:

alt text

and you want to crop it into 4 240x240 images:

alt text

Use:

convert Lenna.png -crop 240x240+0+0  crop_lenna.png

Now you'd have to find out how many pixels fit into a A4 page in your printer, and the dimensions of the image, and it is a very simple script from here.

Adam Matan
A: 

NetPBM's pamdice will do the splitting into multiple pages. You'll have to set the -width and -height options according to the DPI of your desired A4 images.

And you'll also have to convert the input image to netpbm format first with pngtopam:

pngtopam big.png | pamdice -outstem tile -height h -width w

That will leave you will a bunch of files called tile_x_y.ppm

Convert each one of those to PNG with pnmtopng

David Jones