Subject: | a few tweaks to the documentation [patch] |
Hi,
I noticed a minor bug in the SYNOPSIS code (a single '=' where there should be '==') and thought I'd fix it. The attached patch does. I also made a few other changes while I was at it:
* some tweaks to whitespace to avoid warnings from podchecker
* a few typo fixes and and extra bit of explanation in the prose
* and a correction to some escaping which wasn't working
hope that helps,
geoff
--- lib/Image/Math/Constrain.pm.orig 2005-07-04 18:21:41.306754927 +0100
+++ lib/Image/Math/Constrain.pm 2005-07-04 18:58:46.989141110 +0100
@@ -9,38 +9,40 @@
=head1 SYNOPSIS
+ use Image::Math::Constrain;
+
# Create the math object
my $Math = Image::Math::Constrain->new(64, 48);
-
+
# Get the scaling values for an arbitrary image
my $Image = My::Image->load("myimage.jpg");
my $scaling = $Math->constrain($Image->width, $Image->height);
- die "Don't need to scale" if $scaling->{scale} = 1;
-
+ die "Don't need to scale" if $scaling->{scale} == 1;
+
# Returns the three values as a list when called in array contect
my ($width, $height, $scale) = $Math->constrain(800, 600);
# There are lots of different ways to specify the constrain
-
+
# Constrain based on width only
$Math = Image::Math::Constrain->new(100, 0);
-
+
# Constrain based on height only
$Math = Image::Math::Constrain->new(0, 100);
# Or you can provide the two values by ARRAY ref
$Math = Image::Math::Constrain->new( [ 64, 48 ] );
-
+
# Constrain height and width by the same value
$Math = Image::Math::Constrain->new(100);
-
+
# Various string forms to do the same thing
$Math = Image::Math::Constrain->new('constrain(800x600)');
$Math = Image::Math::Constrain->new('300x200');
$Math = Image::Math::Constrain->new('300w200h');
$Math = Image::Math::Constrain->new('100w');
$Math = Image::Math::Constrain->new('100h');
-
+
# Serialises back to 'constrain(800x600)'.
# You can use this to store the object if you wish.
my $string = $Math->as_string;
@@ -56,7 +58,7 @@
Of course, they all do it slightly differnetly, and some do it better
than others.
-Image::Math::Constrain has been created to specifically to implement
+Image::Math::Constrain has been created specifically to implement
this logic once, and implement it properly. Any module or script that
does image size constraining or thumbnailing should probably be using
this for it's math.
@@ -100,12 +102,12 @@
scaling, at least one of which should match the constraint.
A value of zero is used to indicate that a dimension should not be
-constrained. Thus, C<<->new(400, 0)>> would indicate to constrain the
+constrained. Thus, C<-E<gt>new(400, 0)> would indicate to constrain the
width to 400 pixels, but to ignore the height (only changing it to keep
the image proportional).
The constraint dimensions can be provided in a number of different
-formats. See the Synopsis about for a quick list of these. To stay
+formats. See the Synopsis for a quick list of these. To stay
compatible with automated constraint generators, you B<can> provide
constrains as zero width and zero height, and the math object will not
attempt to do any scaling, always returning the input width/height,
@@ -212,7 +214,9 @@
The C<constrain> method takes the height and width of an image and
applies the constrain math to them to get the final width, height
and the scaling value needed in order to get the your image from
-it's current size to the final size.
+it's current size to the final size. The resulting size will be
+in proportion to the original (it will have the same aspect ratio)
+and will never be larger than the original.
When called in array context, returns the new dimensions and scaling value
as a list, as in the following.
@@ -223,7 +227,7 @@
the keys 'width', 'height', and 'scale'.
my $hash = $Math->constrain(800, 600);
-
+
print "New Width : $hash->{width}\n";
print "New Height : $hash->{height}\n";
print "Scaling By : $hash->{scalar}\n";