Scroll to navigation

PDF::Builder::Resource::XObject::Image::PNG(3) User Contributed Perl Documentation PDF::Builder::Resource::XObject::Image::PNG(3)

NAME

PDF::Builder::Resource::XObject::Image::PNG - support routines for PNG image library (using pure Perl code). Inherits from PDF::Builder::Resource::XObject::Image

METHODS

new

    $res = PDF::Builder::Resource::XObject::Image::PNG->new($pdf, $file, %opts)

Returns a PNG-image object. $pdf is the PDF object being added to, $file is the input PNG file, and the optional $name of the new parent image object defaults to PxAAA.

If the Image::PNG::Libpng package is installed, the PNG_IPL library will be used instead of the PNG library. In such a case, use of the PNG library may be forced via the "nouseIPL" flag (see Builder documentation for image_png()).

opts:

'notrans' => 1
No transparency -- ignore tRNS chunk if provided, ignore Alpha channel if provided.
'name' => 'string'
This is the name you can give for the PNG image object. The default is Pxnnnn.

Remember that you need to invoke the image_png method from Builder.pm in order to use this functionality.

Supported PNG types

   (0) Gray scale of depth 1, 2, 4, or 8 bits per pixel (2, 4, 16, or 256 
       gray levels). 16 bpp is not currently supported (a PNG with 16 bpp 
       is a fatal error). Full transparency (of one 8-bit gray value) via 
       the tRNS chunk is allowed, unless the notrans option specifies 
       that it be ignored.
   (2) RGB 24-bit truecolor with 8 bits per sample (16.7 million colors). 
       16 bps is not currently supported (a PNG with 16 bps is a fatal 
       error). Full transparency (of one 3x8-bit RGB color value) via the 
       tRNS chunk is allowed, unless the notrans option specifies that it 
       be ignored.
   (3) Palette color with 1, 2, 4, or 8 bits per pixel (2, 4, 16, or 256
       color table/palette entries). 16 bpp is not currently supported by 
       PNG or PDF. Partial transparency (8-bit Alpha) for each palette 
       entry via the tRNS chunk is allowed, unless the notrans option 
       specifies that it be ignored (all entries fully opaque).
   (4) Gray scale of depth 8 bits per pixel plus 8-bit Alpha channel (256
       gray levels and 256 levels of transparency). 16 bpp is not 
       currently supported (a PNG with 16 bpp is a fatal error). The Alpha 
       channel is ignored if the notrans option is given. The tRNS chunk 
       is not permitted.
   (6) RGB 24-bit truecolor with 8 bits per sample (16.7 million colors) 
       plus 8-bit Alpha channel (256 levels of transparency). 16 bps is not 
       currently supported (a PNG with 16 bps is a fatal error). The Alpha 
       channel is ignored if the notrans option is given. The tRNS chunk 
       is not permitted.

In all cases, 16 bits per sample are not implemented. A fatal error will be returned if a PNG image with 16-bps data is supplied. The code is assuming standard "network" bit ordering (Big Endian). Interlaced (progressive) display images are not supported. Use the PNG_IPL version if you need to support 16 bps or interlaced images.

The transparency chunk (tRNS) will specify one gray level entry or one RGB entry to be treated as transparent (Alpha = 0). For palette color, up to 256 palette entry 8-bit Alpha values are specified (256 levels of transparency, from 0 = transparent to 255 = opaque).

Only a limited number of chunks are handled: IHDR, IDAT (internally), PLTE, tRNS, and IEND (internally). All other chunks are ignored at this time. Certain filters and compressions applied to data will be handled, but there may be unsupported methods.

usesLib

    $mode = $png->usesLib()

Returns 1 if Image::PNG::Libpng installed and used, 0 if not installed, or -1 if installed but not used (nouseIPL option given to "image_png").

Caution: this method can only be used after the image object has been created. It can't tell you whether Image::PNG::Libpng is available in advance of actually using it, in case you want to use some functionality available only in PNG_IPL. See the PDF::Builder LA_IPL() call if you need to know in advance.

2024-03-08 perl v5.40.0