Passport photo maker --- sweet perl utility

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • navatarc
    Fresh Peossy
    • Oct 2004
    • 14

    Passport photo maker --- sweet perl utility

    Source --- http://www.fourmilab.ch/netpbm/passport_photo/
    Download from above.

    passport_photo
    SYNOPSIS

    passport_photo [--black] [--copyright] [--grey/--gray] [--help] [--ifilter program] [--inputfile fname] [--ofilter program] [--outputfile fname] [--paperheight dim] [--paperwidth dim] [--photoheight dim] [--photowidth dim] [--resolution dots/unit] [--verbose] [--version] image_file

    DESCRIPTION

    passport_photo takes an image file containing a single picture with suitable aspect (height to width) ratio and creates an image for a specified printer's paper size and resolution containing as many copies of the original image as will fit, with each scaled to a precise size on the paper. This permits economically creating passport and other identification photos which conform to the size requirements of those requesting them. The program can also be used to print multiple copies of other kinds of pictures on a page, for example, snaps of the family for all the in-laws and outlaws.

    passport_photo is a Perl program which assembles images using components of the Netpbm image processing toolkit; you must have these utilities installed on your computer in order to use it. While these programs are usually associated with Unix (GNU/Linux, etc.) systems, passport_photo works fine on Windows systems with Cygwin (http://www.cygwin.com/) and the requisite programs and libraries installed.

    To obtain the highest quality results, start with a digital camera image or scan of a photographic print made with the highest reasonable resolution--when scanning a photo there's no point setting the resolution so high you can see film grain and paper fibres. The picture should be taken or cropped to ``portrait mode'' (greater height than width) with the same aspect ratio as that required for the individual photos. For example, if photos of the European standard of 45 millimetres high and 35 millimetres wide (aspect ratio 1.286) are being made, and your 5 megapixel digital camera produces images of 2592 by 1944 pixels (aspect ratio 1.333), you should take the photo in portrait mode filling the full 1944 pixel width, then crop the image with the face at the desired position to a height of 2500 pixels to match the aspect ratio of the printed photos. Nothing terrible will happen if the aspect ratios are slightly mismatched, but the image will be smaller due to the need to scale it to fit within the required size.

    OPTIONS

    All options may be abbreviated to their shortest unambiguous prefix.

    --black
    Use black borders between and around images instead of the default white. This is handy when you're using a printer which doesn't fill the entire page (``bleed''), and you wish to measure the actual print area so the individual photos will be scaled to the desired size. It's a poor idea to use this option in other circumstances, as it wastes ink.

    --copyright
    Display copyright information.

    --grey or --gray
    Convert a colour image_file to grey scale. Use this option when grey scale (a.k.a. ``black and white'') photos are required or preferable, for example when applying for a passport from a third world country most of whose bearers have such photos (one place you never want to stand out is at the immigration desk), or a visa for Zeta Reticuli, where such a complexion is de rigueur.

    --help
    Display how to call information.

    --ifilter program
    Specify the Netpbm input filter (for example pngtopnm) used to convert the input file to PPM format. If the input file has an extension of .jpg, .jpeg, .png, .gif, .tif, .tiff, or .pxm, the input filter will be automatically ``guessed'' based on the file type if no --ifilter is specified. Note that you can pass command line options to the input filter by quoting the program argument and specifying them after the filter program name.

    --inputfile fname
    Specifies the name of the input file. This is entirely equivalent to specifying an image_file argument. In either case, a specification of ``-'' causes input to be read from standard input, in which case --ifilter must be specified.

    --ofilter program
    Specify the Netpbm output filter used to write the output file. The default is pnmtojpeg, and unless you really know what you're doing, you shouldn't change this as most services which print digital camera files don't understand file formats other than JPEG. Note that you can pass command line options to the output filter by quoting the program argument and specifying them after the filter program name.

    --outputfile fname
    Specify the name of the output file written by --ofilter. By default, output is written to standard output and may be redirected to a file or piped to another program.

    --paperheight dim
    The height of the image produced by the printer is set to the dimension dim, where ``height'' is taken to mean the longer of the dimensions of the image (hence ``portrait mode''). Note that this specifies the size of the image produced by the printer, not the paper size. If the printer leaves a border around the image, you should print an image with the --black option and measure it to determine the actual printed image size. The dim argument is by default in millimetres. You may specify the dimension in other units by appending a suffix of ``cm'' for centimetres, ``in'' for inches, ``pc'' for picas, or ``pt'' for points. Dimension values may be decimal fractions, but are rounded to integral millimetres. These considerations apply to dim arguments of subsequent options. The default paper height is 150 millimetres (15 cm).

    --paperwidth dim
    The width of the image produced by the printer is set to dim, where ``width'' is the smaller of the dimensions of the image. The default paper width is 100 millimetres (10 cm).

    --photoheight dim
    Each individual photo will have height dim, the larger of the two image dimensions. The default photo height is 45 millimetres (4.5 cm).

    --photowidth dim
    Each individual photo will have width dim, the smaller of the two image dimensions. The default photo width is 35 millimetres (3.5 cm).

    --resolution dots/unit
    The image will be prepared with a resolution of dots/unit, where the dimension is interpreted as a number of dots per unit of length (millimetres if no unit is given). For example, ``48/mm'' (the default value) results in an image with a resolution of 48 dots per millimetre, which is approximately the same as ``1200/in'', 1200 dots per inch.

    --verbose
    Generate verbose output to indicate what's going on, including a transcript of all the Netpbm commands used to prepare the image.

    --version
    Display version number.

    EXAMPLES

    Produce a 10 by 15 centimetre sheet containing six 35 by 45 millimetre passport photos from the image myshot.jpg, writing the ready-to-print 48 dot per millimetre resolution image to JPEG file myprint.jpg:

    perl passport_photo.pl myshot.jpg >myprint.jpg

    Produce an 8 by 10 inch sheet at 1200 dots per inch resolution containing twenty 2 by 2 inch photos as required for United States visa applications.

    perl passport_photo.pl --paperheight 10in --paperwidth 8in
    --photoheight 2in --photowidth 2in
    --resolution 1200/in myshot.jpg >myvisa.jpg

    FILES

    Several intermediate temporary files are created in the current directory, which are assembled into the final image. These files are rather large (about 48 megabytes with the default settings), so make sure there's adequate space on the file system containing the current directory. If the program crashes or is killed before completing, the intermediate files won't be deleted. They all have names which can be deleted by a command such as ``rm *_temp?.ppm as long as you don't have any other files in the directory such a command would inadvertently delete.

    BUGS

    Creating large sheets at high resolution takes lots of memory and substantial compute time. If you run passport_photo on a system with less RAM than the uncompressed image size, forcing paging to disc, it may take almost forever to generate an image.

    One could add any number of fanciful length units to dimension and resolution arguments: parsecs, angstroms, chains, nautical miles, etc. On the other hand, one should have better things to do.

    Yes, I've thought about calling this program ppmpassport or somesuch and submitting it as a Netpbm component. But somebody has to draw the line somewhere against accretion of special-purpose kludges into Netpbm, and here's where I draw it. If somebody does add this, they should remove the input file filtering mechanism and require the input be piped to standard input in PPM format.

    Please report bugs to bugs at fourmilab.ch, indicating the version numbers of passport_photo, Perl, and Netpbm installed on your system.

    AUTHOR

    John Walker (http://www.fourmilab.ch/)

    SEE ALSO


    The Perl Programming Language at Perl.org. Links and other helpful resources for new and experienced Perl programmers.


    VERSION

    This is passport_photo version 1.0, released on August 28th, 2004. The current version of this program is always posted at:



    COPYRIGHT

    This program is in the public domain.
  • Yao
    DUDERZ get a life!!!
    • Jun 2004
    • 8167

    #2
    Re: Passport photo maker --- sweet perl utility

    Cool link dude...i just need to buy a new printer for that ;-)
    Blowkick visual & graphic design - No Civilization. Now With Broadband.

    There are but three true sports -- bullfighting, mountain climbing, and motor-racing. The rest are merely games. -Hemingway

    Comment

    Working...