Image-PNG-Libpng
view release on metacpan or search on metacpan
t/get-text.t view on Meta::CPAN
use warnings;
use strict;
use Test::More;
use Image::PNG::Libpng ':all';
use Image::PNG::Const ':all';
use FindBin '$Bin';
BEGIN: {
use lib "$Bin";
use IPNGLT;
};
use utf8;
use FindBin '$Bin';
use Scalar::Util 'looks_like_number';
binmode STDOUT, ":utf8";
my $builder = Test::More->builder;
binmode $builder->output, ":utf8";
binmode $builder->failure_output, ":utf8";
binmode $builder->todo_output, ":utf8";
# http://www.cpantesters.org/cpan/report/6174e60e-6bf3-1014-896f-3999f29aa079
# and similar, this appears to be a bug in libpng version 1.6.3.
skip_itxt ();
skip_old ();
my @stuff = (
{
file => 'ct0n0g04',
comment => 'no textual data',
empty => 1,
},
{
file => 'ct1n0g04',
comment => 'with textual data',
chunks => [
{
lang => undef,
itxt_length => 0,
text_length => 8,
text => 'PngSuite',
lang_key => undef,
compression => -1,
key => 'Title',
},
{
key => 'Author',
itxt_length => 0,
text_length => 42,
lang_key => undef,
compression => -1,
text => 'Willem A.J. van Schaik
(willem@schaik.com)',
lang => undef,
},
{
lang => undef,
lang_key => undef,
compression => -1,
text => 'Copyright Willem van Schaik, Singapore 1995-96',
text_length => 46,
itxt_length => 0,
key => 'Copyright',
},
{
lang_key => undef,
text => 'A compilation of a set of images created to test the
various color-types of the PNG format. Included are
black&white, color, paletted, with alpha channel, with
transparency formats. All bit-depths allowed according
to the spec are present.',
compression => -1,
text_length => 239,
itxt_length => 0,
lang => undef,
key => 'Description',
},
{
key => 'Software',
text_length => 48,
itxt_length => 0,
lang_key => undef,
text => 'Created on a NeXTstation color using "pnmtopng".',
compression => -1,
lang => undef,
},
{
key => 'Disclaimer',
compression => -1,
lang_key => undef,
text => 'Freeware.',
text_length => 9,
itxt_length => 0,
lang => undef,
},
],
},
{
file => 'ctzn0g04',
comment => 'with compressed textual data',
chunks => [
{
key => 'Title',
lang => undef,
text => 'PngSuite',
lang_key => undef,
compression => -1,
text_length => 8,
itxt_length => 0,
},
{
key => 'Author',
itxt_length => 0,
text_length => 42,
compression => -1,
lang_key => undef,
text => 'Willem A.J. van Schaik
(willem@schaik.com)',
lang => undef,
},
{
key => 'Copyright',
lang => undef,
text_length => 46,
itxt_length => 0,
lang_key => undef,
text => 'Copyright Willem van Schaik, Singapore 1995-96',
compression => 0,
},
{
key => 'Description',
lang_key => undef,
text => 'A compilation of a set of images created to test the
various color-types of the PNG format. Included are
black&white, color, paletted, with alpha channel, with
transparency formats. All bit-depths allowed according
to the spec are present.',
compression => 0,
itxt_length => 0,
text_length => 239,
lang => undef,
},
{
lang => undef,
compression => 0,
lang_key => undef,
text => 'Created on a NeXTstation color using "pnmtopng".',
text_length => 48,
itxt_length => 0,
key => 'Software',
},
{
lang_key => undef,
text => 'Freeware.',
compression => 0,
itxt_length => 0,
text_length => 9,
lang => undef,
key => 'Disclaimer',
},
],
},
{
file => 'cten0g04',
comment => 'english',
chunks => [
{
lang => 'en',
text => 'PngSuite',
lang_key => 'Title',
compression => 1,
itxt_length => 8,
text_length => 0,
key => 'Title',
},
{
key => 'Author',
lang => 'en',
lang_key => 'Author',
text => 'Willem van Schaik (willem@schaik.com)',
compression => 1,
text_length => 0,
itxt_length => 37,
},
{
key => 'Copyright',
itxt_length => 40,
text_length => 0,
lang_key => 'Copyright',
compression => 1,
text => 'Copyright Willem van Schaik, Canada 2011',
lang => 'en',
},
{
itxt_length => 239,
text_length => 0,
lang_key => 'Description',
compression => 1,
text => 'A compilation of a set of images created to test the various color-types of the PNG format. Included are black&white, color, paletted, with alpha channel, with transparency formats. All bit-depths allowed according to the spec are present.',
lang => 'en',
key => 'Description',
},
{
lang => 'en',
lang_key => 'Software',
compression => 1,
text => 'Created on a NeXTstation color using "pnmtopng".',
itxt_length => 48,
text_length => 0,
key => 'Software',
},
{
key => 'Disclaimer',
itxt_length => 9,
text_length => 0,
lang_key => 'Disclaimer',
text => 'Freeware.',
compression => 1,
lang => 'en',
},
],
},
{
file => 'ctfn0g04',
comment => 'finnish',
chunks => [
{
key => 'Title',
lang_key => 'Otsikko',
compression => 1,
text => 'PngSuite',
itxt_length => 8,
text_length => 0,
lang => 'fi',
},
{
key => 'Author',
lang => 'fi',
itxt_length => 37,
text_length => 0,
lang_key => 'Tekijä',
compression => 1,
text => 'Willem van Schaik (willem@schaik.com)',
},
{
lang => 'fi',
itxt_length => 40,
text_length => 0,
lang_key => 'Tekijänoikeudet',
compression => 1,
text => 'Copyright Willem van Schaik, Kanada 2011',
key => 'Copyright',
},
{
key => 'Description',
text_length => 0,
itxt_length => 211,
text => 'kokoelma joukon kuvia luotu testata eri väri-tyyppisiä PNG-muodossa. Mukana on mustavalkoinen, väri, paletted, alpha-kanava, avoimuuden muodossa. Kaikki bit-syvyydessä mukaan sallittua spec on ââläsnä.',
lang_key => 'Kuvaus',
compression => 1,
lang => 'fi',
},
{
lang => 'fi',
itxt_length => 37,
text_length => 0,
text => 'Luotu NeXTstation väriä "pnmtopng".',
lang_key => 'Ohjelmistot',
compression => 1,
key => 'Software',
},
{
key => 'Disclaimer',
lang => 'fi',
itxt_length => 9,
text_length => 0,
compression => 1,
lang_key => 'Vastuuvapauslauseke',
text => 'Freeware.',
},
],
},
{
file => 'ctgn0g04',
comment => 'greek',
chunks => [
{
key => 'Title',
itxt_length => 8,
text_length => 0,
text => 'PngSuite',
lang_key => 'ΤίÏλοÏ',
compression => 1,
lang => 'el',
},
{
text_length => 0,
itxt_length => 37,
lang_key => 'ΣÏ
γγÏαÏÎαÏ',
text => 'Willem van Schaik (willem@schaik.com)',
compression => 1,
lang => 'el',
key => 'Author',
},
{
lang_key => 'ΠνεÏ
μαÏικά δικαιÏμαÏα',
text => 'ΠνεÏ
μαÏικά δικαιÏμαÏα Schaik van Willem, ÎÎ±Î½Î±Î´Î¬Ï 2011',
compression => 1,
itxt_length => 80,
text_length => 0,
lang => 'el',
key => 'Copyright',
},
{
lang => 'el',
text => 'Îια ÏÏ
λλογή αÏÏ Îνα ÏÏνολο εικÏνÏν ÏοÏ
δημιοÏ
Ïγήθηκαν για Ïη δοκιμή ÏÏν διαÏÏÏÏν ÏÏÏμάÏÏν-ÏÏÏÏν ÏοÏ
μοÏÏή PNG. ΠεÏιλαμβάνονÏαι οι αÏÏ...
lang_key => 'ΠεÏιγÏαÏή',
compression => 1,
itxt_length => 465,
text_length => 0,
key => 'Description',
},
{
text_length => 0,
itxt_length => 104,
lang_key => 'ÎογιÏμικÏ',
text => 'ÎημιοÏ
Ïγήθηκε Ïε Îνα ÏÏÏμα NeXTstation ÏÏηÏιμοÏοιÏνÏÎ±Ï "pnmtopng".',
compression => 1,
lang => 'el',
key => 'Software',
},
{
key => 'Disclaimer',
text => 'ÎÏÏεάν λογιÏμικÏ.',
lang_key => 'ÎÏοÏοίηÏη',
compression => 1,
itxt_length => 32,
text_length => 0,
lang => 'el',
},
],
},
{
file => 'cthn0g04',
comment => 'hindi',
chunks => [
{
key => 'Title',
text_length => 0,
itxt_length => 8,
lang_key => 'शà¥à¤°à¥à¤·à¤',
text => 'PngSuite',
compression => 1,
lang => 'hi',
},
{
key => 'Author',
lang => 'hi',
text => 'Willem van Schaik (willem@schaik.com)',
lang_key => 'लà¥à¤à¤',
compression => 1,
text_length => 0,
itxt_length => 37,
},
{
lang_key => 'à¤à¥à¤ªà¥à¤°à¤¾à¤à¤',
text => 'à¤à¥à¤ªà¥à¤°à¤¾à¤à¤ Willem van Schaik, 2011 à¤à¤¨à¤¾à¤¡à¤¾',
compression => 1,
itxt_length => 64,
text_length => 0,
lang => 'hi',
key => 'Copyright',
},
{
key => 'Description',
lang => 'hi',
lang_key => 'विवरण',
text => 'à¤à¤°à¤¨à¥ à¤à¥ लिठPNG पà¥à¤°à¤¾à¤°à¥à¤ª à¤à¥ विà¤à¤¿à¤¨à¥à¤¨ रà¤à¤ पà¥à¤°à¤à¤¾à¤° परà¥à¤à¥à¤·à¤£ बनाया à¤à¤µà¤¿à¤¯à¥à¤ à¤à¤¾ à¤à¤ सà¥à¤ à¤à¤¾ à¤à¤ सà¤à¤à¤²à¤¨. शामिल...
compression => 1,
text_length => 0,
itxt_length => 580,
},
{
text_length => 0,
itxt_length => 103,
text => 'à¤à¤ NeXTstation "pnmtopng \'à¤à¤¾ à¤à¤ªà¤¯à¥à¤ à¤à¤° रà¤à¤ पर बनाया à¤à¤¯à¤¾.',
lang_key => 'सà¥à¤«à¥à¤à¤µà¥à¤¯à¤°',
compression => 1,
lang => 'hi',
key => 'Software',
},
{
lang => 'hi',
text_length => 0,
itxt_length => 25,
lang_key => 'à¤
सà¥à¤µà¥à¤à¤°à¤£',
compression => 1,
text => 'फà¥à¤°à¥à¤µà¥à¤¯à¤°.',
key => 'Disclaimer',
},
],
},
{
file => 'ctjn0g04',
comment => 'japanese',
chunks => [
{
key => 'Title',
itxt_length => 8,
text_length => 0,
text => 'PngSuite',
lang_key => 'ã¿ã¤ãã«',
compression => 1,
lang => 'ja',
},
{
key => 'Author',
compression => 1,
lang_key => 'èè
',
text => 'Willem van Schaik (willem@schaik.com)',
itxt_length => 37,
text_length => 0,
lang => 'ja',
},
{
lang => 'ja',
itxt_length => 58,
text_length => 0,
text => 'è使¨©ã¦ã£ã¬ã ã´ã¡ã³ã·ã£ã¤ã¯ãã«ãã2011',
lang_key => 'æ¬æã¸',
compression => 1,
key => 'Copyright',
},
{
lang_key => 'æ¦è¦',
text => 'PNGå½¢å¼ã®æ§ã
ãªè²ã®ç¨®é¡ããã¹ãããããã«ä½æãããã¤ã¡ã¼ã¸ã®ã»ããã®ã³ã³ãã¤ã«ãå«ã¾ãã¦ããã®ã¯éæåº¦ã®ãã©ã¼ãããã§ãã¢ã«ãã¡ãã£ãã«ãæã¤ãç½é»ãã«ã©ã¼ããã...
compression => 1,
itxt_length => 351,
text_length => 0,
lang => 'ja',
key => 'Description',
},
{
lang => 'ja',
text => '"pnmtopng"ã使ç¨ãã¦NeXTstationè²ä¸ã«ä½æããã¾ãã',
lang_key => 'ã½ããã¦ã§ã¢',
compression => 1,
itxt_length => 66,
text_length => 0,
key => 'Software',
},
{
itxt_length => 21,
text_length => 0,
lang_key => 'å
責äºé
',
text => 'ããªã¼ã¦ã§ã¢ã',
compression => 1,
lang => 'ja',
key => 'Disclaimer',
},
],
},
);
# There are some instances of libpngs which return 2
# (PNG_ITXT_COMPRESSION_zTXt) for the text compression. However, this
# does not occur in any of the examples, so it seems like there must
# be a faulty libpng.
for my $test (@stuff) {
my $png = read_png_file ("$Bin/libpng/$test->{file}.png");
( run in 1.083 second using v1.01-cache-2.11-cpan-ceb78f64989 )