Skip to content

Commit

Permalink
make finding out how to make a transparent image simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Cook committed Dec 6, 2010
1 parent 84f1265 commit 515480c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Imager.pm
Expand Up @@ -4581,6 +4581,9 @@ text, measuring - L<Imager::Font/bounding_box>, L<Imager::Font::BBox>
tiles, color - L<Imager::Filters/mosaic>
transparent images - L<Imager::ImageTypes>,
L<Imager::Cookbook/"Transparent PNG">
=for stopwords unsharp
unsharp mask - L<Imager::Filters/unsharpmask>
Expand Down
19 changes: 19 additions & 0 deletions lib/Imager/Cookbook.pod
Expand Up @@ -91,6 +91,25 @@ say TIFF to JPEG, you'll need multiple output files:
or die $image->errstr;
}

=head2 Transparent PNG

To save to a transparent PNG (or GIF or TIFF) you need to start with
an image with transparency.

To make a transparent image, create an image object with 2 or 4
channels:

# RGB with alpha channel
my $rgba = Imager->new(xsize => $width, ysize => $height, channels => 4);

# Gray with alpha channel
my $graya = Imager->new(xsize => $width, ysize => $height, channels => 2);

By default, the created image will be transparent.

Otherwise, if you have an existing image file with transparency,
simply read it, and the transparency will be preserved.

=head1 IMAGE SYNTHESIS

=head2 Creating an image
Expand Down
6 changes: 4 additions & 2 deletions lib/Imager/ImageTypes.pod
Expand Up @@ -102,15 +102,17 @@ stored. Imager treats these as follows:

=item *

2 samples per color - gray scale image with alpha channel.
2 samples per color - gray scale image with alpha channel, allowing
transparency.

=item *

3 samples per color - RGB image.

=item *

4 samples per color - RGB image with alpha channel.
4 samples per color - RGB image with alpha channel, allowing
transparency.

=back

Expand Down

0 comments on commit 515480c

Please sign in to comment.