contrast(-100...100)
GetFileInformations(filename[,format])
or getfileinformations(filename[,format])
dumpallformats()
GFL::Image - An OO interface to P-e Gougelet's Graphic File Library
use GFL::Image;
my $im = GFL::Image-> new;
$im -> load("test.png"); $im -> set( output => "jpeg", undolevel => 5 ); $im -> resize (320, 200); $im -> filter( maximum => 3, mediancross => 7 ); $im -> undo; $im -> save("test.jpg");
undef ($im);
This module provides an Object Oriented interface to Pierre-E. Gougelet's Graphic File Library.
GFL provides a comprehensive set of image processing tools and can access more than 300 image formats.
GFL is free for non-commercial use, you can grab the latest version at http://www.xnview.org. People wanting to use it in a commercial application must ask authorization to the author.
$a -> set( 'output' => 'bmp')
or
$a -> Set( Output => 'bmp')
or even
$a -> SeT(OUtPuT => 'bmp')
If the idea of loosing 3 seconds per 100000 method calls makes you sick, use all lowercase for method names to avoid Autoloading overhead. (timed on a Duron 850Mhz)
Create a new object.
Assigning attributes via new
is deprecated.
Set single or multiple attributes. Valid attributes are :
If undolevel
changes and happens to be lower than the current number of undos,
older undos are cleared accordingly (in FIFO order).
False - no STDERR report 1 - report normal operations + errors (anonymously) 2 - normal operations + errors, with object identifier 3 - the above plus various internal/cleaning operations
'alias' : Alias Image File 'arcib' : ArcInfo Binary 'bmp' : Windows Bitmap 'cin' : Kodak Cineon 'degas' : Degas & Degas Elite 'dkb' : DKB Ray-Tracer 'gif' : CompuServe GIF 'gpat' : Gimp Pattern 'grob' : HP-48/49 GROB 'hru' : HRU 'ico' : Windows Icon 'iff' : Amiga IFF 'jif' : Jeff's Image Format 'jpeg' : JPEG / JFIF 'miff' : Image Magick file 'mtv' : MTV Ray-Tracer 'palm' : Palm Pilot 'pbm' : Portable Bitmap 'pcl' : Page Control Language 'pcx' : Zsoft Publisher's Paintbrush 'pgm' : Portable Greyscale 'png' : Portable Network Graphics 'pnm' : Portable Image 'ppm' : Portable Pixmap 'psion3' : Psion Serie 3 Bitmap 'psion5' : Psion Serie 5 Bitmap 'qrt' : Qrt Ray-Tracer 'rad' : Radiance 'raw' : Raw 'ray' : Rayshade 'rla' : Wavefront Raster file 'sgi' : Silicon Graphics RGB 'soft' : Softimage 'tga' : Truevision Targa 'ti' : TI Bitmap 'tiff' : TIFF Revision 6 'uyvy' : YUV 16Bits 'uyvyi' : YUV 16Bits Interleaved 'vista' : Vista 'vivid' : Vivid Ray-Tracer 'wbmp' : Wireless Bitmap (level 0) 'wrl' : VRML2 'xbm' : X11 Bitmap 'xpm' : X11 Pixmap
One of: floyd, pattern, halftone45, halftone90
Defaults to floyd
.
jpeg
, wic
, fpx
formats.
0 < value
> 100 (best quality)
png
format.
0 < value
> 6 (best compression)
gif
format.
jpeg
format.
True
, a correct extension is added to the filename
when saving,
or it's extension is replaced if incorrect.
One of: interleaved, sequential, separate
Defaults to: interleaved
One of:
none, rle, lzw, jpeg, zip, sgi_rle, ccitt_rle, ccitt_fax3, ccitt_fax3_2d, ccitt_fax4, wavelet or lzw_predictor
# FIXME : This option does not seem to have any effect ... I'll ask more informations to the GFL library's author.
Input formats are too numerous to be listed here.
Just say dumpallformats()
for a comprehensive list.
1 (default), 2, 4, ...
Get single or multiple attributes.
Valid (case insensitive) attributes are all Set-able attributes plus :
e.g:
$infos = $a->get(FileInformations) || die $a->lasterror; foreach (keys %$infos) { print "$_ => $infos->{$_}\n" if $infos->{$_}; }
sample output:
Origin => 16 Description => Sgi RGB Width => 182 CompressionDescription => Sgi Rle BitsPerPlane => 8 FileSize => 98145 NumberOfPlanes => 3 FormatName => sgi NumberOfImages => 1 FormatIndex => 4 Height => 170 BytesPerPlane => 182 Compression => 5
$infos->{'Width'}
GetFileInformations()
BitmapInformations
attribute.
Sample Hash:
Xdpi => 68 BytesPerLine => 546 Width => 182 BitsPerComponent => 8 Ydpi => 68 Data => GFL_UINT8Ptr=SCALAR(0x81834ec) Height => 170 BytesPerPixel => 3 TransparentIndex => -1 Type => 16
remember this is an hash reference, so you must access every member like this:
$infos->{'Width'}
Open the given file.
input
attribute is set to 'auto' (the default), GFL will attempt to guess the format.
ImageIndex
indicates which image should be loaded in the case of a multi-image or animated file. It is zero-based.
Open a custom size preview for the given file.
The preview becomes the current working bitmap.
input
is set to 'auto' (the default), GFL will attempt to guess the format.
width
and height
will be rounded to the nearest integer value if fractionals.
ImageIndex
indicates which image should be loaded in the case of a multi-image or animated file. It is zero-based.
e.g:
$i = getfileinformations('foo.png') or die; $a = GFL::Image->new; $a -> loadpreview('foo.png', $i->{'Width'}/3, $i->{'Height'}/3);
Save the current Bitmap using attribute Output
as format.
Be aware that there is no checking to see if current Output
format support the actual color depth.
If the GFL library reports `` Can't save this bitmap in this format !'', see ChangeDepth()
method.
Rescale the image to the given Width/Height values.
Width
and Height
are fractionals, they are rounded to the nearest integer.
Flip image on the given axis.
Negate current image
Crop image starting at (x,y) coordinates from current Origin
contrast(-100...100)
Apply a rotation of ``Angle'' degrees.
Apply the given filters.
Where filter_type is one of:
average
, gaussianblur
, maximum
, minimum
, medianbox
, mediancross
And filter_size is one of:
3
, 5
, 7
, 9
, 11
, 13
Multiple filters are applied following arguments order.
Change the color depth of current working bitmap.
new_depth is one of:
binary, 4g, 8g, 16g, 32g, 64g, 128g, 216g, 256g, 8, 16, 32, 64, 128, 216, 256 ,truecolors
Values containing a ``g'' like ``32g'' mean greyscale.
If the dither
attribute is set (boolean), then image is dithered with Adaptative algorithm.
If, additionaly, wanted colordepth is 'binary', then dither will read the binarydither
attribute and use the corresponding algorithm.
Retrieve the last error message.
Those functions aren't really methods : they do not process the object when called from it.
Thus, they don't have error handling as defined in ERROR HANDLING section.
However, if getfileinformations(filename)
is called as a method on an object, you may retrieve
an eventual error via $obj->lasterror
;
getfileinformations()
and dumpallformats()
are also exported (in lowercase) in your namespace,
so you can use them from scratch.
GetFileInformations(filename[,format])
or getfileinformations(filename[,format])
Returns a hash reference containing detailed informations about a given file, or false on error.
If format
is not defined, GFL tries to autodetect it.
See also FileInformations
attribute.
If you've got a patent from UNISIS, you may enable LZW compression (this is class wide). This compression algorithm is used by GIF & TIFF formats.
Always the same sad story...
dumpallformats()
Issue the complete list of supported formats with description and Read/Write flag.
Well, TIMTOWTDI...
To begin with, all methods except get() bring back a status report which is different in LIST and SCALAR context.
Here, you are testing for error. You get a list with two values :
- first value is true if the function failed, false otherwise.
- second value is either an error string or the string 'OK'
e.g:
@error = $a -> rotate(100); if ($error[0]) { print STDERR $error[1]; }
Here, you are testing for Success. You get true if the method succeeded, false otherwise.
e.g:
$a-> rotate(100) && $success++;
In either SCALAR or LIST context, the LastError attribute is always updated with false or an error message after a method call.
As using get()
would also affect lasterror
, you must retrieve it via the special accessor ->lasterror
.
Thus, you can say:
$b = $a -> get('dither'); $errormsg = $a ->lasterror and print "couldn't get dither value : $errormsg\n";
See the Verbose attribute if you want reports on STDERR.
copyright 2001 Germain Garand (germain@ebooksfrance.com)
This wrapper is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
GD(3), Image::Magick(3)