This is an automated email from the git hooks/post-receive script. carnil pushed a commit to branch master in repository libimage-info-perl.
commit d27b925b63d1082ba7933781782977424aa270ef Merge: 2c96f9a d8e65db Author: Don Armstrong <d...@debian.org> Date: Fri May 26 14:11:11 2006 -0700 Import Debian patch 1.21-1 Build.PL | 5 + CREDITS | 27 ++ Changes | 65 ++++ Info.pm.tmpl | 173 ++++++--- MANIFEST | 29 +- META.yml | 4 +- Makefile.PL | 133 ++----- README | 22 +- SIGNATURE | 85 +++-- TODO | 6 +- debian/changelog | 7 + debian/control | 3 +- Info.pm.tmpl => dev/Info.pm.tmpl | 208 ++++++++--- dev/build.pl | 84 +++++ exifdump | 4 +- img/be.tif | Bin 0 -> 394 bytes img/le.tif | Bin 0 -> 416 bytes img/test.gif | Bin 104768 -> 29392 bytes img/test.rle | Bin 61084 -> 4582 bytes img/test.tif | Bin 0 -> 2832 bytes imgdump | 2 +- inc/Module/AutoInstall.pm | 753 ++++++++++++++++++++++++++++++++++++++ inc/Module/Install.pm | 265 ++++++++++++++ inc/Module/Install/AutoInstall.pm | 58 +++ inc/Module/Install/Base.pm | 70 ++++ inc/Module/Install/Build.pm | 66 ++++ inc/Module/Install/Can.pm | 82 +++++ inc/Module/Install/Fetch.pm | 92 +++++ inc/Module/Install/Include.pm | 31 ++ inc/Module/Install/Makefile.pm | 198 ++++++++++ inc/Module/Install/Metadata.pm | 310 ++++++++++++++++ inc/Module/Install/Win32.pm | 64 ++++ inc/Module/Install/WriteAll.pm | 40 ++ lib/Image/Info.pm | 528 ++++++++++++++++++++++++++ lib/Image/Info/BMP.pm | 49 ++- lib/Image/Info/JPEG.pm | 9 + lib/Image/Info/PPM.pm | 48 ++- lib/Image/Info/SVG.pm | 39 +- lib/Image/Info/TIFF.pm | 249 ++++++++----- lib/Image/Info/XBM.pm | 22 +- lib/Image/Info/XPM.pm | 20 +- lib/Image/TIFF.pm | 290 ++++++++++----- t/00_basics.t | 66 ++++ t/bmp.t | 14 +- t/dim.t | 6 +- t/exif.t | 12 +- t/pod_cov.t | 28 +- t/string.t | 106 +++--- t/tiff.t | 38 ++ t/tiff_e.t | 43 +++ t/tiny-pgm.t | 2 +- 51 files changed, 3915 insertions(+), 540 deletions(-) diff --cc Info.pm.tmpl index a325f47,0000000..f53226e mode 100644,000000..100644 --- a/Info.pm.tmpl +++ b/Info.pm.tmpl @@@ -1,339 -1,0 +1,426 @@@ +package Image::Info; + +# Copyright 1999-2004, Gisle Aas. +# +# This library is free software; you can redistribute it and/or +# modify it under the same terms as Perl itself. +# - # Now maintained by Tels. ++# Now maintained by Tels - (c) 2006. + +use strict; +use Symbol (); + +use vars qw($VERSION @EXPORT_OK); + - $VERSION = '1.17'; ++$VERSION = '1.20'; + +require Exporter; +*import = \&Exporter::import; + +@EXPORT_OK = qw(image_info dim html_dim); + ++# already required and failed sub-modules are remembered here +my %mod_failure; + +sub image_info +{ - my($source, %cnf) = @_; ++ my $source = _source(shift); ++ return $source if ref $source eq 'HASH'; # Pass on errors ++ ++ # What sort of file is it? ++ my $head = _head($source); ++ ++ return $head if ref($head) eq 'HASH'; # error? ++ ++ my $format = determine_file_format($head) ++ or return { error => 'Unrecognized file format' }; ++ ++ no strict 'refs'; ++ my $mod = "Image::Info::$format"; ++ my $sub = "$mod\::process_file"; ++ my $info = bless [], "Image::Info::Result"; ++ eval { ++ unless (defined &$sub) { ++ # already required and failed? ++ if (my $fail = $mod_failure{$mod}) { ++ die $fail; ++ } ++ eval "require $mod"; ++ if ($@) { ++ $mod_failure{$mod} = $@; ++ die $@; ++ } ++ die "$mod did not define &$sub" unless defined &$sub; ++ } ++ ++ my %cnf = @_; ++ &$sub($info, $source, \%cnf); ++ $info->clean_up; ++ }; ++ return { error => $@ } if $@; ++ return wantarray ? @$info : $info->[0]; ++} ++ ++sub image_type ++{ ++ my $source = _source(shift); ++ return $source if ref $source eq 'HASH'; # Pass on errors + ++ # What sort of file is it? ++ my $head = _head($source) or return _os_err("Can't read head"); ++ my $format = determine_file_format($head) ++ or return { error => "Unrecognized file format" }; ++ ++ return { file_type => $format }; ++} ++ ++sub _source ++{ ++ my $source = shift; + if (!ref $source) { + require Symbol; + my $fh = Symbol::gensym(); + open($fh, $source) || return _os_err("Can't open $source"); + ${*$fh} = $source; # keep filename in case somebody wants to know + binmode($fh); + $source = $fh; + } + elsif (ref($source) eq "SCALAR") { + if ($] >= 5.008) { + open(my $s, "<", $source) or return _os_err("Can't open string"); + $source = $s; + } + else { + require IO::String; + $source = IO::String->new($$source); + } + } + else { + seek($source, 0, 0) or return _os_err("Can't rewind"); + } + ++ $source; ++} ++ ++sub _head ++{ ++ my $source = shift; + my $head; - read($source, $head, 32) or return _os_err("Can't read head"); ++ ++ # tiny.pgm is 11 bytes ++ my $to_read = 11; ++ my $read = read($source, $head, $to_read); ++ ++ return _os_err("Couldn't read $to_read bytes") if $read != $to_read; ++ + if (ref($source) eq "IO::String") { + # XXX workaround until we can trap seek() with a tied file handle + $source->setpos(0); + } + else { - seek($source, 0, 0) or _os_err("Can't rewind"); - } - - if (my $format = determine_file_format($head)) { - no strict 'refs'; - my $mod = "Image::Info::$format"; - my $sub = "$mod\::process_file"; - my $info = bless [], "Image::Info::Result"; - eval { - unless (defined &$sub) { - if (my $fail = $mod_failure{$mod}) { - die $fail; - } - eval "require $mod;"; - if ($@) { - $mod_failure{$mod} = $@; - die $@; - } - die "$mod did not define &$sub" unless defined &$sub; - } - - &$sub($info, $source, \%cnf); - $info->clean_up; - }; - return { error => $@ } if $@; - return wantarray ? @$info : $info->[0]; ++ seek($source, 0, 0) or return _os_err("Can't rewind"); + } - return { error => "Unrecognized file format" }; ++ $head; +} + +sub _os_err +{ + return { error => "$_[0]: $!", + Errno => $!+0, + }; +} + +%%DETERMINE_FILE_FORMAT%% + +sub dim +{ + my $img = shift || return; + my $x = $img->{width} || return; + my $y = $img->{height} || return; + wantarray ? ($x, $y) : "${x}x$y"; +} + +sub html_dim +{ + my($x, $y) = dim(@_); + return "" unless $x; + "width=\"$x\" height=\"$y\""; +} + +package Image::Info::Result; + +sub push_info +{ + my($self, $n, $key) = splice(@_, 0, 3); + push(@{$self->[$n]{$key}}, @_); +} + +sub clean_up +{ + my $self = shift; + for (@$self) { + for my $k (keys %$_) { + my $a = $_->{$k}; + $_->{$k} = $a->[0] if @$a <= 1; + } + } +} + +sub get_info { + my($self, $n, $key, $delete) = @_; + my $v = $delete ? delete $self->[$n]{$key} : $self->[$n]{$key}; + $v ||= []; + @$v; +} + +1; + +__END__ + +=head1 NAME + +Image::Info - Extract meta information from image files + +=head1 SYNOPSIS + + use Image::Info qw(image_info dim); + + my $info = image_info("image.jpg"); + if (my $error = $info->{error}) { + die "Can't parse image info: $error\n"; + } + my $color = $info->{color_type}; - ++ ++ my $type = image_type("image.jpg"); ++ if (my $error = $type->{error}) { ++ die "Can't determine file type: $error\n"; ++ } ++ die "No gif files allowed!" if $type->{file_type} eq 'GIF'; ++ + my($w, $h) = dim($info); + +=head1 DESCRIPTION + +This module provide functions to extract various kind of meta +information from image files. The following functions are provided by +the C<Image::Info> module: + +=over + +=item image_info( $file ) + +=item image_info( \$imgdata ) + +=item image_info( $file, key => value,... ) + +This function takes the name of a file or a file handle as argument +and will return one or more hashes (actually hash references) +describing the images inside the file. If there is only one image in +the file only one hash is returned. In scalar context, only the hash +for the first image is returned. + +In case of error, and hash containing the "error" key will be +returned. The corresponding value will be an appropriate error +message. + +If a reference to a scalar is passed as argument to this function, +then it is assumed that this scalar contains the raw image data +directly. + +The image_info() function also take optional key/value style arguments +that can influence what information is returned. + ++=item image_type( $file ) ++ ++=item image_info( \$imgdata ) ++ ++This function is a dramatically faster alternative to the image_info ++function for situations in which you B<only> need to find the image type. ++ ++It uses only the internal file-type detection to do this, and thus does ++not need to load any of the image type-specific driver modules, and does ++not access to entire file. It also only needs access to the first 32 ++bytes of the file. ++ ++To maintain some level of compatibility with image_info, image_type ++returns in the same format, with the same error message style. That is, ++it returns a HASH reference, with the $type->{error} key set if there ++was an error. ++ ++On success, the HASH reference will contain the single key 'file_type', ++which represents the type of the file, expressed as the type code used for ++the various drivers ('GIF', 'JPEG', 'TIFF' and so on). ++ ++If there are multiple images within the file they will be ignored, as this ++function provides only the type of the overall file, not of the various ++images within it. This function will not return multiple hashes if the file ++contains multiple images. ++ ++Of course, in all (or at least effectively all) cases the type of the images ++inside the file is going to be the same as that of the file itself. ++ +=item dim( $info_hash ) + +Takes an hash as returned from image_info() and returns the dimensions +($width, $height) of the image. In scalar context returns the +dimensions as a string. + +=item html_dim( $info_hash ) + +Returns the dimensions as a string suitable for embedding directly +into HTML or SVG <img>-tags. E.g.: + + print "<img src="..." @{[html_dim($info)]}>\n"; + ++=item determine_file_format( $file ) ++ ++Determines the file format from the passed file data, and returns ++either undef for an unknown file format, or a string describing ++the format, like "BMP" or "JPEG". ++ +=back + +=head1 Image descriptions + +The image_info() function returns meta information about each image in +the form of a reference to a hash. The hash keys used are in most +cases based on the TIFF element names. All lower case keys are +mandatory for all file formats and will always be there unless an +error occured (in which case the "error" key will be present.) Mixed +case keys will only be present when the corresponding information +element is available in the image. + +The following key names are common for any image format: + +=over + +=item file_media_type + +This is the MIME type that is appropriate for the given file format. +The corresponding value is a string like: "image/png" or "image/jpeg". + +=item file_ext + +The is the suggested file name extention for a file of the given file +format. The value is a 3 letter, lowercase string like "png", "jpg". + +=item width + +This is the number of pixels horizontally in the image. + +=item height + +This is the number of pixels vertically in the image. (TIFF use the +name ImageLength for this field.) + +=item color_type + +The value is a short string describing what kind of values the pixels +encode. The value can be one of the following: + + Gray + GrayA + RGB + RGBA + CMYK + YCbCr + CIELab + +These names can also be prefixed by "Indexed-" if the image is +composed of indexes into a palette. Of these, only "Indexed-RGB" is +likely to occur. + - (It is similar to the TIFF field PhotometricInterpretation, but this ++It is similar to the TIFF field PhotometricInterpretation, but this +name was found to be too long, so we used the PNG inpired term - instead.) ++instead. + +=item resolution + +The value of this field normally gives the physical size of the image +on screen or paper. When the unit specifier is missing then this field +denotes the squareness of pixels in the image. + +The syntax of this field is: + + <res> <unit> + <xres> "/" <yres> <unit> + <xres> "/" <yres> + +The <res>, <xres> and <yres> fields are numbers. The <unit> is a +string like C<dpi>, C<dpm> or C<dpcm> (denoting "dots per +inch/cm/meter). + +=item SamplesPerPixel + +This says how many channels there are in the image. For some image +formats this number might be higher than the number implied from the +C<color_type>. + +=item BitsPerSample + +This says how many bits are used to encode each of samples. The value +is a reference to an array containing numbers. The number of elements +in the array should be the same as C<SamplesPerPixel>. + +=item Comment + +Textual comments found in the file. The value is a reference to an +array if there are multiple comments found. + +=item Interlace + +If the image is interlaced, then this tell which interlace method is +used. + +=item Compression + - This tell which compression algorithm is used. ++This tells you which compression algorithm is used. + +=item Gamma + +A number. + +=item LastModificationTime + +A ISO date string + +=back + +=head1 Supported Image Formats + - The following image file formats are currently supported: ++The following image file formats are supported: + +=over + +%%FORMAT_DESC%% + +=back + ++=head1 CAVEATS ++ ++Note that while the module is still maintained, no new features ++will be added. ++ ++Especially the EXIF parsing code is buggy, not tested at all, ++and quite incomplete (a lot of manufacturer's MakerNotes and tags are ++not parsed at all). If you want a stable, feature-complete, up-to-date ++and tested EXIF parsing library, please use Image::ExifTool. ++ +=head1 SEE ALSO + - L<Image::Size> ++L<Image::Size>, L<Image::ExifTool> + +=head1 AUTHORS + +Copyright 1999-2004 Gisle Aas. + - GIF fixes by Ralf Steines <metam...@yahoo.com>. - - ASCII, BMP SVG, XPM and XBM support added by Jerrad Pierce - <belg4...@mit.edu>/<webmas...@pthbb.org>. ++See the CREDITS file for a list of contributors and authors. + - Exif MakerNote decoding by Jay Soffian <j...@loudcloud.com>. ++Now maintained by Tels - (c) 2006. + - TIFF support by <clar...@emf.net>. ++=head1 LICENSE + +This library is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. + +=cut diff --cc debian/changelog index 7340ec0,0000000..1380e00 mode 100644,000000..100644 --- a/debian/changelog +++ b/debian/changelog @@@ -1,43 -1,0 +1,50 @@@ ++libimage-info-perl (1.21-1) unstable; urgency=low ++ ++ * New upstream release ++ * Upgrade standards version to 3.7.2, no changes necessary ++ ++ -- Don Armstrong <d...@debian.org> Fri, 26 May 2006 14:11:11 -0700 ++ +libimage-info-perl (1.17-2) unstable; urgency=low + + * Add suport for the Nikon D70s to Image::TIFF (closes: #351728) + * Update watch file to support the change in maintainer + + -- Don Armstrong <d...@debian.org> Mon, 6 Feb 2006 17:55:58 -0800 + +libimage-info-perl (1.17-1) unstable; urgency=low + + * New upstream release (closes: #351600) + * Upgrade standards version; no changes necessary + + -- Don Armstrong <d...@debian.org> Mon, 6 Feb 2006 14:06:03 -0800 + +libimage-info-perl (1.16-2) unstable; urgency=low + + * Use Data::Dumper instead of Data::Dump (closes: #284001) + * Fix busted links to exif-e.html (closes: #27837) + * Don't bother to parse information in thumbnails if ilen is 0 (closes: #281967) + + -- Don Armstrong <d...@debian.org> Mon, 7 Mar 2005 16:53:19 -0800 + +libimage-info-perl (1.16-1) unstable; urgency=low + + * New upstream release (closes: #174846) + * Fix debian/copyright problems (closes: #157596) + * New maintainer adopting this package (closes: #274131) + * Depend on libimage-base-perl [Image::Xbm, Image::Xpm] + * Depend on libxml-simple-perl [Image::Info::Svg] + + -- Don Armstrong <d...@donarmstrong.com> Wed, 6 Oct 2004 16:07:04 -0700 + +libimage-info-perl (1.09-2) unstable; urgency=low + + * Fix problem with build prereqs. + + -- Michael Alan Dorman <mdor...@debian.org> Thu, 21 Feb 2002 12:02:18 -0500 + +libimage-info-perl (1.09-1) unstable; urgency=low + + * Initial packaging + + -- Michael Alan Dorman <mdor...@debian.org> Thu, 21 Feb 2002 11:53:56 -0500 diff --cc debian/control index 1362cea,0000000..fa1a968 mode 100644,000000..100644 --- a/debian/control +++ b/debian/control @@@ -1,26 -1,0 +1,27 @@@ +Source: libimage-info-perl +Maintainer: Don Armstrong <d...@debian.org> +Priority: optional +Section: perl - Build-Depends-Indep: debhelper (>= 4), perl (>= 5.6.0-17), libio-string-perl, libimage-base-bundle-perl | libimage-xpm-perl, libimage-base-bundle-perl | libimage-xbm-perl, libxml-simple-perl ++Build-Depends: debhelper (>= 4) ++Build-Depends-Indep: perl (>= 5.6.0-17), libio-string-perl, libimage-base-bundle-perl | libimage-xpm-perl, libimage-base-bundle-perl | libimage-xbm-perl, libxml-simple-perl +Standards-Version: 3.6.2 + +Package: libimage-info-perl +Architecture: all +Priority: optional +Section: perl +Depends: ${perl:Depends}, libio-string-perl, libimage-base-bundle-perl | libimage-xpm-perl, libimage-base-bundle-perl | libimage-xbm-perl, libxml-simple-perl +Description: allows extraction of meta information from image files + This Perl extension allows you to extract meta information from + various types of image files. In this release the following file + formats are supported: + . + JPEG (plain JFIF and Exif) + PNG + GIF + PBM/PGM/PPM + SVG + XBM/XPM + BMP/DIB/RLE + TIFF + diff --cc exifdump index efdc799,65f6bf9..0d88f76 --- a/exifdump +++ b/exifdump @@@ -1,8 -1,10 +1,10 @@@ -#!/usr/bin/perl -w +#!/usr/bin/perl -use lib 'lib'; ++use warnings; + use strict; use Image::Info qw(image_info); - $i=image_info($ARGV[0]); + my $i=image_info($ARGV[0]); foreach (sort keys %$i) { if ($i->{$_} =~ /[\001-\037\177-\377]/ && !/error/) { diff --cc lib/Image/Info/TIFF.pm index 1341bcf,bf613d7..1348cd5 --- a/lib/Image/Info/TIFF.pm +++ b/lib/Image/Info/TIFF.pm @@@ -1,25 -1,28 +1,29 @@@ package Image::Info::TIFF; - =begin register - - MAGIC: /^MM\x00\x2a/ - MAGIC: /^II\x2a\x00/ - - The C<TIFF> spec can be found at: - http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf - - Also good writeup on exif spec at: - http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html - - =end register - - =cut + use strict; use Config; + use Carp qw(confess); use Image::TIFF; - sub my_read + my @types = ( + [ "ERROR INVALID TYPE", "?", 0], + [ "BYTE", "C", 1], + [ "ASCII", "A", 1], + [ "SHORT", "S", 2], + [ "LONG", "L", 4], + [ "RATIONAL", "N2", 8], + [ "SBYTE", "c", 1], + [ "UNDEFINED", "a", 1], + [ "SSHORT", "s", 2], + [ "SLONG", "l", 4], + [ "SRATIONAL", "N2", 8], + [ "FLOAT", "f", 4], + [ "DOUBLE", "d", 8], + ); + + + sub _read { my($source, $len) = @_; my $buf; diff --cc t/dim.t index 953e6b8,0000000..6833f9e mode 100644,000000..100644 --- a/t/dim.t +++ b/t/dim.t @@@ -1,27 -1,0 +1,27 @@@ +#!/usr/bin/perl -w + +use Test::More; +use strict; + +# test dim(), html_dim() and image_info() + +BEGIN + { + plan tests => 5; + chdir 't' if -d 't'; + use lib '../lib'; + use_ok ("Image::Info") or die($@); + }; + +use Image::Info qw(image_info dim html_dim); + +my $info = image_info("../img/test.gif"); +my @dim = dim($info); + - is (join(" ", @dim), "400 300", 'dim()'); ++is (join(" ", @dim), "200 150", 'dim()'); + - is (dim($info), '400x300', 'dim($info)'); ++is (dim($info), '200x150', 'dim($info)'); + - is (html_dim($info), 'width="400" height="300"', 'html_dim()'); ++is (html_dim($info), 'width="200" height="150"', 'html_dim()'); + +is (html_dim(image_info('README')), '', 'no README in info'); -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libimage-info-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits