From a88061dfec74c7d5368d065b89507d39b2fe5d89 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 3 Sep 2020 19:31:56 +0100 Subject: [PATCH] fix jpegload autorotate thanks chregu see https://github.com/libvips/php-vips/issues/105 --- ChangeLog | 1 + libvips/foreign/jpeg2vips.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 57a047ca..38a0a61e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ - ensure SVG loader skips input with chars outside x09-x7F range [lovell] - better mask sizing in gaussmat [johntrunc] - fix tiffsave "squash" handling [barryspearce] +- fix jpegload autorotate [chregu] 24/1/20 started 8.10.0 - more conformat IIIF output from dzsave [regisrob] diff --git a/libvips/foreign/jpeg2vips.c b/libvips/foreign/jpeg2vips.c index c1e87fd5..80964ecc 100644 --- a/libvips/foreign/jpeg2vips.c +++ b/libvips/foreign/jpeg2vips.c @@ -837,7 +837,7 @@ read_jpeg_image( ReadJpeg *jpeg, VipsImage *out ) { struct jpeg_decompress_struct *cinfo = &jpeg->cinfo; VipsImage **t = (VipsImage **) - vips_object_local_array( VIPS_OBJECT( out ), 4 ); + vips_object_local_array( VIPS_OBJECT( out ), 5 ); VipsImage *im; @@ -872,11 +872,13 @@ read_jpeg_image( ReadJpeg *jpeg, VipsImage *out ) if( jpeg->autorotate && vips_image_get_orientation( im ) != 1 ) { - /* This will go via a huge memory buffer :-( + /* We have to copy to memory before calling autorot, since it + * needs random access. */ - if( vips_autorot( im, &t[3], NULL ) ) + if( !(t[3] = vips_image_copy_memory( im )) || + vips_autorot( t[3], &t[4], NULL ) ) return( -1 ); - im = t[3]; + im = t[4]; } if( vips_image_write( im, out ) )