File Coverage

blib/lib/PDL/IO/Image.pm
Criterion Covered Total %
statement 107 120 89.1
branch 24 48 50.0
condition n/a
subroutine 67 68 98.5
pod 2 60 3.3
total 200 296 67.5


line stmt bran cond sub pod time code
1              
2             #
3             # GENERATED WITH PDL::PP! Don't modify!
4             #
5             package PDL::IO::Image;
6              
7             @EXPORT_OK = qw( wimage rimage );
8             %EXPORT_TAGS = (Func=>[@EXPORT_OK]);
9              
10 22     22   4697895 use PDL::Core;
  22         303668  
  22         152  
11 22     22   5676 use PDL::Exporter;
  22         58  
  22         129  
12 22     22   818 use DynaLoader;
  22         56  
  22         1449  
13              
14              
15              
16             $PDL::IO::Image::VERSION = 1.001;
17             @ISA = ( 'PDL::Exporter','DynaLoader' );
18             push @PDL::Core::PP, __PACKAGE__;
19             bootstrap PDL::IO::Image $VERSION;
20              
21              
22              
23              
24              
25              
26              
27              
28 22     22   139 use strict;
  22         50  
  22         570  
29 22     22   110 use warnings;
  22         45  
  22         685  
30 22     22   111 use Carp;
  22         43  
  22         1288  
