Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #8554

When a TIFF image is YCbCr, Pillow calls libtiff's TIFFRGBAImageBegin

readAsRGBA = photometric == PHOTOMETRIC_YCBCR;

if (readAsRGBA) {
_decodeAsRGBA(im, state, tiff);

if (!(TIFFRGBAImageOK(tiff, emsg) && TIFFRGBAImageBegin(&img, tiff, 0, emsg))) {

Looking at that libtiff code, it then calls either PickContigCase or PickSeparateCase. Those set img->get to gtTileContig, gtStripContig, gtTileSeparate or gtStripSeparate. All four of those functions apply orientation to the image based on img->orientation.

Pillow expects to manage image orientation itself. This PR sets img.orientation to prevent libtiff from doing so.

@radarhere radarhere added the TIFF label Nov 16, 2024
@hugovk hugovk merged commit 93cdfeb into python-pillow:main Mar 29, 2025
49 checks passed
@radarhere radarhere deleted the tiff_orientation branch March 29, 2025 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants