larger strip size for pdfload

We had 128-pixel high strips for pdfload. This kept mem use very low,
but meant many calls to page_render. For a tall page with an image
background, we could take almost an hour to render a single page as the
background was repeatedly repainted.

Change the strip height to 5000. This will render most pages in a single
call, but still allow huge images.

See https://github.com/jcupitt/libvips/issues/681
This commit is contained in:
John Cupitt 2017-06-28 09:16:06 +01:00
parent 47f35dd2f1
commit 61d5ba7b58

View File

@ -6,6 +6,8 @@
* - add @n ... number of pages to load
* 23/11/16
* - set page-height, if we can
* 28/6/17
* - use a much larger strip size, thanks bubba
*/
/*
@ -339,10 +341,10 @@ vips_foreign_load_pdf_generate( VipsRegion *or,
int y;
/*
*/
printf( "vips_foreign_load_pdf_generate: "
"left = %d, top = %d, width = %d, height = %d\n",
r->left, r->top, r->width, r->height );
*/
/* Poppler won't always paint the background. Use 255 (white) for the
* bg, PDFs generally assume a paper backgrocund colour.
@ -408,19 +410,10 @@ vips_foreign_load_pdf_load( VipsForeignLoad *load )
VipsImage **t = (VipsImage **)
vips_object_local_array( (VipsObject *) load, 2 );
int tile_width;
int tile_height;
int n_lines;
#ifdef DEBUG
printf( "vips_foreign_load_pdf_load: %p\n", pdf );
#endif /*DEBUG*/
/* Use this to pick a tile height for our strip cache.
*/
vips_get_tile_size( load->real,
&tile_width, &tile_height, &n_lines );
/* Read to this image, then cache to out, see below.
*/
t[0] = vips_image_new();
@ -432,10 +425,11 @@ vips_foreign_load_pdf_load( VipsForeignLoad *load )
/* Don't use tilecache to keep the number of calls to
* pdf_page_render() low. Don't thread the cache, we rely on
* locking to keep pdf single-threaded.
* locking to keep pdf single-threaded. Use a large strip size to
* (again) keep the number of calls to page_render low.
*/
if( vips_linecache( t[0], &t[1],
"tile_height", tile_height,
"tile_height", 5000,
NULL ) )
return( -1 );
if( vips_image_write( t[1], load->real ) )