Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed orientation when opening YCbCr TIFF images #8556

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CR2 / TIFF image loads with incorrectly applied orientation / rotation
1 participant