31              
32             #XXX FIXME probably OK for now
33             {
34 22     22   129 no strict 'refs';
  22         47  
  22         38517  
35             *{'PDL::wimage'} = \&PDL::IO::Image::wimage;
36             }
37              
38             sub _val2list {
39 0 0   0   0 return @{$_[0]} if ref $_[0] eq 'ARRAY';
  0         0  
40 0         0 return $_[0];
41             };
42              
43             sub rimage {
44 38 100   38 1 508085 my $options = ref $_[-1] eq 'HASH' ? pop : {};
45 38         157 my $filename = shift;
46 38 50       341 $options->{format} = "AUTO" unless defined $options->{format};
47 38 50       228 $options->{format_flag} = 0 unless defined $options->{format_flag};
48 38 50       296 $options->{page} = 0 unless defined $options->{page};
49 38         25035 my $pimage = PDL::IO::Image->new_from_file($filename, $options->{format}, $options->{format_flag}, $options->{page});
50              
51 38 50       504 if (my $flip = $options->{flip}) {
52 0 0       0 $pimage->flip_horizontal if $flip =~ /H/;
53 0 0       0 $pimage->flip_vertical if $flip =~ /V/;
54             }
55 38 50       215 if (defined $options->{rotate}) {
56 0         0 $pimage->rotate(_val2list($options->{rotate}));
57             }
58 38 50       179 if (defined $options->{convert_image_type}) {
59 0         0 $pimage->convert_image_type(_val2list($options->{convert_image_type}));
60             }
61              
62 38 50       274 $options->{region} = [] unless ref $options->{region} eq 'ARRAY';
63 38 100       165 if ($options->{palette}) {
64 3         13 return ($pimage->pixels_to_pdl(@{$options->{region}}), $pimage->palette_to_pdl);
  3         159  
65             }
66 35         123 return $pimage->pixels_to_pdl(@{$options->{region}});
  35         1428  
67             }
68              
69             sub wimage {
70 13 100   13 1 2569260 my $options = ref $_[-1] eq 'HASH' ? pop : {};
71 13         66 my ($pixels, $filename) = @_;
72 13 100       85 my $palette = $options->{palette} if ref $options->{palette} eq 'PDL';
73 13 100       937 my $pimage = defined $palette ?
74             PDL::IO::Image->new_from_pdl($pixels, $palette) :
75             PDL::IO::Image->new_from_pdl($pixels);
76              
77 13 50       82 if (my $flip = $options->{flip}) {
78 0 0       0 $pimage->flip_horizontal if $flip =~ /H/;
79 0 0       0 $pimage->flip_vertical if $flip =~ /V/;
80             }
81 13 50       120 if (defined $options->{rotate}) {
82 0         0 $pimage->rotate(_val2list($options->{rotate}));
83             }
84 13 50       61 if (defined $options->{rescale}) {
85 0         0 $pimage->rescale(_val2list($options->{rescale}));
86             }
87 13 50       55 if (defined $options->{rescale_pct}) {
88 0         0 $pimage->rescale_pct(_val2list($options->{rescale_pct}));
89             }
90 13 50       59 if (defined $options->{convert_image_type}) {
91 0         0 $pimage->convert_image_typeconvert_image_type(_val2list($options->{convert_image_type}));
92             }
93              
94 13 50       89 $options->{format} = "AUTO" unless defined $options->{format};
95 13 50       70 $options->{format_flag} = 0 unless defined $options->{format_flag};
96 13         66703 $pimage->save($filename, $options->{format}, $options->{format_flag});
97 13         355 return $pixels;
98             }
99              
100              
101              
102             ### Constants
103              
104 1     1 0 239680 sub BMP_SAVE_RLE() { (constant('BMP_SAVE_RLE'))[1] }
105              
106 1     1 0 32 sub EXR_FLOAT() { (constant('EXR_FLOAT'))[1] }
107              
108 1     1 0 12 sub EXR_NONE() { (constant('EXR_NONE'))[1] }
109              
110 1     1 0 11 sub EXR_ZIP() { (constant('EXR_ZIP'))[1] }
111              
112 1     1 0 10 sub EXR_PIZ() { (constant('EXR_PIZ'))[1] }
113              
114 1     1 0 12 sub EXR_PXR24() { (constant('EXR_PXR24'))[1] }
115              
116 1     1 0 9 sub EXR_B44() { (constant('EXR_B44'))[1] }
117              
118 1     1 0 7 sub EXR_LC() { (constant('EXR_LC'))[1] }
119              
120 1     1 0 8 sub GIF_LOAD256() { (constant('GIF_LOAD256'))[1] }
121              
122 1     1 0 9 sub GIF_PLAYBACK() { (constant('GIF_PLAYBACK'))[1] }
123              
124 1     1 0 8 sub ICO_MAKEALPHA() { (constant('ICO_MAKEALPHA'))[1] }
125              
126 1     1 0 9 sub JPEG_FAST() { (constant('JPEG_FAST'))[1] }
127              
128 1     1 0 9 sub JPEG_ACCURATE() { (constant('JPEG_ACCURATE'))[1] }
129              
130 1     1 0 8 sub JPEG_CMYK() { (constant('JPEG_CMYK'))[1] }
131              
132 1     1 0 23 sub JPEG_EXIFROTATE() { (constant('JPEG_EXIFROTATE'))[1] }
133              
134 1     1 0 8 sub JPEG_GREYSCALE() { (constant('JPEG_GREYSCALE'))[1] }
135              
136 1     1 0 9 sub JPEG_QUALITYSUPERB() { (constant('JPEG_QUALITYSUPERB'))[1] }
137              
138 1     1 0 8 sub JPEG_QUALITYGOOD() { (constant('JPEG_QUALITYGOOD'))[1] }
139              
140 1     1 0 8 sub JPEG_QUALITYNORMAL() { (constant('JPEG_QUALITYNORMAL'))[1] }
141              
142 1     1 0 8 sub JPEG_QUALITYAVERAGE() { (constant('JPEG_QUALITYAVERAGE'))[1] }
143              
144 1     1 0 12 sub JPEG_QUALITYBAD() { (constant('JPEG_QUALITYBAD'))[1] }
145              
146 1     1 0 11 sub JPEG_PROGRESSIVE() { (constant('JPEG_PROGRESSIVE'))[1] }
147              
148 1     1 0 11 sub JPEG_SUBSAMPLING_411() { (constant('JPEG_SUBSAMPLING_411'))[1] }
149              
150 1     1 0 10 sub JPEG_SUBSAMPLING_420() { (constant('JPEG_SUBSAMPLING_420'))[1] }
151              
152 1     1 0 10 sub JPEG_SUBSAMPLING_422() { (constant('JPEG_SUBSAMPLING_422'))[1] }
153              
154 1     1 0 13 sub JPEG_SUBSAMPLING_444() { (constant('JPEG_SUBSAMPLING_444'))[1] }
155              
156 1     1 0 26 sub JPEG_OPTIMIZE() { (constant('JPEG_OPTIMIZE'))[1] }
157              
158 1     1 0 8 sub JPEG_BASELINE() { (constant('JPEG_BASELINE'))[1] }
159              
160 1     1 0 11 sub PCD_BASE() { (constant('PCD_BASE'))[1] }
161              
162 1     1 0 11 sub PCD_BASEDIV4() { (constant('PCD_BASEDIV4'))[1] }
163              
164 1     1 0 29 sub PCD_BASEDIV16() { (constant('PCD_BASEDIV16'))[1] }
165              
166 1     1 0 10 sub PNG_IGNOREGAMMA() { (constant('PNG_IGNOREGAMMA'))[1] }
167              
168 1     1 0 11 sub PNG_Z_BEST_SPEED() { (constant('PNG_Z_BEST_SPEED'))[1] }
169              
170 1     1 0 10 sub PNG_Z_DEFAULT_COMPRESSION() { (constant('PNG_Z_DEFAULT_COMPRESSION'))[1] }
171              
172 1     1 0 12 sub PNG_Z_BEST_COMPRESSION() { (constant('PNG_Z_BEST_COMPRESSION'))[1] }
173              
174 1     1 0 12 sub PNG_Z_NO_COMPRESSION() { (constant('PNG_Z_NO_COMPRESSION'))[1] }
175              
176 1     1 0 11 sub PNG_INTERLACED() { (constant('PNG_INTERLACED'))[1] }
177              
178 1     1 0 33 sub PNM_SAVE_ASCII() { (constant('PNM_SAVE_ASCII'))[1] }
179              
180 1     1 0 6 sub PSD_CMYK() { (constant('PSD_CMYK'))[1] }
181              
182 1     1 0 7 sub PSD_LAB() { (constant('PSD_LAB'))[1] }
183              
184 1     1 0 6 sub RAW_PREVIEW() { (constant('RAW_PREVIEW'))[1] }
185              
186 1     1 0 6 sub RAW_DISPLAY() { (constant('RAW_DISPLAY'))[1] }
187              
188 1     1 0 7 sub RAW_HALFSIZE() { (constant('RAW_HALFSIZE'))[1] }
189              
190 1     1 0 29 sub TARGA_LOAD_RGB888() { (constant('TARGA_LOAD_RGB888'))[1] }
191              
192 1     1 0 10 sub TARGA_SAVE_RLE() { (constant('TARGA_SAVE_RLE'))[1] }
193              
194 1     1 0 9 sub TIFF_CMYK() { (constant('TIFF_CMYK'))[1] }
195              
196 1     1 0 10 sub TIFF_PACKBITS() { (constant('TIFF_PACKBITS'))[1] }
197              
198 1     1 0 10 sub TIFF_DEFLATE() { (constant('TIFF_DEFLATE'))[1] }
199              
200 1     1 0 9 sub TIFF_ADOBE_DEFLATE() { (constant('TIFF_ADOBE_DEFLATE'))[1] }
201              
202 1     1 0 11 sub TIFF_NONE() { (constant('TIFF_NONE'))[1] }
203              
204 1     1 0 10 sub TIFF_CCITTFAX3() { (constant('TIFF_CCITTFAX3'))[1] }
205              
206 1     1 0 11 sub TIFF_CCITTFAX4() { (constant('TIFF_CCITTFAX4'))[1] }
207              
208 1     1 0 10 sub TIFF_LZW() { (constant('TIFF_LZW'))[1] }
209              
210 1     1 0 9 sub TIFF_JPEG() { (constant('TIFF_JPEG'))[1] }
211              
212 1     1 0 10 sub TIFF_LOGLUV() { (constant('TIFF_LOGLUV'))[1] }
213              
214 1     1 0 9 sub WEBP_LOSSLESS() { (constant('WEBP_LOSSLESS'))[1] }
215              
216 1     1 0 10 sub JXR_LOSSLESS() { (constant('JXR_LOSSLESS'))[1] }
217              
218 1     1 0 9 sub JXR_PROGRESSIVE() { (constant('JXR_PROGRESSIVE'))[1] }
219              
220             =head1 NAME
221              
222             PDL::IO::Image - Load/save bitmap from/to PDL (via FreeImage library)
223              
224             =head1 SYNOPSIS
225              
226             Functional interface:
227              
228             use 5.010;
229             use PDL;
230             use PDL::IO::Image;
231              
232             my $pdl1 = rimage('picture.tiff');
233             say $pdl1->info; # PDL: Byte D [400,300] ... width 400, height 300
234             # do some hacking with $piddle
235             wimage($pdl1, 'output.tiff');
236             # you can also use wimage as PDL's method
237             $pdl1->wimage('another-output.png');
238              
239             my ($pixels, $palette) = rimage('picture-256colors.gif', { palette=>1 });
240             say $pixels->info; # PDL: Byte D [400,300] ... width 400, height 300
241             say $palette->info; # PDL: Byte D [3,256]
242             # do some hacking with $pixels and $palette
243             wimage($pixels, 'output.gif', { palette=>$palette });
244              
245             # load specific image (page) from multi-page file
246             my $pdl2 = rimage('picture.tiff', { page=>0 });
247              
248             # load specific image + flit vertically before converting to piddle
249             my $pdl3 = rimage('picture.tiff', { flip=>'V' });
250              
251             # random pixels + ramdom colors (RGBA - 35 bits per pixel)
252             (random(400, 300, 4) * 256)->byte->wimage("random.png");
253              
254             my $pix1 = (sin(0.25 * rvals(101, 101)) * 128 + 127)->byte;
255             say $pix1->info; # PDL: Byte D [101,101]
256             my $pal1 = yvals(3, 256)->byte;
257             $pal1->slice("(2),:") .= 0; # set blue part of palette to zero
258             say $pal1->info; # PDL: Byte D [3,256]
259             $pix1->wimage("wave1_grayscale.gif"); # default is grayscale palette
260             $pix1->wimage("wave2_yellow.gif", { palette=>$pal1 });
261              
262             # rotate /rescale before saving
263             my $pix2 = (sin(0.25 * xvals(101, 101)) * 128 + 127)->byte;
264             $pix2->wimage("wave3_grayscale.gif", { rescale=>[16,16] }); # rescale to 16x16 pixels
265             $pix2->wimage("wave4_grayscale.gif", { rescale_pct=>50 }); # rescale to 50%
266             $pix2->wimage("wave5_grayscale.gif", { rotate=>33.33 });
267              
268             Object oriented (OO) interface:
269              
270             use 5.010;
271             use PDL;
272             use PDL::IO::Image;
273              
274             # create PDL::IO::Image object from file
275             my $pimage1 = PDL::IO::Image->new_from_file('picture.gif');
276             say 'width = ' . $pimage1->get_width;
277             say 'height = ' . $pimage1->get_height;
278             say 'image_type = ' . $pimage1->get_image_type;
279             say 'color_type = ' . $pimage1->get_color_type;
280             say 'colors_used = ' . $pimage1->get_colors_used;
281             say 'bpp = ' . $pimage1->get_bpp;
282             # you can do some operations with PDL::IO::Image object
283             $pimage1->flip_vertical;
284             # export pixels from PDL::IO::Image object content into a piddle
285             my $pix_pdl = $pimage1->pixels_to_pdl();
286             # export palette from PDL::IO::Image object content into a piddle
287             my $pal_pdl = $pimage1->palette_to_pdl();
288              
289             # let us have a piddle with pixel data
290             my $wave_pixels = (sin(0.008 * xvals(2001, 2001)) * 128 + 127)->byte;
291             # create PDL::IO::Image object from PDL piddle
292             my $pimage2 = PDL::IO::Image->new_from_pdl($wave_pixels);
293             # do some transformation with PDL::IO::Image object
294             $pimage2->rotate(45);
295             $pimage2->rescale(200, 200);
296             # export PDL::IO::Image object content into a image file
297             $pimage2->save("output.jpg");
298              
299             =head1 DESCRIPTION
300              
301             PDL::IO::Image implements I/O for a number of popular image formats. It is based on
302             L<"FreeImage library"|http://freeimage.sourceforge.net/> however there is no need to install
303             FreeImage library on your system because PDL::IO::Image uses L module which
304             handles building FreeImage library from sources (works on Windows, Cygwin, Mac OS X, Linux and other UNIXes).
305              
306             Check also an excellent FreeImage documentation at L
307              
308             =head2 Supported file formats
309              
310             This module supports loading (L or L) and saving (L or L)
311             of the following formats (note that not all formats support writing - see C column).
312              
313             BMP R/W Windows or OS/2 Bitmap [extensions: bmp]
314             ICO R/W Windows Icon [extensions: ico]
315             JPEG R/W JPEG - JFIF Compliant [extensions: jpg,jif,jpeg,jpe]
316             JNG R/W JPEG Network Graphics [extensions: jng]
317             KOALA R/- C64 Koala Graphics [extensions: koa]
318             IFF R/- IFF Interleaved Bitmap [extensions: iff,lbm]
319             MNG R/- Multiple-image Network Graphics [extensions: mng]
320             PBM R/W Portable Bitmap (ASCII) [extensions: pbm]
321             PBMRAW R/W Portable Bitmap (RAW) [extensions: pbm]
322             PCD R/- Kodak PhotoCD [extensions: pcd]
323             PCX R/- Zsoft Paintbrush [extensions: pcx]
324             PGM R/W Portable Greymap (ASCII) [extensions: pgm]
325             PGMRAW R/W Portable Greymap (RAW) [extensions: pgm]
326             PNG R/W Portable Network Graphics [extensions: png]
327             PPM R/W Portable Pixelmap (ASCII) [extensions: ppm]
328             PPMRAW R/W Portable Pixelmap (RAW) [extensions: ppm]
329             RAS R/- Sun Raster Image [extensions: ras]
330             TARGA R/W Truevision Targa [extensions: tga,targa]
331             TIFF R/W Tagged Image File Format [extensions: tif,tiff]
332             WBMP R/W Wireless Bitmap [extensions: wap,wbmp,wbm]
333             PSD R/- Adobe Photoshop [extensions: psd]
334             CUT R/- Dr. Halo [extensions: cut]
335             XBM R/- X11 Bitmap Format [extensions: xbm]
336             XPM R/W X11 Pixmap Format [extensions: xpm]
337             DDS R/- DirectX Surface [extensions: dds]
338             GIF R/W Graphics Interchange Format [extensions: gif]
339             HDR R/W High Dynamic Range Image [extensions: hdr]
340             G3 R/- Raw fax format CCITT G.3 [extensions: g3]
341             SGI R/- SGI Image Format [extensions: sgi,rgb,rgba,bw]
342             EXR R/W ILM OpenEXR [extensions: exr]
343             J2K R/W JPEG-2000 codestream [extensions: j2k,j2c]
344             JP2 R/W JPEG-2000 File Format [extensions: jp2]
345             PFM R/W Portable floatmap [extensions: pfm]
346             PICT R/- Macintosh PICT [extensions: pct,pict,pic]
347             RAW R/- RAW camera image [extensions: 3fr,arw,bay,bmq,cap,cine,
348             cr2,crw,cs1,dc2, dcr,drf,dsc,dng,erf,fff,ia,iiq,k25,
349             kc2,kdc,mdc,mef,mos,mrw,nef,nrw,orf,pef, ptx,pxn,qtk,
350             raf,raw,rdc,rw2,rwl,rwz,sr2,srf,srw,sti]
351             WEBP R/W Google WebP image format [extensions: webp]
352             JPEG-XR R/W JPEG XR image format [extensions: jxr,wdp,hdp]
353              
354             B the strings in the first column (e.g. C<'BMP'>, C<'JPEG'>, C<'PNG'>) are used as a format identifier in
355             L, L, L, L (+some other methods).
356              
357             The supported format may differ depending on FreeImage library version. You can list what exactly you FreeImage library
358             can handle like this:
359              
360             for (PDL::IO::Image->format_list) {
361             my $r = PDL::IO::Image->format_can_read($_) ? 'R' : '-';
362             my $w = PDL::IO::Image->format_can_write($_) ? 'W' : '-';
363             my $e = PDL::IO::Image->format_extension_list($_);
364             my $d = PDL::IO::Image->format_description($_);
365             printf("% 7s %s/%s %s [extensions: %s]\n", $_, $r, $w, $d, $e);
366             }
367              
368             =head2 Supported image types
369              
370             This module can handle the following image types.
371              
372             BITMAP Standard image: 1-, 4-, 8-, 16-, 24-, 32-bit
373             UINT16 Array of unsigned short: unsigned 16-bit
374             INT16 Array of short: signed 16-bit
375             UINT32 Array of unsigned long: unsigned 32-bit
376             INT32 Array of long: signed 32-bit
377             FLOAT Array of float: 32-bit IEEE floating point
378             DOUBLE Array of double: 64-bit IEEE floating point
379             RGB16 48-bit RGB image: 3 x 16-bit
380             RGBA16 64-bit RGBA image: 4 x 16-bit
381             RGBF 96-bit RGB float image: 3 x 32-bit IEEE floating point
382             RGBAF 128-bit RGBA float image: 4 x 32-bit IEEE floating point
383              
384             Currently B:
385              
386             COMPLEX Array of FICOMPLEX: 2 x 64-bit IEEE floating point
387              
388             Image type is important especially when you want to load image data from PDL piddle into a PDL::IO::Image object
389             (and later save to a file). Based on piddle size and piddle type the image type is detected (in L
390             and L).
391              
392             W .. image width
393             H .. image height
394             PDL Byte [W,H] BITMAP 1-/4-/8-bits per pixel
395             PDL Byte [W,H,3] BITMAP 24-bits per pixel (RGB)
396             PDL Byte [W,H,4] BITMAP 32-bits per pixel (RGBA)
397             PDL Ushort [W,H] UINT16
398             PDL Short [W,H] INT16
399             PDL LongLong [W,H] UINT32 (unfortunately there is no PDL Ulong type)
400             PDL Long [W,H] INT32
401             PDL Float [W,H] FLOAT
402             PDL Double [W,H] DOUBLE
403             PDL Ushort [W,H,3] RGB16
404             PDL Ushort [W,H,4] RGBA16
405             PDL Float [W,H,3] RGBf
406             PDL Float [W,H,4] RGBAF
407              
408             B the strings with type name (e.g. C<'BITMAP'>, C<'UINT16'>, C<'RGBAF'>) are used as a image type
409             identifier in method L and a return value of method L.
410              
411             Not all file formats support all image formats above (especially those non-BITMAP image types). If you are in doubts use
412             C format for storing unusual image types.
413              
414             =head1 FUNCTIONS
415              
416             The functional interface comprises of two functions L and L - both are exported by default.
417              
418             =head2 rimage
419              
420             Loads image into a PDL piddle (or into two piddles in case of palette-based images).
421              
422             my $pixels_pdl = rimage($filename);
423             #or
424             my $pixels_pdl = rimage($filename, \%options);
425             #or
426             my ($pixels_pdl, $palette_pdl) = rimage($filename, { palette=>1 });
427              
428             Internally it works in these steps:
429              
430             =over
431              
432             =item * Create PDL::IO::Image object from the input file.
433              
434             =item * Do optional transformations (based on C<%options>) with PDL::IO::Image object.
435              
436             =item * Export PDL::IO::Image object into a piddle(s) via L and L.
437              
438             =item * B L returns piddle(s) not a PDL::IO::Image object
439              
440             =back
441              
442             Items supported in B hash:
443              
444             =over
445              
446             =item * format
447              
448             String identifying file format (e.g. C<'JPEG'> - for valid values see L), default
449             is C<'AUTO'> which means that format is auto detected.
450              
451             =item * format_flag
452              
453             Optional flag related to loading given file format - see L method for more info.
454              
455             =item * page
456              
457             Index (0-based) of a specific page to load from multi-page images (TIFF, ICO or animated GIF).
458              
459             =item * flip
460              
461             Values C<'H'>, C<'V'> or C<'HV'> specifying horizontal, vertical or horizontal+vertical flipping.
462             Default: do not flip.
463              
464             =item * rotate
465              
466             Optional floating point value with rotation angle (in degrees) - see L method for more info.
467             Default: do not rotate.
468              
469             =item * convert_image_type
470              
471             String identifying image type (e.g. C<'BITMAP'> - for valid values see L).
472             Default: no conversion.
473              
474             =item * region
475              
476             An arrayref with a region specification like C<[$x1,$x2,$y1,$y2]> - see L method for more info.
477             Default: create the output piddle from the whole image.
478              
479             =item * palette
480              
481             Values C<0> (default) or C<1> - whether to load (or not) color lookup table (aka LUT).
482              
483             =back
484              
485             =head2 wimage
486              
487             Write PDL piddle(s) into a image file.
488              
489             $pixels_pdl->wimage($filename);
490             #or
491             $pixels_pdl->wimage($filename, \%options);
492              
493             wimage($pixels_pdl, $filename);
494             #or
495             wimage($pixels_pdl, $filename, \%options);
496              
497             Internally it works in these steps:
498              
499             =over
500              
501             =item * Create PDL::IO::Image object from the C<$pixels_piddle> (+ C<$palette_piddle> passed as C option).
502              
503             =item * Dimensions and type of C<$pixels_piddle> must comply with L.
504              
505             =item * Do optional transformations (based on C<%options>) with PDL::IO::Image object.
506              
507             =item * Export PDL::IO::Image object into a image file via L method.
508              
509             =back
510              
511             Items supported in B hash:
512              
513             =over
514              
515             =item * format
516              
517             String identifying file format (e.g. C<'JPEG'> - for valid values see L), default
518             is C<'AUTO'> which means that format is auto detected from extension of C<$filename>.
519              
520             =item * format_flag
521              
522             Optional flag related to saving given file format - see L method for more info.
523              
524             =item * palette
525              
526             Optional PDL piddle with color palette (has to be C where 0 < N <= 256) containing RGB triplets.
527              
528             =item * flip
529              
530             Values C<'H'>, C<'V'> or C<'HV'> specifying horizontal, vertical or horizontal+vertical flipping.
531             Default: do not flip.
532              
533             =item * rotate
534              
535             Optional floating point value with rotation angle (in degrees) - see L method for more info.
536             Default: do not rotate.
537              
538             =item * rescale
539              
540             Optional arrayref with rescale specification (in pixels) e.g. C<[$new_w, $new_h]> - see L method for more info.
541             Default: do not rescale.
542              
543             =item * rescale_pct
544              
545             Optional floating point value with rescale ratio in percent - see L method for more info.
546             Default: do not rescale.
547              
548             =item * convert_image_type
549              
550             String identifying image type (e.g. C<'BITMAP'> - for valid values see L).
551             Default: no conversion.
552              
553             =back
554              
555             =head1 METHODS
556              
557             =head2 new_from_file
558              
559             Create PDL::IO::Image object from image file.
560              
561             my $pimage = IO::PDL::Image->new_from_file($filename);
562             #or
563             my $pimage = IO::PDL::Image->new_from_file($filename, $format);
564             #or
565             my $pimage = IO::PDL::Image->new_from_file($filename, $format, $format_flag);
566             #or
567             my $pimage = IO::PDL::Image->new_from_file($filename, $format, $format_flag, $page);
568              
569             #if you have image file content in a scalar variable you can use
570             my $pimage = IO::PDL::Image->new_from_file(\$variable_with_image_data);
571              
572             C<$filename> - input image file name or a reference to scalar variable with imiga data.
573              
574             C<$format> - string identifying file format (e.g. C<'JPEG'> - for valid values see L),
575             default is C<'AUTO'> which means that format is auto detected (based on file header with fall-back to detection based
576             on file extension).
577              
578             C<$format_flag> - optional flag related to loading given file format, default if C<0> (no extra flags). The flag can be
579             created by OR-ing some of available constants:
580              
581             PDL::IO::Image::GIF_LOAD256 Load the image as a 256 color image with unused
582             palette entries, if it's 16 or 2 color
583             PDL::IO::Image::GIF_PLAYBACK 'Play' the GIF to generate each frame (as 32bpp)
584             instead of returning raw frame data when loading
585             PDL::IO::Image::ICO_MAKEALPHA Convert to 32-bit and create an alpha channel from
586             the ANDmask when loading
587             PDL::IO::Image::JPEG_FAST Load the file as fast as possible, sacrificing some quality
588             PDL::IO::Image::JPEG_ACCURATE Load the file with the best quality, sacrificing some speed
589             PDL::IO::Image::JPEG_CMYK This flag will load CMYK bitmaps as 32-bit separated CMYK
590             PDL::IO::Image::JPEG_GREYSCALE Load and convert to a 8-bit greyscale image (faster than
591             loading as 24-bit and converting to 8-bit)
592             PDL::IO::Image::JPEG_EXIFROTATE Load and rotate according to Exif 'Orientation' tag if available
593             PDL::IO::Image::PCD_BASE This flag will load the one sized 768 x 512
594             PDL::IO::Image::PCD_BASEDIV4 This flag will load the bitmap sized 384 x 256
595             PDL::IO::Image::PCD_BASEDIV16 This flag will load the bitmap sized 192 x 128
596             PDL::IO::Image::PNG_IGNOREGAMMA Avoid gamma correction on loading
597             PDL::IO::Image::PSD_CMYK Reads tags for separated CMYK (default is conversion to RGB)
598             PDL::IO::Image::PSD_LAB Reads tags for CIELab (default is conversion to RGB)
599             PDL::IO::Image::RAW_PREVIEW Try to load the embedded JPEG preview with included Exif
600             data or default to RGB 24-bit
601             PDL::IO::Image::RAW_DISPLAY Load the file as RGB 24-bit
602             PDL::IO::Image::RAW_HALFSIZE Output a half-size color image
603             PDL::IO::Image::TARGA_LOAD_RGB888 If set the loader converts RGB555 and ARGB8888 -> RGB888
604             PDL::IO::Image::TIFF_CMYK Load CMYK bitmaps as separated CMYK (default is conversion to RGB)
605              
606             =head2 new_from_pdl
607              
608             Create PDL::IO::Image object from PDL piddle with pixel (+ optional palette) data.
609              
610             my $pimage = IO::PDL::Image->new_from_pdl($pixels_pdl);
611             #or
612             my $pimage = IO::PDL::Image->new_from_pdl($pixels_pdl, $palette_pdl);
613              
614             C<$pixels_pdl> - PDL piddle containing pixel data, dimensions and type must comply with L.
615              
616             C<$palette_pdl> - Optional PDL piddle with color palette (has to be C where 0 < N <= 256) containing RGB triplets.
617              
618             =head2 clone
619              
620             Create a copy (clone) of PDL::IO::Image object.
621              
622             my $pimage_copy = $pimage->clone();
623              
624             =head2 pixels_to_pdl
625              
626             Export pixel data from PDL::IO::Image object into a piddle.
627              
628             my $pixels_pdl = $pimage->pixels_to_pdl;
629             #or
630             my $pixels_pdl = $pimage->pixels_to_pdl($x1, $x2, $y1, $y2);
631              
632             C<$x1, $x2, $y1, $y2> - Optional specification of image sub-region to be exported. All values are 0-based, negative
633             values can be used to specify boundary "from the end".
634              
635             =head2 palette_to_pdl
636              
637             Export palette (aka LUT - color lookup table) data from PDL::IO::Image object into a piddle.
638              
639             my $palette_pdl = $pimage->palette_to_pdl;
640              
641             The output piddle is ususally C. Returns C if image represented by C<$pimage> does not use
642             palette.
643              
644             =head2 save
645              
646             Export PDL::IO::Image object into a image file.
647              
648             $pimage->save($filename, $format, $flags);
649             #or
650             $pimage->save($filename, $format);
651             #or
652             $pimage->save($filename);
653              
654             #you can save the image data to a variable like this
655             my $output_image;
656             $pimage->save(\$output_image, $format);
657             #NOTE: $format is mandatory in this case
658              
659             Returns C<$pimage> (self).
660              
661             C<$filename> - output image file name or a reference to perl scalar variable.
662              
663             C<$format> - string identifying file format (e.g. C<'JPEG'> - for valid values see L),
664             default is C<'AUTO'> which means that format is auto detected from extension of C<$filename>.
665              
666             C<$format_flag> - optional flag related to saving given file format, default if C<0> (no extra flags). The flag can be
667             created by OR-ing some of available constants:
668              
669             PDL::IO::Image::BMP_SAVE_RLE Compress the bitmap using RLE when saving
670             PDL::IO::Image::EXR_FLOAT Save data as float instead of as half (not recommended)
671             PDL::IO::Image::EXR_NONE Save with no compression
672             PDL::IO::Image::EXR_ZIP Save with zlib compression, in blocks of 16 scan lines
673             PDL::IO::Image::EXR_PIZ Save with piz-based wavelet compression
674             PDL::IO::Image::EXR_PXR24 Save with lossy 24-bit float compression
675             PDL::IO::Image::EXR_B44 Save with lossy 44% float compression
676             PDL::IO::Image::EXR_LC Save with one luminance and two chroma channels, rather than RGB (lossy)
677             for J2K format: integer X in [1..512] Save with a X:1 rate (default = 16)
678             for JP2 format: integer X in [1..512] Save with a X:1 rate (default = 16)
679             PDL::IO::Image::JPEG_QUALITYSUPERB Saves with superb quality (100:1)
680             PDL::IO::Image::JPEG_QUALITYGOOD Saves with good quality (75:1 - default)
681             PDL::IO::Image::JPEG_QUALITYNORMAL Saves with normal quality (50:1)
682             PDL::IO::Image::JPEG_QUALITYAVERAGE Saves with average quality (25:1)
683             PDL::IO::Image::JPEG_QUALITYBAD Saves with bad quality (10:1)
684             for JPEG format: integer X in [0..100] Save with quality X:1
685             PDL::IO::Image::JPEG_PROGRESSIVE Saves as a progressive JPEG file
686             PDL::IO::Image::JPEG_SUBSAMPLING_411 Save with high 4x1 chroma subsampling (4:1:1)
687             PDL::IO::Image::JPEG_SUBSAMPLING_420 Save with medium 2x2 chroma subsampling (4:2:0) - default value
688             PDL::IO::Image::JPEG_SUBSAMPLING_422 Save with low 2x1 chroma subsampling (4:2:2)
689             PDL::IO::Image::JPEG_SUBSAMPLING_444 Save with no chroma subsampling (4:4:4)
690             PDL::IO::Image::JPEG_OPTIMIZE On saving, compute optimal Huffman coding tables
691             PDL::IO::Image::JPEG_BASELINE Save basic JPEG, without metadata or any markers
692             for JXR format: integer X in [1..100) Save with quality X:1 (default = 80), using X=100 means lossless
693             PDL::IO::Image::JXR_LOSSLESS Save lossless (quality = 100)
694             PDL::IO::Image::JXR_PROGRESSIVE Saves as a progressive JPEG-XR file
695             PDL::IO::Image::PNG_Z_BEST_SPEED Save using ZLib level 1 compression (default value is 6)
696             PDL::IO::Image::PNG_Z_DEFAULT_COMPRESSION Save using ZLib level 6 compression (default)
697             PDL::IO::Image::PNG_Z_BEST_COMPRESSION Save using ZLib level 9 compression (default value is 6)
698             PDL::IO::Image::PNG_Z_NO_COMPRESSION Save without ZLib compression
699             PDL::IO::Image::PNG_INTERLACED Save using Adam7 interlacing
700             PDL::IO::Image::PNM_SAVE_RAW Saves the bitmap as a binary file
701             PDL::IO::Image::PNM_SAVE_ASCII Saves the bitmap as an ASCII file
702             PDL::IO::Image::TIFF_CMYK Stores tags for separated CMYK
703             PDL::IO::Image::TIFF_PACKBITS Save using PACKBITS compression
704             PDL::IO::Image::TIFF_DEFLATE Save using DEFLATE compression (also known as ZLIB compression)
705             PDL::IO::Image::TIFF_ADOBE_DEFLATE Save using ADOBE DEFLATE compression
706             PDL::IO::Image::TIFF_NONE Save without any compression
707             PDL::IO::Image::TIFF_CCITTFAX3 Save using CCITT Group 3 fax encoding
708             PDL::IO::Image::TIFF_CCITTFAX4 Save using CCITT Group 4 fax encoding
709             PDL::IO::Image::TIFF_LZW Save using LZW compression
710             PDL::IO::Image::TIFF_JPEG Save using JPEG compression (8-bit greyscale and 24-bit only)
711             PDL::IO::Image::TIFF_LOGLUV Save using LogLuv compression (only available with RGBF images
712             PDL::IO::Image::TARGA_SAVE_RLE Save with RLE compression
713              
714             =head2 dump_bitmap
715              
716             Extract raw bitmap data (+ do necessary image type and/or bpp conversions).
717              
718             my ($width, $height, $bpp, $pixels, $palette) = $pimage->dump_bitmap;
719             #or
720             my ($width, $height, $bpp, $pixels, $palette) = $pimage->dump_bitmap($required_bpp);
721              
722             C<$pixels> and C<$palette> are raw data buffers containg sequence of RGB (RGBA) byte values.
723              
724             C<$required_bpp> can be 8, 24 or 32 - before dumping the image is converted to C image type + colors depth is
725             converted to given value. Default is autodetect the lowest sufficient bpp (from 8, 24, 32).
726              
727             =head2 get_image_type
728              
729             Returns the data type of a bitmap (e.g. C<'BITMAP'>, C<'UINT16'>) - see L.
730              
731             my $imtype = $pimage->get_image_type;
732              
733             =head2 get_colors_used
734              
735             Returns the palette size for palletised bitmaps (usually 256), and 0 for high-colour bitmaps.
736              
737             my $colors = $pimage->get_colors_used;
738              
739             =head2 get_bpp
740              
741             Returns the size of one pixel in the bitmap in bits (aka bits per pixel).
742              
743             my $bpp = $pimage->get_bpp;
744              
745             =head2 get_width
746              
747             Returns the width of the bitmap in pixels.
748              
749             my $w = $pimage->get_width;
750              
751             =head2 get_height
752              
753             Returns the height of the bitmap in pixels.
754              
755             my $h = $pimage->get_height;
756              
757             =head2 get_dots_per_meter_x
758              
759             Returns the horizontal resolution, in pixels-per-meter.
760              
761             my $dpmx = $pimage->get_dots_per_meter_x;
762              
763             =head2 set_dots_per_meter_x
764              
765             Set the horizontal resolution, in pixels-per-meter.
766              
767             $pimage->set_dots_per_meter_x($res);
768              
769             Returns C<$pimage> (self).
770              
771             =head2 get_dots_per_meter_y
772              
773             Returns the vertical resolution, in pixels-per-meter.
774              
775             my $dpmy = $pimage->get_dots_per_meter_y;
776              
777             =head2 set_dots_per_meter_y
778              
779             Set the vertical resolution, in pixels-per-meter.
780              
781             $pimage->set_dots_per_meter_y($res);
782              
783             Returns C<$pimage> (self).
784              
785             =head2 get_color_type
786              
787             Returns color type.
788              
789             my $coltype = $pimage->get_color_type;
790              
791             The return value is a string:
792              
793             'MINISBLACK' Monochrome bitmap (1-bit): first palette entry is black.
794             Palletised bitmap (4 or 8-bit) and single channel non standard bitmap: greyscale palette
795             'MINISWHITE' Monochrome bitmap (1-bit): first palette entry is white.
796             Palletised bitmap (4 or 8-bit): inverted greyscale palette
797             'PALETTE' Palettized bitmap (1, 4 or 8 bit)
798             'RGB' High-color bitmap (16, 24 or 32 bit), RGB16 or RGBF
799             'RGBALPHA' High-color bitmap with an alpha channel (32 bit bitmap, RGBA16 or RGBAF)
800             'CMYK' CMYK bitmap (32 bit only)
801              
802             =head2 is_transparent
803              
804             Returns C<1> when the transparency table is enabled (1-, 4- or 8-bit images) or when the
805             input dib contains alpha values (32-bit images, RGBA16 or RGBAF images). Returns C<0> otherwise.
806              
807             my $bool = $pimage->is_transparent;
808              
809             =head2 get_transparent_index
810              
811             Returns the palette entry used as transparent color for the image specified. Works for
812             palletised images only and returns -1 for high color images or if the image has no color set to
813             be transparent.
814              
815             my $idx = $pimage->get_transparent_index;
816              
817             =head2 set_transparent_index
818              
819             Sets the index of the palette entry to be used as transparent color for the image specified.
820             Does nothing on high color images.
821              
822             $pimage->set_transparent_index($index);
823              
824             Returns C<$pimage> (self).
825              
826             =head2 flip_horizontal
827              
828             Flip the image horizontally along the vertical axis.
829              
830             $pimage->flip_horizontal;
831              
832             Returns C<$pimage> (self).
833              
834             =head2 flip_vertical
835              
836             Flip the image vertically along the horizontal axis.
837              
838             $pimage->flip_vertical;
839              
840             Returns C<$pimage> (self).
841              
842             =head2 rotate
843              
844             Rotates image, the angle of counter clockwise rotation is specified by the C<$angle> parameter in degrees.
845              
846             $pimage->rotate($angle);
847             #or
848             $pimage->rotate($angle, $bg_r, $bg_g, $bg_b, $bg_a); # RGBA(F|16) images
849             $pimage->rotate($angle, $bg_r, $bg_g, $bg_b); # RGB(F|16) images
850             $pimage->rotate($angle, $bg); # palette-based images
851              
852             You can specify optional backgroung color via C<$bg_r>, C<$bg_g>, C<$bg_b>, C<$bg_a> or C<$bg>.
853              
854             Returns C<$pimage> (self).
855              
856             =head2 rescale
857              
858             Performs resampling (scaling/zooming) of a greyscale or RGB(A) image to the desired destination width and height.
859              
860             $pimage->rescale($dst_width, $dst_height, $filter);
861             #or
862             $pimage->rescale($dst_width, 0); # destination height is computed
863             #or
864             $pimage->rescale(0, $dst_height); # destination width is computed
865              
866             Returns C<$pimage> (self).
867              
868             C<$filter> - resampling filter identifier:
869              
870             0 .. Box, pulse, Fourier window, 1st order (constant) b-spline
871             1 .. Mitchell & Netravali's two-param cubic filter
872             2 .. Bilinear filter
873             3 .. 4th order (cubic) b-spline
874             4 .. Catmull-Rom spline, Overhauser spline
875             5 .. Lanczos3 filter
876              
877             =head2 rescale_pct
878              
879             Performs resampling by given percentage ratio.
880              
881             $pimage->rescale($dst_width_pct, $dst_height_pct, $filter);
882             #or
883             $pimage->rescale($dst_pct);
884              
885             Returns C<$pimage> (self).
886              
887             C<$filter> - see L
888              
889             =head2 convert_image_type
890              
891             Converts an image to destination C<$image_type>.
892              
893             $pimage->convert_image_type($image_type, $scale_linear);
894             #or
895             $pimage->convert_image_type($image_type);
896              
897             Returns C<$pimage> (self).
898              
899             C<$image_type> - string identifying image type (e.g. C<'BITMAP'>, C<'UINT16'> - for valid values see L).
900              
901             =head2 adjust_colors
902              
903             Adjusts an image's brightness, contrast and gamma as well as it may optionally invert the image within a single operation.
904              
905             $pimage->adjust_colors($brightness, $contrast, $gamma, $invert);
906              
907             Returns C<$pimage> (self).
908              
909             C<$brightness> - real value from range C<[-100..100]>, value C<0> means no change, less than 0 will make the
910             image darker and greater than 0 will make the image brighter
911              
912             C<$contrast> - real value from range C<[-100..100]>, value C<0> means no change, less than 0 will decrease the
913             contrast and greater than 0 will increase the contrast of the image
914              
915             C<$gamma> - real value greater than 0, value of 1.0 leaves the image alone, less than one
916             darkens it, and greater than one lightens it
917              
918             C<$invert> - C<0> or C<1> invert (or not) all pixels
919              
920             =head2 color_to_4bpp
921              
922             Converts a bitmap to 4 bits. If the bitmap was a high-color bitmap (16, 24 or 32-bit) or if it was
923             a monochrome or greyscale bitmap (1 or 8-bit), the end result will be a greyscale bitmap,
924             otherwise (1-bit palletised bitmaps) it will be a palletised bitmap.
925              
926             $pimage->color_to_4bpp();
927              
928             Returns C<$pimage> (self).
929              
930             =head2 color_to_8bpp
931              
932             Converts a bitmap to 8 bits. If the bitmap was a high-color bitmap (16, 24 or 32-bit) or if it was
933             a monochrome or greyscale bitmap (1 or 4-bit), the end result will be a greyscale bitmap,
934             otherwise (1 or 4-bit palletised bitmaps) it will be a palletised bitmap.
935              
936             $pimage->color_to_8bpp();
937              
938             Returns C<$pimage> (self).
939              
940             =head2 color_to_8bpp_grey
941              
942             Converts a bitmap to a 8-bit greyscale image with a linear ramp. Contrary to the
943             FreeImage_ConvertTo8Bits function, 1-, 4- and 8-bit palletised images are correctly
944             converted, as well as images with a FIC_MINISWHITE color type.
945              
946             $pimage->color_to_8bpp_grey();
947              
948             Returns C<$pimage> (self).
949              
950             =head2 color_to_16bpp_555
951              
952             Converts a bitmap to 16 bits, where each pixel has a color pattern of 5 bits red, 5 bits green
953             and 5 bits blue. One bit in each pixel is unused.
954              
955             $pimage->color_to_16bpp_555();
956              
957             Returns C<$pimage> (self).
958              
959             =head2 color_to_16bpp_565
960              
961             Converts a bitmap to 16 bits, where each pixel has a color pattern of 5 bits red, 6 bits green
962             and 5 bits blue.
963              
964             $pimage->color_to_16bpp_565();
965              
966             Returns C<$pimage> (self).
967              
968             =head2 color_to_24bpp
969              
970             Converts a bitmap to 24 bits per pixel.
971              
972             $pimage->color_to_24bpp();
973              
974             Returns C<$pimage> (self).
975              
976             =head2 color_to_32bpp
977              
978             Converts a bitmap to 32 bits per pixel.
979              
980             $pimage->color_to_32bpp();
981              
982             Returns C<$pimage> (self).
983              
984             =head2 color_dither
985              
986             Converts a bitmap to 1-bit monochrome bitmap using a dithering algorithm.
987              
988             $pimage->color_dither($algorithm);
989             #or
990             $pimage->color_dither();
991              
992             Returns C<$pimage> (self).
993              
994             Possible C<$algorithm> values:
995              
996             0 .. Floyd & Steinberg error diffusion (DEFAULT)
997             1 .. Bayer ordered dispersed dot dithering (order 2 dithering matrix)
998             2 .. Bayer ordered dispersed dot dithering (order 3 dithering matrix)
999             3 .. Ordered clustered dot dithering (order 3 - 6x6 matrix)
1000             4 .. Ordered clustered dot dithering (order 4 - 8x8 matrix)
1001             5 .. Ordered clustered dot dithering (order 8 - 16x16 matrix)
1002             6 .. Bayer ordered dispersed dot dithering (order 4 dithering matrix)
1003              
1004             =head2 color_threshhold
1005              
1006             Converts a bitmap to 1-bit monochrome bitmap using a C<$threshold> between [0..255] (default is 127).
1007              
1008             $pimage->color_threshhold($threshold);
1009             #or
1010             $pimage->color_threshhold();
1011              
1012             Returns C<$pimage> (self).
1013              
1014             =head2 color_quantize
1015              
1016             $pimage->color_quantize($quantize);
1017             #or
1018             $pimage->color_quantize();
1019              
1020             Returns C<$pimage> (self).
1021              
1022             Possible C<$quantize> values:
1023              
1024             0 .. Xiaolin Wu color quantization algorithm
1025             1 .. NeuQuant neural-net quantization algorithm by Anthony Dekker
1026              
1027             =head2 tone_mapping
1028              
1029             Converts a High Dynamic Range image (48-bit RGB or 96-bit RGBF) to a 24-bit RGB image, suitable for display.
1030              
1031             $pimage->tone_mapping($tone_mapping_operator, $param1, $param2);
1032              
1033             Returns C<$pimage> (self).
1034              
1035             C<$tone_mapping_operator> - tone mapping operator identifier:
1036              
1037             0 .. Adaptive logarithmic mapping (F. Drago, 2003)
1038             1 .. Dynamic range reduction inspired by photoreceptor physiology (E. Reinhard, 2005)
1039             2 .. Gradient domain high dynamic range compression (R. Fattal, 2002)
1040              
1041             Optional parameters:
1042              
1043             $pimage->tone_mapping(0, $gamma, $exposure);
1044             #or
1045             $pimage->tone_mapping(1, $intensity, $contrast);
1046             #or
1047             $pimage->tone_mapping(2, $color_saturation, $attenuation);
1048              
1049             =head2 free_image_version
1050              
1051             Returns a string containing the current version of the library.
1052              
1053             my $v = PDL::IO::Image->free_image_version();
1054              
1055             =head2 format_list
1056              
1057             Returns a list of all supported file formats.
1058              
1059             my @f = PDL::IO::Image->format_list();
1060              
1061             =head2 format_extension_list
1062              
1063             Returns a comma-delimited file extension list for given file format.
1064              
1065             my $ext = PDL::IO::Image->format_extension_list($format);
1066              
1067             C<$format> - string identifying file format (e.g. C<'JPEG'> - for valid values see L).
1068              
1069             =head2 format_mime_type
1070              
1071             Returns MIME content type string for given file format.
1072              
1073             my $mtype = PDL::IO::Image->format_mime_type($format);
1074              
1075             C<$format> - string identifying file format (e.g. C<'JPEG'> - for valid values see L).
1076              
1077             =head2 format_description
1078              
1079             Returns description string for given file format.
1080              
1081             my $desc = PDL::IO::Image->format_description($format);
1082              
1083             C<$format> - string identifying file format (e.g. C<'JPEG'> - for valid values see L).
1084              
1085             =head2 format_can_read
1086              
1087             Returns C<1> or C<0> - module supports (or not) reading given file format.
1088              
1089             my $bool = PDL::IO::Image->format_can_read($format);
1090              
1091             C<$format> - string identifying file format (e.g. C<'JPEG'> - for valid values see L).
1092              
1093             =head2 format_can_write
1094              
1095             Returns C<1> or C<0> - module supports (or not) saving given file format.
1096              
1097             my $bool = PDL::IO::Image->format_can_write($format);
1098              
1099             C<$format> - string identifying file format (e.g. C<'JPEG'> - for valid values see L).
1100              
1101             =head2 format_can_export_type
1102              
1103             Returns C<1> or C<0> - module can export (or not) given image type to given file format.
1104              
1105             my $bool = PDL::IO::Image->format_can_export_type($format, $image_type);
1106              
1107             C<$format> - string identifying file format (e.g. C<'JPEG'> - for valid values see L).
1108              
1109             C<$image_type> - string identifying image type (e.g. C<'BITMAP'> - for valid values see L).
1110              
1111             =head2 format_can_export_bpp
1112              
1113             Returns C<1> or C<0> - module can export (or not) given file format in given bits per pixel depth.
1114              
1115             my $bool = PDL::IO::Image->format_can_export_bpp($format, $bpp);
1116              
1117             C<$format> - string identifying file format (e.g. C<'JPEG'> - for valid values see L).
1118              
1119             C<$bpp> - bits per pixel (e.g. 1, 4, 8, 16, 24, 32)
1120              
1121             =head2 format_from_mime
1122              
1123             Returns file format string (e.g. C<'BMP'>, C<'JPEG'> - see L) for given mime type.
1124              
1125             my $format = PDL::IO::Image->format_from_mime($mime_type);
1126              
1127             =head2 format_from_file
1128              
1129             Returns file format string (e.g. C<'BMP'>, C<'JPEG'> - see L) for given C<$filename>.
1130              
1131             my $format = PDL::IO::Image->format_from_file($filename);
1132              
1133             =head1 CONSTANTS
1134              
1135             There many constants which can be used with L or L methods. These constants are not exported
1136             by this module therefore you have to use full names like this:
1137              
1138             use PDL;
1139             use PDL::IO::Image;
1140              
1141             my $pimage = PDL::IO::Image->new_from_file("in.jpg", "JPEG", PDL::IO::Image::JPEG_ACCURATE);
1142              
1143             =head1 SEE ALSO
1144              
1145             L, L, L, L, L
1146              
1147             =head1 LICENSE
1148              
1149             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1150              
1151             =head1 COPYRIGHT
1152              
1153             2014+ KMX Ekmx@cpan.orgE
1154              
1155             =cut
1156              
1157              
1158             ;
1159              
1160              
1161              
1162             # Exit with OK status
1163              
1164             1;
1165              
1166