Permalink
Browse files

move TIFF into its own module

  • Loading branch information...
Tony Cook
Tony Cook committed Aug 25, 2010
1 parent 4922fb3 commit e5ee047bfc7249dc1393e2f9df5d1370a363c604
Showing with 927 additions and 394 deletions.
  1. +1 −1 Changes
  2. +4 −66 Imager.pm
  3. +0 −138 Imager.xs
  4. +33 −25 MANIFEST
  5. +81 −81 Makefile.PL
  6. +136 −0 TIFF/Makefile.PL
  7. +141 −0 TIFF/TIFF.pm
  8. +145 −0 TIFF/TIFF.xs
  9. +20 −25 tiff.c → TIFF/imtiff.c
  10. +15 −0 TIFF/imtiff.h
  11. +17 −17 t/t106tiff.t → TIFF/t/t10tiff.t
  12. BIN { → TIFF}/testimg/alpha.tif
  13. BIN TIFF/testimg/comp4.bmp
  14. BIN { → TIFF}/testimg/comp4.tif
  15. BIN { → TIFF}/testimg/comp4bad.tif
  16. BIN { → TIFF}/testimg/comp4t.tif
  17. BIN TIFF/testimg/comp8.bmp
  18. BIN { → TIFF}/testimg/comp8.tif
  19. BIN { → TIFF}/testimg/gralpha.tif
  20. BIN { → TIFF}/testimg/grey16.tif
  21. BIN { → TIFF}/testimg/grey32.tif
  22. BIN TIFF/testimg/imager.pbm
  23. BIN { → TIFF}/testimg/imager.tif
  24. BIN { → TIFF}/testimg/pengtile.tif
  25. +279 −0 TIFF/testimg/penguin-base.ppm
  26. BIN { → TIFF}/testimg/rgb16.tif
  27. BIN { → TIFF}/testimg/rgb16t.tif
  28. BIN { → TIFF}/testimg/rgbatsep.tif
  29. BIN { → TIFF}/testimg/scmyk.tif
  30. BIN { → TIFF}/testimg/scmyka.tif
  31. BIN { → TIFF}/testimg/scmyka16.tif
  32. BIN { → TIFF}/testimg/scmykaa.tif
  33. BIN { → TIFF}/testimg/slab.tif
  34. BIN { → TIFF}/testimg/srgb.tif
  35. BIN { → TIFF}/testimg/srgba.tif
  36. BIN { → TIFF}/testimg/srgba16.tif
  37. BIN { → TIFF}/testimg/srgba32.tif
  38. BIN { → TIFF}/testimg/srgbaa.tif
  39. BIN { → TIFF}/testimg/tiffwarn.tif
  40. +7 −4 image.c
  41. +0 −33 imager.h
  42. +3 −0 imext.c
  43. +7 −0 imext.h
  44. +5 −1 imexttypes.h
  45. +30 −0 lib/Imager/APIRef.pod
  46. +1 −1 t/t106notiff.t
  47. +1 −1 t/t50basicoo.t
  48. +1 −1 t/x11rubthru.t
