Skip to content

Commit

Permalink
test pdfload in te new desc tester
Browse files Browse the repository at this point in the history
and fix a couple of small issues
  • Loading branch information
jcupitt committed Oct 6, 2019
1 parent 09b4ce6 commit 3f1eb2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 10 additions & 9 deletions libvips/foreign/pdfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -459,13 +456,17 @@ 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 );

#ifdef DEBUG
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();
Expand Down
4 changes: 4 additions & 0 deletions test/test_descriptors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3f1eb2c

Please sign in to comment.