NAME

presize - calculate resized image dimentions keeping the aspect ratio


SYNOPSIS

presize [-l|--long_side |[-s|--short_side] | [-r|--ratio] | [-a|--approximate] | [-v|--verbose] | [--version | [-?|-h|--help] | [long_side_length]


DESCRIPTION

This program calculates the new length of the other side of a rectanglular image when one side is given. It defaults to 4:3 aspect ratio but can be given other ratios, too.

If you give the program a side length with does not have an integer length other side, it will recursively explore and report closest integer lengths above and below the given one. E.g., using the default aspect ratio 4:3, a long side length of 5 pixels would reguire short side length 3.75 pixels which is not feasible, so two closest results are given: '8 x 6' and '4 x 3'.

Extrapolation is disabled if attribute '-approximate' is set. It is automatically disabled if special words are used to set the aspect ratio. These ratios are typically irrational numbers which make it impossible to find an exact match. Currently only words 'phi', 'golden', 'A', 'A4', 'ISO' and 'ISO216' are in use.

This program was first written to calculate side length with the correct ratio when using the crop tool in gimp (1.2 or 2.0). I found gimp's way of setting aspect ratio a bit too cumbersome to be practical.


OPTIONS

[-l | --long |[-s | --short]
Indicate the desired length of the short or long side. If neither argument given, the first unnamed argument will be read in to be the long side. If that fails, the program prints an error message and exits.

-r | --ratio
Set the aspect ratio. Defaults to 4:3. It is customary to give the longer side first. If you give them the other way round, you also swap the meaning of long and short in side lengths.

Special words 'phi' and 'golden' can be used to set the golden ratio (1.61803398874989). To set the ratio to square root of 2 use words 'A', 'A4', 'ISO' or 'ISO216'.

-a | --approximate
The default action of the program is to extrapolate if the side is not an integer. Set this attribute to true to disable it and round the first calculated value to the nearest integer.

-v | --verbose
Print out more information to STDERR.

--version
Print out a line with the program name and version number.

-? | -h | --help
Show this help.


VERSION HISTORY

0.3, 9 Feb 2004, code works

0.4, 14 Feb 2004, more and clearer docs

0.5, 21 Feb 2004, '-approximate' and some irrational numbers ratio values


BUGS

If you set the ratio to something insane in relation to the side length and run perl with warnings, you will get a warning about deep recursion.

Please report other bugs to the author.


LICENSE

You may distribute this module under the same terms as perl itself.


AUTHOR

Heikki Lehvaslaiho, heikki aatt ebi.ac.uk