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

HEIF/AVIF file signature (magic number) #8

Closed
DimonLavron opened this issue Oct 29, 2021 · 7 comments
Closed

HEIF/AVIF file signature (magic number) #8

DimonLavron opened this issue Oct 29, 2021 · 7 comments
Labels
fixed in upcoming release fix will arrive with next release fixed Fixed in last version

Comments

@DimonLavron
Copy link

Hi there!

Recently I started to use pyheif-pillow-opener for one project to add support for heif/avif files. It was great until I faced with some issue, that I want to share with you, because I can see you start developing your addon a month ago and you hopefully can fix it faster on your side

So, in as_opener.py you have check_heif_magic method. It checks, if 5-8 bytes of signature is ftyp or 9-12 bytes of signature is one of the listed brands, but I think it should be logical and instead of logical or in return statement and that's why:

  1. Links in function comments What is HEIF/HEIC magic number? strukturag/libheif#83 GNOME/gimp@e4bff4c shows, that acceptable magic numbers is ftypheic, ftypheix, ftypmif1 etc., not just ftyp or [heic, heix, mif1]
  2. I found out that some other files can have 5-8 bytes as ftyp, for my particular situation it was .m4a, it has ftypM4A magic number, and I found some other files, that is not HEIF/AVIF photos, but have 5-8 bytes as ftyp (here you can find some them, but I bet we can find more: https://www.garykessler.net/library/file_sigs.html) and because of that .m4a files can be validated as HEIF files with this function, but this is not HEIF at all

I can't find too much info about HEIF/AVIF file signature, so maybe I'm wrong, but from my experience and from discussions above I assume, that this could be a bug

Thank you for your attention, would be gladful if you fix this, or tell me that I've missed something!

@bigcat88
Copy link
Owner

bigcat88 commented Oct 29, 2021

@DimonLavron Will look at this tomorrow, and also will test how it works with "heics" generated by last iPhones...

and in last binary release as I remember, as_opener has old name, this code(with new name) is what I prepare for next release, anyway I'll look and make a new release with this and some other stuff at Sunday or Monday/Tuesday.
Thanks.

@bigcat88 bigcat88 added good issue That's an interesting thing... fixed in upcoming release fix will arrive with next release and removed good issue That's an interesting thing... labels Oct 29, 2021
@bigcat88
Copy link
Owner

@DimonLavron Release will be ready on Tuesday or Wednesday, need add some additional stuff, like caching in GitHub Actions for faster build(arm build takes too long time currently) and include libaom library for AV1 format, write tests for these images: nokia heif repo and maybe will have time to make windows binary bistro.

@DimonLavron
Copy link
Author

@bigcat88 good to hear, thanks for quick reaction!

@bigcat88
Copy link
Owner

bigcat88 commented Nov 3, 2021

When they will fix this(pypa/cibuildwheel#902) at the same day new version will be posted...
:(
Edit: Release will be tomorrow(5 November)

@bigcat88
Copy link
Owner

bigcat88 commented Nov 5, 2021

@DimonLavron release published.

@bigcat88 bigcat88 added the fixed Fixed in last version label Nov 5, 2021
@DimonLavron
Copy link
Author

@bigcat88 thanks a lot!

@bigcat88
Copy link
Owner

@DimonLavron published a new release(this is first version with windows wheels), there was some changes in opener mode(it must be faster now), can you please check it ?
Tried to cover all with tests, but it is a bit complex task, need some more time for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in upcoming release fix will arrive with next release fixed Fixed in last version
Projects
None yet
Development

No branches or pull requests

2 participants