3 Imager::Transformations - Simple transformations of one image into another.
9 $newimg = $img->copy();
11 $newimg = $img->scale(xpixels=>400, qtype => 'mixing');
12 $newimg = $img->scale(xpixels=>400, ypixels=>400);
13 $newimg = $img->scale(xpixels=>400, ypixels=>400, type=>'min');
14 $newimg = $img->scale(scalefactor=>0.25);
16 $newimg = $img->scaleX(pixels=>400);
17 $newimg = $img->scaleX(scalefactor=>0.25);
18 $newimg = $img->scaleY(pixels=>400);
19 $newimg = $img->scaleY(scalefactor=>0.25);
21 $newimg = $img->crop(left=>50, right=>100, top=>10, bottom=>100);
22 $newimg = $img->crop(left=>50, top=>10, width=>50, height=>90);
24 $dest->paste(left=>40,top=>20,img=>$logo);
26 $img->rubthrough(src=>$srcimage,tx=>30, ty=>50);
27 $img->rubthrough(src=>$srcimage,tx=>30, ty=>50,
28 src_minx=>20, src_miny=>30,
29 src_maxx=>20, src_maxy=>30);
31 $img->compose(src => $src, tx => 30, ty => 20, combine => 'color');
32 $img->compose(src => $src, tx => 30, ty => 20, combine => 'color');
33 mask => $mask, opacity => 0.5);
35 $img->flip(dir=>"h"); # horizontal flip
36 $img->flip(dir=>"vh"); # vertical and horizontal flip
37 $newimg = $img->copy->flip(dir=>"v"); # make a copy and flip it vertically
39 my $rot20 = $img->rotate(degrees=>20);
40 my $rotpi4 = $img->rotate(radians=>3.14159265/4);
43 # Convert image to gray
44 $new = $img->convert(preset=>'grey');
46 # Swap red/green channel
47 $new = $img->convert(matrix=>[ [ 0, 1, 0 ],
51 # build an image using channels from multiple input images
52 $new = $img->combine(src => [ $im1, $im2, $im3 ]);
53 $new = $img->combine(src => [ $im1, $im2, $im3 ],
54 channels => [ 2, 1, 0 ]);
56 # limit the range of red channel from 0..255 to 0..127
57 @map = map { int( $_/2 } 0..255;
58 $img->map( red=>\@map );
60 # Apply a Gamma of 1.4
62 my @map = map { int( 0.5 + 255*($_/255)**$gamma ) } 0..255;
63 $img->map(all=>\@map); # inplace conversion
67 The methods described in Imager::Transformations fall into two categories.
68 Either they take an existing image and modify it in place, or they
69 return a modified copy.
71 Functions that modify inplace are C<flip()>, C<paste()>,
72 C<rubthrough()> and C<compose()>. If the original is to be left
73 intact it's possible to make a copy and alter the copy:
75 $flipped = $img->copy()->flip(dir=>'h');
77 =head2 Image copying/resizing/cropping/rotating
79 A list of the transformations that do not alter the source image follows:
85 To create a copy of an image use the C<copy()> method. This is useful
86 if you want to keep an original after doing something that changes the image.
88 $newimg = $orig->copy();
92 X<scale>To scale an image so proportions are maintained use the
93 C<$img-E<gt>scale()> method. if you give either a C<xpixels> or
94 C<ypixels> parameter they will determine the width or height
95 respectively. If both are given the one resulting in a larger image
96 is used, unless you set the C<type> parameter to C<'min'>. example:
97 C<$img> is 700 pixels wide and 500 pixels tall.
99 $newimg = $img->scale(xpixels=>400); # 400x285
100 $newimg = $img->scale(ypixels=>400); # 560x400
102 $newimg = $img->scale(xpixels=>400,ypixels=>400); # 560x400
103 $newimg = $img->scale(xpixels=>400,ypixels=>400,type=>'min'); # 400x285
105 $newimg = $img->scale(xpixels=>400, ypixels=>400),type=>'nonprop'); # 400x400
107 $newimg = $img->scale(scalefactor=>0.25); 175x125
108 $newimg = $img->scale(); # 350x250
110 If you want to create low quality previews of images you can pass
111 C<qtype=E<gt>'preview'> to scale and it will use nearest neighbor
112 sampling instead of filtering. It is much faster but also generates
113 worse looking images - especially if the original has a lot of sharp
114 variations and the scaled image is by more than 3-5 times smaller than
121 C<xpixels>, C<ypixels> - desired size of the scaled image. The
122 C<type> parameter controls whether the larger or smaller of the two
123 possible sizes is chosen, or if the image is scaled
128 C<constrain> - an Image::Math::Constrain object defining the way in
129 which the image size should be constrained.
133 C<scalefactor> - if none of C<xpixels>, C<ypixels>, C<xscalefactor>,
134 C<yscalefactor> or C<constrain> is supplied then this is used as the
135 ratio to scale by. Default: 0.5.
139 C<xscalefactor>, C<yscalefactor> - if both are supplied then the image is
140 scaled as per these parameters, whether this is proportionally or not.
145 C<type> - controls whether the larger or smaller of the two possible
146 sizes is chosen, possible values are:
152 C<min> - the smaller of the 2 sizes are chosen.
156 C<max> - the larger of the 2 sizes. This is the default.
160 C<nonprop> - non-proportional scaling. New in Imager 0.54.
164 scale() will fail if C<type> is set to some other value.
166 For example, if the original image is 400 pixels wide by 200 pixels
167 high and C<xpixels> is set to 300, and C<ypixels> is set to 160. When
168 C<type> is C<'min'> the resulting image is 300 x 150, when C<type> is
169 C<'max'> the resulting image is 320 x 160.
171 C<type> is only used if both C<xpixels> and C<ypixels> are supplied.
175 C<qtype> - defines the quality of scaling performed. Possible values are:
181 C<normal> - high quality scaling. This is the default.
185 C<preview> - lower quality. When scaling down this will skip input
186 pixels, eg. scaling by 0.5 will skip every other pixel. When scaling
187 up this will duplicate pixels.
191 C<mixing> - implements the mixing algorithm implemented by
192 F<pnmscale>. This retains more detail when scaling down than
193 C<normal>. When scaling down this proportionally accumulates sample
194 data from the pixels, resulting in a proportional mix of all of the
195 pixels. When scaling up this will mix pixels when the sampling grid
196 crosses a pixel boundary but will otherwise copy pixel values.
200 scale() will fail if C<qtype> is set to some other value.
202 C<preview> is faster than C<mixing> which is much faster than C<normal>.
206 To scale an image on a given axis without maintaining proportions, it
207 is best to call the scaleX() and scaleY() methods with the required
210 my $scaled = $img->scaleX(pixels=>400)->scaleY(pixels=>200);
212 From Imager 0.54 you can scale without maintaining proportions either
213 by supplying both the C<xscalefactor> and C<yscalefactor> arguments:
215 my $scaled = $img->scale(xscalefactor => 0.5, yscalefactor => 0.67);
217 or by supplying C<xpixels> and C<ypixels> and setting C<type> to
220 my $scaled = $im->scale(xpixels => 200, ypixels => 200, type => 'nonprop');
222 Returns a new scaled image on success. The source image is not
225 Returns false on failure, check the errstr() method for the reason for
228 A mandatory warning is produced if scale() is called in void context.
231 my $image = Imager->new;
232 $image->read(file => 'somefile.jpg')
233 or die $image->errstr;
235 # all full quality unless indicated otherwise
237 my $half = $image->scale;
240 my $double = $image->scale(scalefactor => 2.0);
242 # so a 400 x 400 box fits in the resulting image:
243 my $fit400x400inside = $image->scale(xpixels => 400, ypixels => 400);
244 my $fit400x400inside2 = $image->scale(xpixels => 400, ypixels => 400,
247 # fit inside a 400 x 400 box
248 my $inside400x400 = $image->scale(xpixels => 400, ypixels => 400,
251 # make it 400 pixels wide or high
252 my $width400 = $image->scale(xpixels => 400);
253 my $height400 = $image->scale(ypixels => 400);
255 # low quality scales:
257 my $low = $image->scale(qtype => 'preview');
259 # mixing method scale
260 my $mixed = $image->scale(qtype => 'mixing', scalefactor => 0.1);
262 # using an Image::Math::Constrain object
263 use Image::Math::Constrain;
264 my $constrain = Image::Math::Constrain->new(800, 600);
265 my $scaled = $image->scale(constrain => $constrain);
267 # same as Image::Math::Constrain version
268 my $scaled2 = $image->scale(xpixels => 800, ypixels => 600, type => 'min');
272 scaleX() will scale along the X dimension, return a new image with the
275 my $newimg = $img->scaleX(pixels=>400); # 400x500
276 $newimg = $img->scaleX(scalefactor=>0.25) # 175x500
282 C<scalefactor> - the amount to scale the X axis. Ignored if C<pixels> is
283 provided. Default: 0.5.
287 C<pixels> - the new width of the image.
291 Returns a new scaled image on success. The source image is not
294 Returns false on failure, check the errstr() method for the reason for
297 A mandatory warning is produced if scaleX() is called in void context.
301 scaleY() will scale along the Y dimension, return a new image with the
304 $newimg = $img->scaleY(pixels=>400); # 700x400
305 $newimg = $img->scaleY(scalefactor=>0.25) # 700x125
311 C<scalefactor> - the amount to scale the Y axis. Ignored if C<pixels> is
312 provided. Default: 0.5.
316 C<pixels> - the new height of the image.
320 Returns a new scaled image on success. The source image is not
323 Returns false on failure, check the errstr() method for the reason for
326 A mandatory warning is produced if scaleY() is called in void context.
328 =item scale_calculate()
330 Performs the same calculations that the scale() method does to
331 calculate the scaling factors from the parameters you pass.
333 scale_calculate() can be called as an object method, or as a class
336 Takes the following parameters over scale():
342 C<width>, C<height> - the image width and height to base the scaling on.
343 Required if scale_calculate() is called as a class method. If called
344 as an object method these default to the image width and height
349 You might use scale_calculate() as a class method when generating an
350 HTML C<IMG> tag, for example.
352 Returns an empty list on failure.
354 Returns a list containing horizontal scale factor, vertical scale
355 factor, new width, new height, on success.
357 my ($x_scale, $y_scale, $new_width, $new_height) =
358 Imager->scale_calculate(width => 1024, height => 768,
359 ypixels => 180, type => 'min');
361 my ($x_scale, $y_scale, $new_width, $new_height) =
362 $img->scale_calculate(xpixels => 200, type => 'min');
366 =for stopwords resize
368 Another way to resize an image is to crop it. The parameters to
369 crop are the edges of the area that you want in the returned image,
370 where the right and bottom edges are non-inclusive. If a parameter is
371 omitted a default is used instead.
373 crop() returns the cropped image and does not modify the source image.
375 The possible parameters are:
381 C<left> - the left edge of the area to be cropped. Default: 0
385 C<top> - the top edge of the area to be cropped. Default: 0
389 C<right> - the right edge of the area to be cropped. Default: right
394 C<bottom> - the bottom edge of the area to be cropped. Default:
395 bottom edge of image.
399 C<width> - width of the crop area. Ignored if both C<left> and C<right> are
400 supplied. Centered on the image if neither C<left> nor C<right> are
405 C<height> - height of the crop area. Ignored if both C<top> and
406 C<bottom> are supplied. Centered on the image if neither C<top> nor
407 C<bottom> are supplied.
413 # these produce the same image
414 $newimg = $img->crop(left=>50, right=>100, top=>10, bottom=>100);
415 $newimg = $img->crop(left=>50, top=>10, width=>50, height=>90);
416 $newimg = $img->crop(right=>100, bottom=>100, width=>50, height=>90);
418 # and the following produce the same image
419 $newimg = $img->crop(left=>50, right=>100);
420 $newimg = $img->crop(left=>50, right=>100, top=>0,
421 bottom=>$img->getheight);
423 # grab the top left corner of the image
424 $newimg = $img->crop(right=>50, bottom=>50);
426 You can also specify width and height parameters which will produce a
427 new image cropped from the center of the input image, with the given
430 $newimg = $img->crop(width=>50, height=>50);
432 If you supply C<left>, C<width> and C<right> values, the C<right>
433 value will be ignored. If you supply C<top>, C<height> and C<bottom>
434 values, the C<bottom> value will be ignored.
436 The edges of the cropped area default to the edges of the source
439 # a vertical bar from the middle from top to bottom
440 $newimg = $img->crop(width=>50);
443 $newimg = $img->crop(left=>$img->getwidth() / 2);
445 If the resulting image would have zero width or height then crop()
446 returns false and $img->errstr is an appropriate error message.
448 A mandatory warning is produced if crop() is called in void context.
452 Use the rotate() method to rotate an image. This method will return a
455 To rotate by an exact amount in degrees or radians, use the 'degrees'
456 or 'radians' parameter:
458 my $rot20 = $img->rotate(degrees=>20);
459 my $rotpi4 = $img->rotate(radians=>3.14159265/4);
461 Exact image rotation uses the same underlying transformation engine as
462 the matrix_transform() method (see Imager::Engines).
464 You can also supply a C<back> argument which acts as a background
465 color for the areas of the image with no samples available (outside
466 the rectangle of the source image.) This can be either an
467 Imager::Color or Imager::Color::Float object. This is B<not> mixed
468 transparent pixels in the middle of the source image, it is B<only>
469 used for pixels where there is no corresponding pixel in the source
472 To rotate in steps of 90 degrees, use the 'right' parameter:
474 my $rotated = $img->rotate(right=>270);
476 Rotations are clockwise for positive values.
484 C<right> - rotate by an exact multiple of 90 degrees, specified in
489 C<radians> - rotate by an angle specified in radians.
493 C<degrees> - rotate by an angle specified in degrees.
497 C<back> - for C<radians> and C<degrees> this is the color used for the
498 areas not covered by the original image. For example, the corners of
499 an image rotated by 45 degrees.
501 This can be either an Imager::Color object, an Imager::Color::Float
502 object or any parameter that Imager can convert to a color object, see
503 L<Imager::Draw/Color Parameters> for details.
505 This is B<not> mixed transparent pixels in the middle of the source
506 image, it is B<only> used for pixels where there is no corresponding
507 pixel in the source image.
509 Default: transparent black.
513 # rotate 45 degrees clockwise,
514 my $rotated = $img->rotate(degrees => 45);
516 # rotate 10 degrees counter-clockwise
517 # set pixels not sourced from the original to red
518 my $rotated = $img->rotate(degrees => -10, back => 'red');
522 =head2 Image pasting/flipping
524 A list of the transformations that alter the source image follows:
530 X<paste>To copy an image to onto another image use the C<paste()>
533 $dest->paste(left=>40, top=>20, src=>$logo);
535 That copies the entire C<$logo> image onto the C<$dest> image so that the
536 upper left corner of the C<$logo> image is at (40,20).
544 C<src>, C<img> - the source image. C<src> added for compatibility with
549 C<left>, C<top> - position in output of the top left of the pasted image.
554 C<src_minx>, C<src_miny> - the top left corner in the source image to start
555 the paste from. Default: (0, 0)
559 C<src_maxx>, C<src_maxy> - the bottom right in the source image of the sub
560 image to paste. This position is B<non> inclusive. Default: bottom
561 right corner of the source image.
565 C<width>, C<height> - if the corresponding src_maxx or src_maxy is not
566 defined then width or height is used for the width or height of the
567 sub image to be pasted.
571 # copy the 20x20 pixel image from (20,20) in $src_image to (10,10) in $img
572 $img->paste(src=>$src_image,
573 left => 10, top => 10,
574 src_minx => 20, src_miny => 20,
575 src_maxx => 40, src_maxx => 40);
577 If the source image has an alpha channel and the target doesn't, then
578 the source is treated as if composed onto a black background.
580 If the source image is color and the target is gray scale, the
581 source is treated as if run through C<< convert(preset=>'gray') >>.
585 A more complicated way of blending images is where one image is
586 put 'over' the other with a certain amount of opaqueness. The
587 method that does this is rubthrough().
589 $img->rubthrough(src=>$overlay,
591 src_minx=>20, src_miny=>30,
592 src_maxx=>20, src_maxy=>30);
594 That will take the sub image defined by I<$overlay> and
595 I<[src_minx,src_maxx)[src_miny,src_maxy)> and overlay it on top of
596 I<$img> with the upper left corner at (30,50). You can rub 2 or 4
597 channel images onto a 3 channel image, or a 2 channel image onto a 1
598 channel image. The last channel is used as an alpha channel. To add
599 an alpha channel to an image see I<convert()>.
607 C<tx>, C<ty> - location in the target image ($self) to render the
608 top left corner of the source.
612 C<src_minx>, C<src_miny> - the top left corner in the source to transfer to
613 the target image. Default: (0, 0).
617 C<src_maxx>, C<src_maxy> - the bottom right in the source image of the sub
618 image to overlay. This position is B<non> inclusive. Default: bottom
619 right corner of the source image.
623 # overlay all of $source onto $targ
624 $targ->rubthrough(tx => 20, ty => 25, src => $source);
626 # overlay the top left corner of $source onto $targ
627 $targ->rubthrough(tx => 20, ty => 25, src => $source,
628 src_maxx => 20, src_maxy => 20);
630 # overlay the bottom right corner of $source onto $targ
631 $targ->rubthrough(tx => 20, ty => 30, src => $src,
632 src_minx => $src->getwidth() - 20,
633 src_miny => $src->getheight() - 20);
635 rubthrough() returns true on success. On failure check
636 C<< $target->errstr >> for the reason for failure.
640 Draws the source image over the target image, with the source alpha
641 channel modified by the optional mask and the opacity.
643 $img->compose(src=>$overlay,
645 src_minx=>20, src_miny=>30,
646 src_maxx=>20, src_maxy=>30,
647 mask => $mask, opacity => 0.5);
649 That will take the sub image defined by I<$overlay> and
650 I<[src_minx,src_maxx)[src_miny,src_maxy)> and overlay it on top of
651 I<$img> with the upper left corner at (30,50). You can rub 2 or 4
652 channel images onto a 3 channel image, or a 2 channel image onto a 1
661 C<src> - the source image to draw onto the target. Required.
665 C<tx>, C<ty> - location in the target image ($self) to render the top
666 left corner of the source. These can also be supplied as C<left> and
667 C<right>. Default: (0, 0).
671 C<src_minx>, C<src_miny> - the top left corner in the source to transfer to
672 the target image. Default: (0, 0).
676 C<src_maxx>, C<src_maxy> - the bottom right in the source image of the sub
677 image to overlay. This position is B<non> inclusive. Default: bottom
678 right corner of the source image.
682 C<mask> - a mask image. The first channel of this image is used to
683 modify the alpha channel of the source image. This can be used to
684 mask out portions of the source image. Where the first channel is
685 zero none of the source image will be used, where the first channel is
686 maximum the full alpha of the source image will be used, as further
687 modified by the opacity.
691 opacity - further modifies the alpha channel of the source image, in
692 the range 0.0 to 1.0. Default: 1.0.
696 combine - the method to combine the source pixels with the target.
697 See the combine option documentation in Imager::Fill. Default:
702 Calling compose() with no mask, combine set to C<normal>, opacity set
703 to C<1.0> is equivalent to calling rubthrough().
705 compose() is intended to be produce similar effects to layers in
706 interactive paint software.
708 # overlay all of $source onto $targ
709 $targ->compose(tx => 20, ty => 25, src => $source);
711 # overlay the top left corner of $source onto $targ
712 $targ->compose(tx => 20, ty => 25, src => $source,
713 src_maxx => 20, src_maxy => 20);
715 # overlay the bottom right corner of $source onto $targ
716 $targ->compose(tx => 20, ty => 30, src => $src,
717 src_minx => $src->getwidth() - 20,
718 src_miny => $src->getheight() - 20);
720 compose() returns true on success. On failure check $target->errstr
721 for the reason for failure.
725 An inplace horizontal or vertical flip is possible by calling the
726 C<flip()> method. If the original is to be preserved it's possible to
727 make a copy first. The only parameter it takes is the C<dir>
728 parameter which can take the values C<h>, C<v>, C<vh> and C<hv>.
730 $img->flip(dir=>"h"); # horizontal flip
731 $img->flip(dir=>"vh"); # vertical and horizontal flip
732 $nimg = $img->copy->flip(dir=>"v"); # make a copy and flip it vertically
734 flip() returns true on success. On failure check $img->errstr for the
739 =head2 Color transformations
745 You can use the convert method to transform the color space of an
746 image using a matrix. For ease of use some presets are provided.
748 The convert method can be used to:
754 convert an RGB or RGBA image to gray scale.
758 convert a gray scale image to RGB.
762 extract a single channel from an image.
766 set a given channel to a particular value (or from another channel)
770 The currently defined presets are:
776 C<gray>, C<grey> - converts an RGBA image into a gray scale image with
777 alpha channel, or an RGB image into a gray scale image without an
780 This weights the RGB channels at 22.2%, 70.7% and 7.1% respectively.
784 C<noalpha> - removes the alpha channel from a 2 or 4 channel image.
785 An identity for other images.
789 C<red>, C<channel0> - extracts the first channel of the image into a
794 C<green>, C<channel1> - extracts the second channel of the image into
795 a single channel image
799 C<blue>, C<channel2> - extracts the third channel of the image into a
804 C<alpha> - extracts the alpha channel of the image into a single
807 If the image has 1 or 3 channels (assumed to be gray scale or RGB) then
808 the resulting image will be all white.
814 converts a gray scale image to RGB, preserving the alpha channel if any
818 C<addalpha> - adds an alpha channel to a gray scale or RGB image.
819 Preserves an existing alpha channel for a 2 or 4 channel image.
823 For example, to convert an RGB image into a gray scale image:
825 $new = $img->convert(preset=>'grey'); # or gray
827 or to convert a gray scale image to an RGB image:
829 $new = $img->convert(preset=>'rgb');
831 The presets aren't necessary simple constants in the code, some are
832 generated based on the number of channels in the input image.
834 If you want to perform some other color transformation, you can use
835 the 'matrix' parameter.
837 For each output pixel the following matrix multiplication is done:
839 | channel[0] | | $c00, ..., $c0k | | inchannel[0] |
840 | ... | = | ... | x | ... |
841 | channel[k] | | $ck0, ..., $ckk | | inchannel[k] |
843 Where C<k = $img-E<gt>getchannels()-1>.
845 So if you want to swap the red and green channels on a 3 channel image:
847 $new = $img->convert(matrix=>[ [ 0, 1, 0 ],
851 or to convert a 3 channel image to gray scale using equal weightings:
853 $new = $img->convert(matrix=>[ [ 0.333, 0.333, 0.334 ] ])
855 Convert a 2 channel image (gray scale with alpha) to an RGBA image with
856 the gray converted to the specified RGB color:
858 # set (RGB) scaled on the grey scale portion and copy the alpha
860 my $colored = $gray->convert(matrix=>[ [ ($red/255), 0 ],
866 To convert a 3 channel image to a 4 channel image with a 50 percent
869 my $withalpha = $rgb->convert(matrix =>[ [ 1, 0, 0, 0 ],
878 Combine channels from one or more input images into a new image.
886 C<src> - a reference to an array of input images. There must be at least
887 one input image. A given image may appear more than once in C<src>.
891 C<channels> - a reference to an array of channels corresponding to the
892 source images. If C<channels> is not supplied then the first channel
893 from each input image is used. If the array referenced by C<channels>
894 is shorter than that referenced by C<src> then the first channel is
895 used from the extra images.
899 # make an rgb image from red, green, and blue images
900 my $rgb = Imager->combine(src => [ $red, $green, $blue ]);
902 # convert a BGR image into RGB
903 my $rgb = Imager->combine(src => [ $bgr, $bgr, $bgr ],
904 channels => [ 2, 1, 0 ]);
906 # add an alpha channel from another image
907 my $rgba = Imager->combine(src => [ $rgb, $rgb, $rgb, $alpha ],
908 channels => [ 0, 1, 2, 0 ]);
912 =head2 Color Mappings
918 You can use the map method to map the values of each channel of an
919 image independently using a list of look-up tables. It's important to
920 realize that the modification is made inplace. The function simply
921 returns the input image again or undef on failure.
923 Each channel is mapped independently through a look-up table with 256
924 entries. The elements in the table should not be less than 0 and not
925 greater than 255. If they are out of the 0..255 range they are
926 clamped to the range. If a table does not contain 256 entries it is
929 Single channels can mapped by specifying their name and the mapping
930 table. The channel names are C<red>, C<green>, C<blue>, C<alpha>.
932 @map = map { int( $_/2 } 0..255;
933 $img->map( red=>\@map );
935 It is also possible to specify a single map that is applied to all
936 channels, alpha channel included. For example this applies a gamma
937 correction with a gamma of 1.4 to the input image.
940 @map = map { int( 0.5 + 255*($_/255)**$gamma ) } 0..255;
941 $img->map(all=> \@map);
943 The C<all> map is used as a default channel, if no other map is
944 specified for a channel then the C<all> map is used instead. If we
945 had not wanted to apply gamma to the alpha channel we would have used:
947 $img->map(all=> \@map, alpha=>[]);
949 Since C<[]> contains fewer than 256 element the gamma channel is
952 It is also possible to simply specify an array of maps that are
953 applied to the images in the RGBA order. For example to apply
954 maps to the C<red> and C<blue> channels one would use:
956 $img->map(maps=>[\@redmap, [], \@bluemap]);
962 L<Imager>, L<Imager::Engines>
966 Tony Cook <tonyc@cpan.org>, Arnar M. Hrafnkelsson