View
@@ -8,7 +8,7 @@ Imager 0.78 - unreleased
Thanks to Justin Davis.
https://rt.cpan.org/Ticket/Display.html?id=60491
- - moved the GIF file handling code into a sub-module in preparation
+ - moved GIF, TIFF file handling code into sub-modules in preparation
for separate distribution.
https://rt.cpan.org/Ticket/Display.html?id=49616 (partial)
View
@@ -77,10 +77,6 @@ use Imager::Font;
i_readjpeg_wiol
i_writejpeg_wiol
- i_readtiff_wiol
- i_writetiff_wiol
- i_writetiff_wiol_faxable
-
i_readpnm_wiol
i_writeppm_wiol
@@ -1385,17 +1381,6 @@ sub read {
my $allow_incomplete = $input{allow_incomplete};
defined $allow_incomplete or $allow_incomplete = 0;
- if ( $input{'type'} eq 'tiff' ) {
- my $page = $input{'page'};
- defined $page or $page = 0;
- $self->{IMG}=i_readtiff_wiol( $IO, $allow_incomplete, $page );
- if ( !defined($self->{IMG}) ) {
- $self->{ERRSTR}=$self->_error_as_msg(); return undef;
- }
- $self->{DEBUG} && print "loading a tiff file\n";
- return $self;
- }
-
if ( $input{'type'} eq 'pnm' ) {
$self->{IMG}=i_readpnm_wiol( $IO, $allow_incomplete );
if ( !defined($self->{IMG}) ) {
@@ -1758,24 +1743,7 @@ sub write {
($IO, $fh) = $self->_get_writer_io(\%input, $input{'type'})
or return undef;
- if ($input{'type'} eq 'tiff') {
- $self->_set_opts(\%input, "tiff_", $self)
- or return undef;
- $self->_set_opts(\%input, "exif_", $self)
- or return undef;
-
- if (defined $input{class} && $input{class} eq 'fax') {
- if (!i_writetiff_wiol_faxable($self->{IMG}, $IO, $input{fax_fine})) {
- $self->{ERRSTR} = $self->_error_as_msg();
- return undef;
- }
- } else {
- if (!i_writetiff_wiol($self->{IMG}, $IO)) {
- $self->{ERRSTR} = $self->_error_as_msg();
- return undef;
- }
- }
- } elsif ( $input{'type'} eq 'pnm' ) {
+ if ( $input{'type'} eq 'pnm' ) {
$self->_set_opts(\%input, "pnm_", $self)
or return undef;
if ( ! i_writeppm_wiol($self->{IMG},$IO) ) {
@@ -1791,14 +1759,6 @@ sub write {
return undef;
}
$self->{DEBUG} && print "writing a raw file\n";
- } elsif ( $input{'type'} eq 'png' ) {
- $self->_set_opts(\%input, "png_", $self)
- or return undef;
- if ( !i_writepng_wiol($self->{IMG}, $IO) ) {
- $self->{ERRSTR}='unable to write png image';
- return undef;
- }
- $self->{DEBUG} && print "writing a png file\n";
} elsif ( $input{'type'} eq 'jpeg' ) {
$self->_set_opts(\%input, "jpeg_", $self)
or return undef;
@@ -1899,23 +1859,7 @@ sub write_multi {
($IO, $file) = $class->_get_writer_io($opts, $type)
or return undef;
- if ($type eq 'tiff') {
- $class->_set_opts($opts, "tiff_", @images)
- or return;
- $class->_set_opts($opts, "exif_", @images)
- or return;
- my $res;
- $opts->{fax_fine} = 1 unless exists $opts->{fax_fine};
- if ($opts->{'class'} && $opts->{'class'} eq 'fax') {
- $res = i_writetiff_multi_wiol_faxable($IO, $opts->{fax_fine}, @work);
- }
- else {
- $res = i_writetiff_multi_wiol($IO, @work);
- }
- unless ($res) {
- $class->_set_error($class->_error_as_msg());
- return undef;
- }
+ if (0) { # eventually PNM in here, now that TIFF/GIF are elsewhere
}
else {
if (@images == 1) {
@@ -1975,14 +1919,8 @@ sub read_multi {
return;
}
- my @imgs;
- if ($type eq 'gif') {
- @imgs = i_readgif_multi_wiol($IO);
- }
- elsif ($type eq 'tiff') {
- @imgs = i_readtiff_multi_wiol($IO, -1);
- }
- elsif ($type eq 'pnm') {
+ my @imgs;
+ if ($type eq 'pnm') {
@imgs = i_readpnm_multi_wiol($IO, $opts{allow_incomplete}||0);
}
else {
View
138 Imager.xs
@@ -559,9 +559,7 @@ static struct value_name make_color_names[] =
static struct value_name translate_names[] =
{
-#ifdef HAVE_LIBGIF
{ "giflib", pt_giflib, },
-#endif
{ "closest", pt_closest, },
{ "perturb", pt_perturb, },
{ "errdiff", pt_errdiff, },
@@ -2383,142 +2381,6 @@ i_test_format_probe(ig, length)
-#ifdef HAVE_LIBTIFF
-
-Imager::ImgRaw
-i_readtiff_wiol(ig, allow_incomplete, page=0)
- Imager::IO ig
- int allow_incomplete
- int page
-
-void
-i_readtiff_multi_wiol(ig, length)
- Imager::IO ig
- int length
- PREINIT:
- i_img **imgs;
- int count;
- int i;
- PPCODE:
- imgs = i_readtiff_multi_wiol(ig, length, &count);
- if (imgs) {
- EXTEND(SP, count);
- for (i = 0; i < count; ++i) {
- SV *sv = sv_newmortal();
- sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
- PUSHs(sv);
- }
- myfree(imgs);
- }
-
-
-undef_int
-i_writetiff_wiol(im, ig)
- Imager::ImgRaw im
- Imager::IO ig
-
-undef_int
-i_writetiff_multi_wiol(ig, ...)
- Imager::IO ig
- PREINIT:
- int i;
- int img_count;
- i_img **imgs;
- CODE:
- if (items < 2)
- croak("Usage: i_writetiff_multi_wiol(ig, images...)");
- img_count = items - 1;
- RETVAL = 1;
- if (img_count < 1) {
- RETVAL = 0;
- i_clear_error();
- i_push_error(0, "You need to specify images to save");
- }
- else {
- imgs = mymalloc(sizeof(i_img *) * img_count);
- for (i = 0; i < img_count; ++i) {
- SV *sv = ST(1+i);
- imgs[i] = NULL;
- if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
- imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
- }
- else {
- i_clear_error();
- i_push_error(0, "Only images can be saved");
- myfree(imgs);
- RETVAL = 0;
- break;
- }
- }
- if (RETVAL) {
- RETVAL = i_writetiff_multi_wiol(ig, imgs, img_count);
- }
- myfree(imgs);
- }
- OUTPUT:
- RETVAL
-
-undef_int
-i_writetiff_wiol_faxable(im, ig, fine)
- Imager::ImgRaw im
- Imager::IO ig
- int fine
-
-undef_int
-i_writetiff_multi_wiol_faxable(ig, fine, ...)
- Imager::IO ig
- int fine
- PREINIT:
- int i;
- int img_count;
- i_img **imgs;
- CODE:
- if (items < 3)
- croak("Usage: i_writetiff_multi_wiol_faxable(ig, fine, images...)");
- img_count = items - 2;
- RETVAL = 1;
- if (img_count < 1) {
- RETVAL = 0;
- i_clear_error();
- i_push_error(0, "You need to specify images to save");
- }
- else {
- imgs = mymalloc(sizeof(i_img *) * img_count);
- for (i = 0; i < img_count; ++i) {
- SV *sv = ST(2+i);
- imgs[i] = NULL;
- if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
- imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
- }
- else {
- i_clear_error();
- i_push_error(0, "Only images can be saved");
- myfree(imgs);
- RETVAL = 0;
- break;
- }
- }
- if (RETVAL) {
- RETVAL = i_writetiff_multi_wiol_faxable(ig, imgs, img_count, fine);
- }
- myfree(imgs);
- }
- OUTPUT:
- RETVAL
-
-const char *
-i_tiff_libversion()
-
-bool
-i_tiff_has_compression(name)
- const char *name
-
-#endif /* HAVE_LIBTIFF */
-
-
-#ifdef HAVE_LIBPNG
-
-#endif
View
@@ -98,6 +98,39 @@ SGI/testimg/verb.rgb
SGI/testimg/verb12.rgb
SGI/testimg/verb16.rgb
SGI/testimg/verb6.rgb
+TIFF/Makefile.PL
+TIFF/TIFF.pm
+TIFF/TIFF.xs
+TIFF/imtiff.c
+TIFF/imtiff.h
+TIFF/testimg/alpha.tif Alpha scaling test image
+TIFF/testimg/comp4.bmp Compressed 4-bit/pixel BMP
+TIFF/testimg/comp4.tif 4-bit/pixel paletted TIFF
+TIFF/testimg/comp4bad.tif corrupted 4-bit/pixel paletted TIFF
+TIFF/testimg/comp4t.tif 4-bit/pixel paletted TIFF (tiled)
+TIFF/testimg/comp8.bmp Compressed 8-bit/pixel BMP
+TIFF/testimg/comp8.tif 8-bit/pixel paletted TIFF
+TIFF/testimg/gralpha.tif Grey alpha test image
+TIFF/testimg/grey16.tif 16-bit/sample greyscale TIFF
+TIFF/testimg/grey32.tif 32-bit/sample greyscale+alpha TIFF
+TIFF/testimg/imager.pbm Test bi-level
+TIFF/testimg/imager.tif Test bi-level
+TIFF/testimg/penguin-base.ppm
+TIFF/testimg/pengtile.tif Tiled tiff image, same as penguin-base.ppm
+TIFF/testimg/rgb16.tif 16-bit/sample RGB image - strips
+TIFF/testimg/rgb16t.tif 16-bit/sample RGB image - tiled
+TIFF/testimg/rgbatsep.tif Tiled/separated for testing RGBA codepath
+TIFF/testimg/scmyk.tif Simple CMYK TIFF image
+TIFF/testimg/scmyka.tif CMYK with one alpha channel
+TIFF/testimg/scmyka16.tif CMYK with one alpha channel (16-bit)
+TIFF/testimg/scmykaa.tif CMYK with 2 alpha channels
+TIFF/testimg/slab.tif Lab color image
+TIFF/testimg/srgb.tif Simple RGB image
+TIFF/testimg/srgba.tif RGB with one alpha
+TIFF/testimg/srgba16.tif
+TIFF/testimg/srgba32.tif
+TIFF/testimg/srgbaa.tif RGB with 2 alpha
+TIFF/testimg/tiffwarn.tif Generates a warning while being read
apidocs.perl Build lib/Imager/APIRef.pm
bigtest.perl Library selection tester
bmp.c Reading and writing Windows BMP files
@@ -311,7 +344,6 @@ t/tr18561.t Regression tests
t/tr18561b.t
tags.c
testimg/209_yonge.jpg Regression test: #17981
-testimg/alpha.tif Alpha scaling test image
testimg/alpha16.tga 16-bit/pixel TGA with alpha "channel" RT 32926
testimg/bad1oflow.bmp 1-bit/pixel, overflow integer on 32-bit machines
testimg/bad1wid0.bmp 1-bit/pixel, zero width
@@ -337,18 +369,10 @@ testimg/bad_asc.pgm ASCII PGM with invalid image data
testimg/bad_asc.ppm ASCII PPM with invalid image data
testimg/base.jpg Base JPEG test image
testimg/comp4.bmp Compressed 4-bit/pixel BMP
-testimg/comp4.tif 4-bit/pixel paletted TIFF
-testimg/comp4bad.tif corrupted 4-bit/pixel paletted TIFF
-testimg/comp4t.tif 4-bit/pixel paletted TIFF (tiled)
testimg/comp8.bmp Compressed 8-bit/pixel BMP
-testimg/comp8.tif 8-bit/pixel paletted TIFF
testimg/exiftest.jpg Test image for EXIF parsing
testimg/gimpgrad A GIMP gradient file
-testimg/gralpha.tif Grey alpha test image
-testimg/grey16.tif 16-bit/sample greyscale TIFF
-testimg/grey32.tif 32-bit/sample greyscale+alpha TIFF
testimg/imager.pbm Test bi-level
-testimg/imager.tif Test bi-level
testimg/junk.ppm
testimg/longid.tga Test TGA with a long id string
testimg/maxval.ppm For ppm file maxval handling
@@ -360,17 +384,9 @@ testimg/maxval_asc.ppm
testimg/multiple.ppm Test multiple PPM reading
testimg/newgimpgrad.ggr Test GIMP Gradient file (newer type)
testimg/penguin-base.ppm
-testimg/pengtile.tif Tiled tiff image, same as penguin-base.ppm
testimg/pgm.pgm Simple pgm for testing the right sample is in the right place
-testimg/rgb16.tif 16-bit/sample RGB image - strips
-testimg/rgb16t.tif 16-bit/sample RGB image - tiled
-testimg/rgbatsep.tif Tiled/separated for testing RGBA codepath
testimg/scale.ppm
-testimg/scmyk.tif Simple CMYK TIFF image
testimg/scmyk.jpg Simple CMYK JPEG image
-testimg/scmyka.tif CMYK with one alpha channel
-testimg/scmyka16.tif CMYK with one alpha channel (16-bit)
-testimg/scmykaa.tif CMYK with 2 alpha channels
testimg/short1.bmp 1-bit/pixel, data missing from EOF
testimg/short24.bmp 24-bit/pixel, data missing from EOF
testimg/short4.bmp truncated 4bit/pixel uncompressed BMP
@@ -386,17 +402,10 @@ testimg/short_bin.ppm Bin PPM with short image section
testimg/short_bin16.pgm 16-bit Bin PGM with short image section
testimg/short_bin16.ppm 16-bit Bin PPM with short image section
testimg/simple.pbm
-testimg/slab.tif Lab color image
-testimg/srgb.tif Simple RGB image
-testimg/srgba.tif RGB with one alpha
-testimg/srgba16.tif
-testimg/srgba32.tif
-testimg/srgbaa.tif RGB with 2 alpha
testimg/test.png Standard test image as PNG
testimg/test.raw Standard test image as RAW
testimg/test.tga Standard test image as TGA
testimg/test_gimp_pal A simple GIMP palette file
-testimg/tiffwarn.tif Generates a warning while being read
testimg/winrgb2.bmp 1-bit bmp base
testimg/winrgb24.bmp 24-bit bmp base
testimg/winrgb24off.bmp 24-bit bmp with image data offset from header
@@ -407,7 +416,6 @@ testimg/winrgb8.bmp 8-bit bmp base
testimg/winrgb8off.bmp 8-bit bmp with image data offset from header
testimg/zerotype.jpg Image with a zero type entry in the EXIF data
tga.c Reading and writing Targa files
-tiff.c
trans2.c
transform.perl Shell interface to Imager::Transform
typemap
Oops, something went wrong.

0 comments on commit e5ee047

Please sign in to comment.