NAME

GD::Convert - additional output formats for GD

SYNOPSIS

use GD;
use GD::Convert qw(gif=gif_netpbm newFromGif=newFromGif_imagemagick);
...
$gd->ppm;
$gd->xpm;
$gd->gif;
...
$gd = GD::Image->newFromPpmData(...);
$gd = GD::Image->newFromGif(...);

DESCRIPTION

This module provides additional output methods for the GD module: ppm, xpm, gif_netpbm and gif_imagemagick, and also additional constructors: newFromPpm, newFromPpmData, newFromGif_netpbm, newFromGifData_netpbm, newFromGif_imagemagick, newFromGifData_imagemagick.

The new methods go into the GD namespace.

For convenience, it is possible to set shorter names for the gif etc. methods:

gif=gif_netpbm

Use external commands from netpbm to create GIF images.

gif=gif_imagemagick

Use external commands from imagemagick to create GIF images.

gif=any

Use any of the above methods to create GIF images.

The same convenience importer is defined for newFromGif and newFromGifData.

The new methods and constructors:

$ppmdata = $image->ppm

Take a GD image and return a string with a PPM file as its content.

$xpmdata = $image->xpm

Take a GD image and return a string with a XPM file as its content.

$gifdata = $image->gif_netpbm([...])

Take a GD image and return a string with a GIF file as its content. The conversion will use the ppmtogif binary from netpbm. If you specify gif=gif_netpbm in the use line, then you can use the method name gif instead.

The gif_netpbm handles the optional parameter -transparencyhack. If set to a true value, a transparent GIF file will be produced. Note that this will not work if the transparent color occurs also as a normal color.

$gifdata = $image->gif_imagemagick

This is the same as gif_netpbm, instead it is using the convert program of ImageMagick.

$image = GD::Image->newFromPpm($file, [$truecolor])

Create a GD image from the named ppm file or filehandle reference. Only raw ppm files (signature P6) are supported.

$image = GD::Image->newFromPpmData($data, [$truecolor])

Create a GD image from the data string containing ppm data. Only raw ppm files are supported.

$image = GD::Image->newFromGif_netpbm($file, [$truecolor]);

Create a GD image from the named file or filehandle reference using external netpbm programs.

$image = GD::Image->newFromGifData_netpbm($file, [$truecolor]);

Create a GD image from the data string using external netpbm programs.

$image = GD::Image->newFromGif_imagemagick($file, [$truecolor]);

Create a GD image from the named file or filehandle reference using external ImageMagick programs.

$image = GD::Image->newFromGifData_imagemagick($file, [$truecolor]);

Create a GD image from the data string using external ImageMagick programs.

BUGS

Transparency will get lost in PPM images.

The transparency handling for GIF images is clumsy --- maybe the new --alpha option of ppmtogif should be used.

The size of the created files should be smaller, especially of the XPM output.

AUTHOR

Slaven Rezic <slaven@rezic.de>

COPYRIGHT

Copyright (c) 2001,2003 Slaven Rezic. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

GD, netpbm(1), convert(1).