Set page height only for multi-page images (#2506)

This commit is contained in:
Kleis Auke Wolthuizen 2021-11-01 17:55:37 +01:00 committed by GitHub
parent e412d5bdf0
commit 9c1003fbe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 5 deletions

View File

@ -605,8 +605,12 @@ vips_foreign_load_heif_set_header( VipsForeignLoadHeif *heif, VipsImage *out )
#endif /*HAVE_HEIF_COLOR_PROFILE*/
vips_image_set_int( out, "heif-primary", heif->primary_page );
vips_image_set_int( out, "n-pages", heif->n_top );
if( vips_object_argument_isset( VIPS_OBJECT( heif ), "n" ) )
vips_image_set_int( out, VIPS_META_N_PAGES, heif->n_top );
/* Only set page-height if we have more than one page, or this could
* accidentally turn into an animated image later.
*/
if( heif->n > 1 )
vips_image_set_int( out,
VIPS_META_PAGE_HEIGHT, heif->page_height );

View File

@ -299,7 +299,10 @@ vips_foreign_load_nsgif_set_header( VipsForeignLoadNsgif *gif,
VIPS_INTERPRETATION_sRGB, 1.0, 1.0 );
vips_image_pipelinev( image, VIPS_DEMAND_STYLE_FATSTRIP, NULL );
if( vips_object_argument_isset( VIPS_OBJECT( gif ), "n" ) )
/* Only set page-height if we have more than one page, or this could
* accidentally turn into an animated image later.
*/
if( gif->n > 1 )
vips_image_set_int( image,
VIPS_META_PAGE_HEIGHT, gif->anim->height );
vips_image_set_int( image, VIPS_META_N_PAGES,

View File

@ -488,7 +488,11 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load )
for( i = 1; i < pdf->n; i++ )
if( pdf->pages[i].height != pdf->pages[0].height )
break;
if( vips_object_argument_isset( VIPS_OBJECT( pdf ), "n" ) )
/* Only set page-height if we have more than one page, or this could
* accidentally turn into an animated image later.
*/
if( pdf->n > 1 )
vips_image_set_int( load->out,
VIPS_META_PAGE_HEIGHT, pdf->pages[0].height );

View File

@ -361,7 +361,11 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load )
for( i = 1; i < pdf->n; i++ )
if( pdf->pages[i].height != pdf->pages[0].height )
break;
if( vips_object_argument_isset( VIPS_OBJECT( pdf ), "n" ) )
/* Only set page-height if we have more than one page, or this could
* accidentally turn into an animated image later.
*/
if( pdf->n > 1 )
vips_image_set_int( load->out,
VIPS_META_PAGE_HEIGHT, pdf->pages[0].height );