Image::IPTCInfo::RasterCaption - get/set IPTC raserized caption w/Image::Magick


        use Image::IPTCInfo::RasterCaption;

        # Access the raw rasterized caption field:
        $info = new Image::IPTCInfo::RasterCaption
                or die "No raster caption!";
        $raw_raster_caption = $info->Attribute('rasterized caption');



Add to Image::IPTCInfo support for the IPTC IIM4 Dataset 2:125 Rasterized Caption.

This is an alpha-state module that sub-classes Josh Carter's Image::IPTCInfo, and you should consult the Image::IPTCInfo for details of how to use it before proceding with this documentation.

This module will loose its alpha status once I've verified it matches the IPTC standard. If anyone has a rasterized caption not produced by this module, please send me a copy!


The IPTC is the International Press & Telecommunications Council. The IIM4 is version four of the Information Interchange Model, which amongst other things allows the embedding of text (and now XML) within images (though XML support is not yet provided by the Perl modules in this namespace).

The IPTC IIM4 specification describes a rasterized caption as containing "...the rasterized object data description and is used where characters that have not been coded are required for the caption."

        Not repeatable, 7360 octets, consisting of binary data,one bit
        per pixel,two value bitmap where 1 (one) represents black and
        0 (zero) represents white.

             -- IPTC-NAA Information Interchange Model Version No. 4,
                October 1997, Page 41

METHOD save_raster_caption

Writes to the file specified in the sole argument the rasterized caption stored in the object's IPTC field of the same name.

Image creation is via Image::Magick so see Image::Magick for further details.

On failure returns undef.

On success returns the path written to.

METHOD load_raster_caption

Sets the IPTC field 'rasterized caption' with a rasterized version of the image located at the path specified in the first argument.

If a second argument is provided, it should be an integer in the range 1-255, representing the threshold at which source image pixels will be included in the rasterized monochrome. The default is 127.

If the image is larger than the standard size, it will be resized. No attempt is made to maintain its aspect ratio, though if there is a demand for this I shall add it.

On failure carps and returns undef.

On success returns a referemce to a scalar containing the rasterized caption.

METHOD set_raster_caption

Fills the rasterized caption with binary data representing supplied text.

This is very elementry: no font metrics what so ever, just calls Image::Magick's Annotate with the text supplied in the first argument, using the point size specified in the second argument, and the font named in the third.

If no size is supplied, defaults to 12 points.

If no font is supplied, then arialuni.ttf is looked for in the fonts directory beneath the directory specified in the environment variable SYSTEMROOT. Failing that, the ImageMagick default is used - YMMV. See the Annotate method in Image::Magick ( for details.

On failure carps and returns undef

On success returns a referemce to a scalar containing the rasterized caption.


Lee Goddard <lgoddard -at- cpan -dot org>.


This module is Copyright (C) 2003, Lee Goddard. All Rights Are Reserved.

When included as part of the Standard Version of Perl or as part of its complete documentation whether printed or otherwise, this work may be distributed only under the terms of Perl's Artistic License. Any distribution of this file or derivatives thereof *outside* of that package requires that special arrangements be made with copyright holder.

Irrespective of its distribution, all code examples in these files are hereby placed into the public domain. You are permitted and encouraged to use this code in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit would be courteous but is not required.


This information is offered in good faith and in the hope that it may be of use, but is not guaranteed to be correct, up to date, or suitable for any particular purpose whatsoever. The author accepts no liability in respect of this module, code, information or its use.