]> git.imager.perl.org - imager.git/blobdiff - lib/Imager/Transformations.pod
CVE-2016-1238 mitigation
[imager.git] / lib / Imager / Transformations.pod
index 4a6557c0defc0df2e316af528390c6261d6319a2..33f6a30188ff4ca670cefc0ed4bfc457d8375e58 100644 (file)
@@ -48,6 +48,11 @@ Imager::Transformations - Simple transformations of one image into another.
                                  [ 1, 0, 0 ],
                                  [ 0, 0, 1 ] ]);
 
+  # build an image using channels from multiple input images
+  $new = $img->combine(src => [ $im1, $im2, $im3 ]);
+  $new = $img->combine(src => [ $im1, $im2, $im3 ],
+                       channels => [ 2, 1, 0 ]);
+
   # limit the range of red channel from 0..255 to 0..127
   @map = map { int( $_/2 } 0..255;
   $img->map( red=>\@map );
@@ -75,14 +80,14 @@ A list of the transformations that do not alter the source image follows:
 
 =over
 
-=item copy
+=item copy()
 
 To create a copy of an image use the C<copy()> method.  This is useful
 if you want to keep an original after doing something that changes the image.
 
   $newimg = $orig->copy();
 
-=item scale
+=item scale()
 
 X<scale>To scale an image so proportions are maintained use the
 C<$img-E<gt>scale()> method.  if you give either a C<xpixels> or
@@ -161,7 +166,7 @@ scale() will fail if C<type> is set to some other value.
 For example, if the original image is 400 pixels wide by 200 pixels
 high and C<xpixels> is set to 300, and C<ypixels> is set to 160.  When
 C<type> is C<'min'> the resulting image is 300 x 150, when C<type> is
-C<'max'> the resulting image is 320 x 150.
+C<'max'> the resulting image is 320 x 160.
 
 C<type> is only used if both C<xpixels> and C<ypixels> are supplied.
 
@@ -520,7 +525,7 @@ A list of the transformations that alter the source image follows:
 
 =over
 
-=item paste
+=item paste()
 
 X<paste>To copy an image to onto another image use the C<paste()>
 method.
@@ -572,7 +577,7 @@ sub image to be pasted.
 If the source image has an alpha channel and the target doesn't, then
 the source is treated as if composed onto a black background.
 
-If the source image is color and the target is gray scale, the the
+If the source image is color and the target is gray scale, the
 source is treated as if run through C<< convert(preset=>'gray') >>.
 
 =item rubthrough()
@@ -599,7 +604,7 @@ Parameters:
 
 =item *
 
-C<tx>, C<ty> - location in the the target image ($self) to render the
+C<tx>, C<ty> - location in the target image ($self) to render the
 top left corner of the source.
 
 =item *
@@ -657,7 +662,7 @@ C<src> - the source image to draw onto the target.  Required.
 
 =item *
 
-C<tx>, C<ty> - location in the the target image ($self) to render the top
+C<tx>, C<ty> - location in the target image ($self) to render the top
 left corner of the source.  These can also be supplied as C<left> and
 C<right>.  Default: (0, 0).
 
@@ -715,7 +720,7 @@ interactive paint software.
 compose() returns true on success.  On failure check $target->errstr
 for the reason for failure.
 
-=item flip
+=item flip()
 
 An inplace horizontal or vertical flip is possible by calling the
 C<flip()> method.  If the original is to be preserved it's possible to
@@ -735,7 +740,7 @@ reason for failure.
 
 =over
 
-=item convert
+=item convert()
 
 You can use the convert method to transform the color space of an
 image using a matrix.  For ease of use some presets are provided.
@@ -867,13 +872,48 @@ alpha channel:
                                            [ 0, 0, 0, 0.5 ],
                                          ]);
 
+=item combine()
+X<combine>
+
+Combine channels from one or more input images into a new image.
+
+Parameters:
+
+=over
+
+=item *
+
+C<src> - a reference to an array of input images.  There must be at least
+one input image.  A given image may appear more than once in C<src>.
+
+=item *
+
+C<channels> - a reference to an array of channels corresponding to the
+source images.  If C<channels> is not supplied then the first channel
+from each input image is used.  If the array referenced by C<channels>
+is shorter than that referenced by C<src> then the first channel is
+used from the extra images.
+
+=back
+
+  # make an rgb image from red, green, and blue images
+  my $rgb = Imager->combine(src => [ $red, $green, $blue ]);
+
+  # convert a BGR image into RGB
+  my $rgb = Imager->combine(src => [ $bgr, $bgr, $bgr ],
+                            channels => [ 2, 1, 0 ]);
+
+  # add an alpha channel from another image
+  my $rgba = Imager->combine(src => [ $rgb, $rgb, $rgb, $alpha ],
+                     channels => [ 0, 1, 2, 0 ]);
+
 =back
 
 =head2 Color Mappings
 
 =over
 
-=item map
+=item map()
 
 You can use the map method to map the values of each channel of an
 image independently using a list of look-up tables.  It's important to
@@ -923,7 +963,7 @@ L<Imager>, L<Imager::Engines>
 
 =head1 AUTHOR
 
-Tony Cook <tony@imager.perl.org>, Arnar M. Hrafnkelsson
+Tony Cook <tonyc@cpan.org>, Arnar M. Hrafnkelsson
 
 =head1 REVISION