Extracted from Pike v7.4 release 117 at 2005-08-23.
pike.ida.liu.se
[Top]
predef::
Image
Image.PNG

Method Image.PNG._decode()


Method _decode

array Image.PNG._decode(string|array data)
array Image.PNG._decode(string|array data, mapping options)

Description

Decode a PNG image file.

Result is a mapping,

([
   "image": object image,
 
   ... options ...
])

image is the stored image.

Valid entries in options is a superset of the one given to encode :

basic options:
 
    "alpha": object alpha,            - alpha channel
 
    "palette": object colortable,     - image palette
                                        (if non-truecolor)
 
advanced options:
 
    "background": array(int) color,   - suggested background color
    "background_index": int index,    - what index in colortable
 
    "chroma": ({ float white_point_x,
                 float white_point_y,
                 float red_x,
                 float red_y,         - CIE x,y chromaticities
                 float green_x,
                 float green_y,
                 float blue_x,
                 float blue_y })
 
    "gamma":  float gamma,            - gamma
 
    "spalette": object colortable,    - suggested palette,
                                        for truecolor images
    "histogram": array(int) hist,     - histogram for the image,
                                        corresponds to palette index
 
    "physical": ({ int unit,          - physical pixel dimension
                   int x,y })           unit 0 means pixels/meter
 
    "sbit": array(int) sbits          - significant bits
 
    "text": array(array(string)) text - text information,
            ({ ({ keyword, data }), ... })
 
            Standard keywords:
 
            Title          Short (one line) title or caption for image
            Author         Name of image's creator
            Description    Description of image (possibly long)
            Copyright      Copyright notice
            Creation Time  Time of original image creation
            Software       Software used to create the image
            Disclaimer     Legal disclaimer
            Warning        Warning of nature of content
            Source         Device used to create the image
            Comment        Miscellaneous comment
 
    "time": ({ int year, month, day,  - time of last modification
               hour, minute, second })
 
 wizard options:
    "compression": int method         - compression method (0)
 
 

This method can also take options, as a mapping:

advanced options:
    "palette": colortable object
        - replace the decoded palette with this when
          unpacking the image data, if applicable

Note

Please read about the PNG file format. This function ignores any checksum errors in the file. A PNG of higher color resolution than the Image module supports (8 bit) will lose that information in the conversion. It throws an error if the image data is erroneous.