Graphics-TIFF
view release on metacpan or search on metacpan
7 Thu, 27 Oct 2020 19:30 +0100
- Fix TIFFGetField for TIFFTAG_COLORMAP
6 Wed, 02 Aug 2017 19:30 +0200
- correct number of tests to skip in t/1.t. Closes RT 122665
(t/1.t fails on some Linux systems)
5 Sat, 29 Jul 2017 19:30 +0200
- correct pkgconfig identifier. Closes RT 122628.
Thanks to Petr Pisar for the patch.
- don't depend on Image::Magick and skip tests if not installed
- + tests with no dependencies
4 Mon, 17 Jul 2017 19:30 +0200
- rewrite test in 1.t to fix failure with older Perls
- skip 92_tiffinfo.t & 93_tiff2pdf.t if we don't have Perl 5.10, adding
Test::Requires to TEST_REQUIRES
- use Pod::Readme to build README from POD
- use perlmagick to build test images and thus fix test failures from
smokers without Imagemagick
The runtime dependencies are just libtiff itself. In Windows this is
satisfied by Alien::libtiff.
Build
The build dependencies are additionally the development headers for
libtiff and Perl.
Test
In addition to the above, the Perl module Image::Magick is required to
run some of the tests.
INCOMPATIBILITIES
BUGS AND LIMITATIONS
SEE ALSO
The LIBTIFF Standard Reference http://www.libtiff.org/libtiff.html is a
handy companion. The Perl bindings follow the C API very closely, and
lib/Graphics/TIFF.pm view on Meta::CPAN
The runtime dependencies are just libtiff itself. In Windows this is satisfied
by Alien::libtiff.
=head2 Build
The build dependencies are additionally the development headers for libtiff
and Perl.
=head2 Test
In addition to the above, the Perl module Image::Magick is required to run some
of the tests.
=head1 INCOMPATIBILITIES
=head1 BUGS AND LIMITATIONS
=head1 SEE ALSO
The LIBTIFF Standard Reference L<http://www.libtiff.org/libtiff.html> is a handy
companion. The Perl bindings follow the C API very closely, and the C reference
use warnings;
use strict;
use Graphics::TIFF ':all';
use Test::More tests => 50;
use Test::Deep;
use IPC::Cmd qw(can_run);
use Test::Requires qw( Image::Magick );
use File::Temp;
use File::Spec;
use English;
BEGIN { use_ok('Graphics::TIFF') }
#########################
like( Graphics::TIFF->GetVersion, qr/LIBTIFF, Version/, 'version string' );
my $version = Graphics::TIFF->get_version_scalar;
if ( $version < 4.000003 ) {
plan skip_all => 'libtiff 4.0.3 or better required';
exit;
}
ok( Graphics::TIFF->IsCODECConfigured(COMPRESSION_DEFLATE),
'IsCODECConfigured' );
my $directory = File::Temp->newdir;
my $image = Image::Magick->new;
my $file = File::Spec->catfile( $directory, 'test.tif' );
$image->Read('rose:');
$image->Set( density => '72x72' );
$image->Write($file);
my $tif = Graphics::TIFF->Open( $file, 'r' );
is( $tif->FileName, $file, 'FileName' );
isa_ok $tif, 'Graphics::TIFF';
can_ok $tif, qw(Close ReadDirectory ReadEXIFDirectory GetField);
}
$out->WriteDirectory;
$tif->Close;
$out->Close;
is( `tiffcmp $file $file2`, '', 'tiffcmp' );
}
#########################
$image = Image::Magick->new;
$image->Read('rose:');
$image->Set( density => '72x72', alpha => 'Set' );
$image->Write($file);
$tif = Graphics::TIFF->Open( $file, 'r' );
my @values = $tif->GetField(TIFFTAG_EXTRASAMPLES);
is_deeply( \@values, [EXTRASAMPLE_UNASSALPHA],
'GetField TIFFTAG_EXTRASAMPLES' );
@values = $tif->GetFieldDefaulted(TIFFTAG_EXTRASAMPLES);
is_deeply( \@values, [EXTRASAMPLE_UNASSALPHA],
'GetFieldDefaulted TIFFTAG_EXTRASAMPLES' );
$tif->Close;
#########################
$image = Image::Magick->new;
$image->Read('rose:');
$image->Set( density => '72x72', type => 'palette', depth => 2 );
$image->Write($file);
$tif = Graphics::TIFF->Open( $file, 'r' );
@values = $tif->GetField(TIFFTAG_COLORMAP);
is $#{ $values[0] }, 255, 'GetField TIFFTAG_COLORMAP r';
is $#{ $values[1] }, 255, 'GetField TIFFTAG_COLORMAP g';
is $#{ $values[2] }, 255, 'GetField TIFFTAG_COLORMAP b';
t/92_tiffinfo.t view on Meta::CPAN
use warnings;
use strict;
use English;
use IPC::Cmd qw(can_run);
use Test::More;
use Test::Requires qw( v5.10 Image::Magick );
use File::Temp;
use File::Spec;
#########################
if ( not $ENV{TEST_AUTHOR} ) {
my $msg = 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.';
plan( skip_all => $msg );
}
if ( can_run('tiffinfo') ) {
plan tests => 15;
}
else {
plan skip_all => 'tiffinfo not installed';
exit;
}
my $directory = File::Temp->newdir;
my $file = File::Spec->catfile( $directory, 'test.tif' );
my $image = Image::Magick->new;
$image->Read( 'rose:', 'rose:' );
$image->Set( density => '72x72' );
$image->Write($file);
my $cmd = 'PERL5LIB="blib:blib/arch:lib:$PERL5LIB" '
. "$EXECUTABLE_NAME examples/tiffinfo.pl";
is( `$cmd $file`, `tiffinfo $file`, 'basic multi-directory' );
is( `$cmd -2 $file`, `tiffinfo -2 $file`, 'dirnum' );
$image = Image::Magick->new;
$image->Read('rose:');
$image->Set( density => '72x72' );
$image->Write($file);
is( `$cmd -d $file`, `tiffinfo -d $file`, '-d' );
is( `$cmd -D $file`, `tiffinfo -D $file`, '-D' );
is(
`$cmd -d -f lsb2msb $file`,
t/93_tiff2pdf.t view on Meta::CPAN
use warnings;
use strict;
use English;
use IPC::Cmd qw(can_run);
use Test::More;
use Test::Requires qw( v5.10 Image::Magick );
use File::Temp;
use File::Spec;
#########################
if ( not $ENV{TEST_AUTHOR} ) {
my $msg = 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.';
plan( skip_all => $msg );
}
t/93_tiff2pdf.t view on Meta::CPAN
# strip '-m' option added in tiff-4.2.0
$expected =~ s/^ -m: .*?\R//ms;
# strip a description line added in libtiff 4.3.0
$expected =~ s/^Convert a TIFF image to a PDF document\R\R//sm;
# adjust options introduction changed in libtiff 4.3.0
$expected =~ s/^where options are:/options:/sm;
is( `$cmd -? $tif 2>&1`, $expected, '-?' );
#########################
my $image = Image::Magick->new;
$image->Read('rose:');
$image->Set( density => '72x72' );
$image->Write($tif);
system("tiff2pdf -d -o $pdf $tif");
$expected = `cat $pdf | $make_reproducible | hexdump`;
my @expected = split "\n", $expected;
my @output = split "\n", `$cmd -d $tif | $make_reproducible | hexdump`;
is_deeply( \@output, \@expected, 'basic functionality' );
( run in 0.863 second using v1.01-cache-2.11-cpan-beeb90c9504 )