@@ -289,8 +289,7 @@ vips_foreign_save_heif_write_page(VipsForeignSaveHeif *heif, int page)
289
289
#endif /*HAVE_HEIF_COLOR_PROFILE*/
290
290
291
291
options = heif_encoding_options_alloc ();
292
- if (vips_image_hasalpha (save -> ready ))
293
- options -> save_alpha_channel = 1 ;
292
+ options -> save_alpha_channel = save -> ready -> Bands > 3 ;
294
293
295
294
#ifdef HAVE_HEIF_ENCODING_OPTIONS_OUTPUT_NCLX_PROFILE
296
295
/* Matrix coefficients have to be identity (CICP x/y/0) in lossless
@@ -517,6 +516,7 @@ vips_foreign_save_heif_build(VipsObject *object)
517
516
char * chroma ;
518
517
const struct heif_encoder_descriptor * out_encoder ;
519
518
const struct heif_encoder_parameter * const * param ;
519
+ gboolean has_alpha ;
520
520
521
521
if (VIPS_OBJECT_CLASS (vips_foreign_save_heif_parent_class )-> build (object ))
522
522
return -1 ;
@@ -677,34 +677,25 @@ vips_foreign_save_heif_build(VipsObject *object)
677
677
heif -> page_width = save -> ready -> Xsize ;
678
678
heif -> page_height = vips_image_get_page_height (save -> ready );
679
679
heif -> n_pages = save -> ready -> Ysize / heif -> page_height ;
680
+ has_alpha = save -> ready -> Bands > 3 ;
680
681
681
682
if (heif -> page_width > 16384 || heif -> page_height > 16384 ) {
682
683
vips_error ("heifsave" , _ ("image too large" ));
683
684
return -1 ;
684
685
}
685
686
686
- /* Reject multiband images.
687
- */
688
- if (save -> ready -> Type == VIPS_INTERPRETATION_MULTIBAND ) {
689
- vips_error ("heifsave" , _ ("Unsupported interpretation: %s" ),
690
- vips_enum_nick (VIPS_TYPE_INTERPRETATION ,
691
- save -> ready -> Type ));
692
- return -1 ;
693
- }
694
-
695
687
/* Make a heif image the size of a page. We send sink_disc() output
696
688
* here and write a frame each time it fills.
697
689
*/
698
690
#ifdef DEBUG
699
691
printf ("vips_foreign_save_heif_build:\n" );
700
692
printf ("\twidth = %d\n" , heif -> page_width );
701
693
printf ("\theight = %d\n" , heif -> page_height );
702
- printf ("\talpha = %d\n" , vips_image_hasalpha ( save -> ready ) );
694
+ printf ("\talpha = %d\n" , has_alpha );
703
695
#endif /*DEBUG*/
704
696
error = heif_image_create (heif -> page_width , heif -> page_height ,
705
697
heif_colorspace_RGB ,
706
- vips__heif_chroma (heif -> bitdepth ,
707
- vips_image_hasalpha (save -> ready )),
698
+ vips__heif_chroma (heif -> bitdepth , has_alpha ),
708
699
& heif -> img );
709
700
if (error .code ) {
710
701
vips__heif_error (& error );
0 commit comments