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

EXIF data are not transferred correctly #93

Closed
fabbaum opened this issue May 9, 2023 · 3 comments
Closed

EXIF data are not transferred correctly #93

fabbaum opened this issue May 9, 2023 · 3 comments
Labels
fixed Fixed in last version

Comments

@fabbaum
Copy link

fabbaum commented May 9, 2023

Describe the bug

With version pillow_heif==0.10.1, the code snip attached below worked perfectly. The EXIF data was read from a HEIC photo and added to a JPG.

With version pillow_heif==0.11.0, the EXIF data is no longer transferred correctly.

Please also compare the two file attachments.

Steps/Code to Reproduce

for files in os.listdir(path_source):
    if files.endswith('.HEIC'):
        filename = files.split('.')[0]
        heif_file = pillow_heif.open_heif(path_source + files, convert_hdr_to_8bit=False, bgr_mode=True)
        np_array = np.asarray(heif_file)
        cv2.imwrite(os.path.join(path_output, filename + '.jpg'), np_array)

        # Add exif to new image
        exif = heif_file.info['exif']
        image_new = Image.open(os.path.join(path_output, filename + '.jpg'))
        image_new.save(path_output + filename + '.jpg', 'JPEG', exif=exif)

Expected Results

The expected result, reproduced with version 0.10.1:
3.11.1 (tags/v3.11.1:a7a450f, Dec 6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]
Windows-10-10.0.19045-SP0
0.10.1
{'libheif': '1.15.2', 'HEIF': 'x265 HEVC encoder (3.4+31-6722fce1f)', 'AVIF': 'AOMedia Project AV1 Encoder v3.6.0'}
Version 0 10 1

Actual Results

Version 0 11 0

Versions

3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]
Windows-10-10.0.19045-SP0
0.11.0
{'libheif': '1.15.2', 'HEIF': 'x265 HEVC encoder (3.4+31-6722fce1f)', 'AVIF': 'AOMedia Project AV1 Encoder v3.6.0'}
@bigcat88
Copy link
Owner

bigcat88 commented May 9, 2023

It is not a bug, just correct returning of Exif from libheif.
Exif can possible be without bExif\x00\x00 sequence at the beginning(those Pillow just do not support this with explictly exif parameter).
But 0.11.0 version really breaks compatibility with previous versions in way you described...

The only way currenly see to restore compatability for me looks like always append bExif\x00\x00 at the start of Exif if it is not present...

I'll add test for this case you described and publish an update that restores compatibility and do not return the bug that was fixed previously in 0.11.0

Thanks for pointing on this!

image_new.save(path_output + filename + '.jpg', 'JPEG', exif=b'Exif\x00\x00' + exif)

@bigcat88 bigcat88 added the fixed in upcoming release fix will arrive with next release label May 9, 2023
@bigcat88 bigcat88 reopened this May 9, 2023
@bigcat88 bigcat88 added fixed Fixed in last version and removed fixed in upcoming release fix will arrive with next release labels May 10, 2023
@bigcat88
Copy link
Owner

If with this release all is good, and in three days there will be no issues I'll mark 0.11.0 version as yanked.

Feel free to close issue after check that the problem is gone for you

@fabbaum
Copy link
Author

fabbaum commented May 10, 2023

The release ist good. Thank you very much for the quick implementation.

@fabbaum fabbaum closed this as completed May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Fixed in last version
Projects
None yet
Development

No branches or pull requests

2 participants