add page-height to pdfload

This commit is contained in:
John Cupitt 2016-11-23 22:11:26 +00:00
parent 25dd60c781
commit 8c84e6cc34
3 changed files with 52 additions and 1 deletions

38
TODO
View File

@ -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

View File

@ -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

View File

@ -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 );