diff --git a/TODO b/TODO index f99c9889..e2e3d930 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,42 @@ - all toilet roll loaders need to set "page-height" - magick, pdf and tiff need to use the same page/n interface + magick, pdf, gif and tiff need to use the same page/n interface + + magick: has page and all_frames + + deprecate all_frames, add @n, make all_frames set n == -1 + + do we allow page + all_frames? + + need to check magick2vips.c and magick7load.c + + add page-height + + magick6 + + john@kiwi:~/pics$ vips magickload nipguide.pdf x.v --all-frames + john@kiwi:~/pics$ vipsheader x.v + x.v: 595x842 ushort, 2 bands, grey16, magickload + + argh + + magick7 + + $ vips magickload nipguide.pdf x.v --all-frames + $ vipsheader x.v + x.v: 595x48836 ushort, 4 bands, rgb16, magickload + + phew + + gifload has page, but no n + + add an n param + + add page-height + + pdfload has page, n, allows n == -1, sets page-height + + diff --git a/libvips/foreign/magickload.c b/libvips/foreign/magickload.c index 9b5eb0db..ec94ec24 100644 --- a/libvips/foreign/magickload.c +++ b/libvips/foreign/magickload.c @@ -308,6 +308,7 @@ vips_foreign_load_magick_buffer_init( VipsForeignLoadMagickBuffer *buffer ) * Optional arguments: * * * @all_frames: %gboolean, load all frames in sequence + * * @page: %gint, load from this page * * @density: string, canvas resolution for rendering vector formats like SVG * * Read in an image using libMagick, the ImageMagick library. This library can @@ -355,6 +356,7 @@ vips_magickload( const char *filename, VipsImage **out, ... ) * Optional arguments: * * * @all_frames: %gboolean, load all frames in sequence + * * @page: %gint, load from this page * * @density: string, canvas resolution for rendering vector formats like SVG * * Read an image memory block using libMagick into a VIPS image. Exactly as diff --git a/libvips/foreign/pdfload.c b/libvips/foreign/pdfload.c index 7ab3907a..a32591c2 100644 --- a/libvips/foreign/pdfload.c +++ b/libvips/foreign/pdfload.c @@ -4,6 +4,8 @@ * - from openslideload.c * 12/5/16 * - add @n ... number of pages to load + * 23/11/16 + * - set page-height, if we can */ /* @@ -309,6 +311,17 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load ) top += pdf->pages[i].height; } + /* If all pages are the same size, we can tag this as a toilet roll + * image and tiffsave will be able to save it as a multipage tiff. + */ + for( i = 1; i < pdf->n; i++ ) + if( pdf->pages[i].width != pdf->pages[0].width || + pdf->pages[i].height != pdf->pages[0].height ) + break; + if( i == pdf->n ) + vips_image_set_int( load->out, + VIPS_META_PAGE_HEIGHT, pdf->pages[0].height ); + vips_foreign_load_pdf_set_image( pdf, load->out ); return( 0 );