start trying to fix autorotate for heif images

This commit is contained in:
John Cupitt 2019-03-05 15:35:58 +00:00
parent 27f1d28b61
commit f209870e7b
2 changed files with 23 additions and 12 deletions

View File

@ -32,9 +32,10 @@
*/
/*
#define DEBUG_VERBOSE
*/
#define VIPS_DEBUG
#define DEBUG
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
@ -323,27 +324,29 @@ vips_foreign_load_heif_set_header( VipsForeignLoadHeif *heif, VipsImage *out )
enum heif_color_profile_type profile_type =
heif_image_handle_get_color_profile_type( heif->handle );
printf( "profile type = " );
switch( profile_type ) {
case heif_color_profile_type_not_present:
printf( "no profile\n" );
printf( "none" );
break;
case heif_color_profile_type_nclx:
printf( "nclx profile\n" );
printf( "nclx" );
break;
case heif_color_profile_type_rICC:
printf( "rICC profile\n" );
printf( "rICC" );
break;
case heif_color_profile_type_prof:
printf( "prof profile\n" );
printf( "prof" );
break;
default:
printf( "unknown profile type\n" );
printf( "unknown" );
break;
}
printf( "\n" );
}
#endif /*DEBUG*/
@ -383,8 +386,12 @@ vips_foreign_load_heif_set_header( VipsForeignLoadHeif *heif, VipsImage *out )
#ifdef HAVE_EXIF
if( !heif->autorotate ) {
if( angle == VIPS_ANGLE_D90 ||
angle == VIPS_ANGLE_D270 )
angle == VIPS_ANGLE_D270 ) {
#ifdef DEBUG
printf( "swapping width/height\n" );
#endif /*DEBUG*/
VIPS_SWAP( int, image_page_width, image_page_height );
}
}
else
vips_autorot_remove_angle( out );
@ -894,6 +901,7 @@ vips_foreign_load_heif_buffer_init( VipsForeignLoadHeifBuffer *buffer )
* * @page: %gint, page (top-level image number) to read
* * @n: %gint, load this many pages
* * @autorotate: %gboolean, apply image transformations
* * @thumbnail: %gboolean, fetch thumbnail instead of image
*
* Read a HEIF image file into a VIPS image.
*
@ -907,9 +915,12 @@ vips_foreign_load_heif_buffer_init( VipsForeignLoadHeifBuffer *buffer )
* HEIF images have a primary image. The metadata item `heif-primary` gives
* the page number of the primary.
*
* HEIF images can have trsnaformations like rotate, flip and crop stored in
* HEIF images can have transformations like rotate, flip and crop stored in
* the header. Set @autorotate %TRUE to apply these during load.
*
* If @thumbnail is %TRUE, then fetch a stored thumbnail rather than the
* image.
*
* See also: vips_image_new_from_file().
*
* Returns: 0 on success, -1 on error.
@ -939,10 +950,10 @@ vips_heifload( const char *filename, VipsImage **out, ... )
* * @page: %gint, page (top-level image number) to read
* * @n: %gint, load this many pages
* * @autorotate: %gboolean, apply image transformations
* * @thumbnail: %gboolean, fetch thumbnail instead of image
*
* Read a HEIF image file into a VIPS image.
* Exactly as
* vips_heifload(), but read from a memory buffer.
* Exactly as vips_heifload(), but read from a memory buffer.
*
* You must not free the buffer while @out is active. The
* #VipsObject::postclose signal on @out is a good place to free.

View File

@ -836,8 +836,8 @@ class TestForeign:
def heif_valid(im):
a = im(10, 10)
assert_almost_equal_objects(a, [75.0, 86.0, 81.0])
assert im.width == 4032
assert im.height == 3024
assert im.width == 3024
assert im.height == 4032
assert im.bands == 3
self.file_loader("heifload", HEIC_FILE, heif_valid)