Fixed orientation when opening YCbCr TIFF images by radarhere · Pull Request #8556 · python-pillow/Pillow

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.