diff --git a/ChangeLog b/ChangeLog index 804f7d95..972bb588 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ - vips_resize() and vips_similarity() use it when they can - bicubic is better on 32-bit int images - add pdfload for PDF rendering ... file and buffer input are supported +- vipsthumbnail knows about pdfload 27/1/16 started 8.2.3 - fix a crash with SPARC byte-order labq vips images diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index f098b8a2..c7d8a58a 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -2863,12 +2863,13 @@ vips_matload( const char *filename, VipsImage **out, ... ) * @dpi: %gdouble, render at this DPI * @scale: %gdouble, scale render by this factor * - * Render a PDF file into a VIPS image. + * Render a PDF file into a VIPS image. Rendering uses the libpoppler library + * and should be fast. * * Use @page to select a page to render, numbering from zero. * * Use @dpi to set the rendering resolution. The default is 72. Alternatively, - * you can scale the rendering by @scale. + * you can scale the rendering from the default 1 point == 1 pixel by @scale. * * The operation fills a number of header fields with metadata, for example * "pdf-author". They may be useful. diff --git a/tools/vipsthumbnail.c b/tools/vipsthumbnail.c index a3164942..1720dbb4 100644 --- a/tools/vipsthumbnail.c +++ b/tools/vipsthumbnail.c @@ -70,6 +70,8 @@ * - premultiply alpha * 30/7/15 * - warn if you autorot and there's no exif support + * 9/2/16 + * - add PDF --size support */ #ifdef HAVE_CONFIG_H @@ -274,8 +276,34 @@ thumbnail_open( VipsObject *process, const char *filename ) NULL )) ) return( NULL ); } + else if( strcmp( loader, "VipsForeignLoadPdfFile" ) == 0 ) { + double shrink; + + /* This will just read in the header and is quick. + */ + if( !(im = vips_image_new_from_file( filename, NULL )) ) + return( NULL ); + + shrink = calculate_shrink( im ); + + g_object_unref( im ); + + vips_info( "vipsthumbnail", + "loading PDF with factor %g pre-shrink", + shrink ); + + /* We can't use UNBUFERRED safely on very-many-core systems. + */ + if( !(im = vips_image_new_from_file( filename, + "access", VIPS_ACCESS_SEQUENTIAL, + "scale", 1.0 / shrink, + NULL )) ) + return( NULL ); + + } else { - /* All other formats. + /* All other formats. We can't use UNBUFERRED safely on + * very-many-core systems. */ if( !(im = vips_image_new_from_file( filename, "access", VIPS_ACCESS_SEQUENTIAL,