From 3f1eb2c7dd467ad9ee8843e156459479f2cc02ac Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 6 Oct 2019 18:27:40 +0100 Subject: [PATCH] test pdfload in te new desc tester and fix a couple of small issues --- libvips/foreign/pdfload.c | 19 ++++++++++--------- test/test_descriptors.sh | 4 ++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/libvips/foreign/pdfload.c b/libvips/foreign/pdfload.c index 4675e216..82cb0329 100644 --- a/libvips/foreign/pdfload.c +++ b/libvips/foreign/pdfload.c @@ -185,7 +185,8 @@ vips_foreign_load_pdf_get_flags( VipsForeignLoad *load ) static int vips_foreign_load_pdf_get_page( VipsForeignLoadPdf *pdf, int page_no ) { - if( pdf->current_page != page_no ) { + if( pdf->current_page != page_no || + !pdf->page ) { VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( pdf ); VIPS_UNREF( pdf->page ); @@ -356,24 +357,20 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load ) VIPS_AREA( pdf->background )->n )) ) return( -1 ); + pdf_class->close( pdf ); + return( 0 ); } static void vips_foreign_load_pdf_minimise( VipsObject *object, VipsForeignLoadPdf *pdf ) { + VipsForeignLoadPdfClass *class = VIPS_FOREIGN_LOAD_PDF_GET_CLASS( pdf ); #ifdef DEBUG printf( "vips_foreign_load_pdf_minimise: %p\n", pdf ); #endif /*DEBUG*/ - /* In seq mode, we can shut down the input at the end of computation. - */ - if( VIPS_FOREIGN_LOAD( pdf )->access == VIPS_ACCESS_SEQUENTIAL ) { - VipsForeignLoadPdfClass *class = - VIPS_FOREIGN_LOAD_PDF_GET_CLASS( pdf ); - - class->close( pdf ); - } + class->close( pdf ); } static int @@ -459,6 +456,7 @@ static int vips_foreign_load_pdf_load( VipsForeignLoad *load ) { VipsForeignLoadPdf *pdf = VIPS_FOREIGN_LOAD_PDF( load ); + VipsForeignLoadPdfClass *class = VIPS_FOREIGN_LOAD_PDF_GET_CLASS( pdf ); VipsImage **t = (VipsImage **) vips_object_local_array( (VipsObject *) load, 2 ); @@ -466,6 +464,9 @@ vips_foreign_load_pdf_load( VipsForeignLoad *load ) printf( "vips_foreign_load_pdf_load: %p\n", pdf ); #endif /*DEBUG*/ + if( class->open( pdf ) ) + return( -1 ); + /* Read to this image, then cache to out, see below. */ t[0] = vips_image_new(); diff --git a/test/test_descriptors.sh b/test/test_descriptors.sh index 648d714e..02be52dd 100755 --- a/test/test_descriptors.sh +++ b/test/test_descriptors.sh @@ -19,3 +19,7 @@ fi if test_supported gifload; then ./test_descriptors $test_images/cogs.gif fi + +if test_supported pdfload; then + ./test_descriptors $test_images/ISO_12233-reschart.pdf +fi