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
Unable to read exif data unless loaded from path #745
Comments
For clarity: I'm happy to work on the PR for this |
It would be nice if exif() would be able to read meta data from all images no matter if they were loaded from a path. PR would be welcomed. Be sure to follow:
|
I think the only problem is that, GD encoding does not retain EXIF data. So if you encode the image as data-url to reread it with |
The issues I can see coming are:
Are any of these specific blockers? |
OK - so from some testing it's possible to read the exif headers by base64 encoding just a portion of the binary data. eg: $headerData = stream_get_contents($assetContainer->getStream(), 10240);
$exif = exif_read_data ( "data://image/jpeg;base64," . base64_encode($headerData) , 0 , true ); So it may be possible to either just hold onto a portion of the data for exif reading or we can prefetch exif data for the image but by encoding just a portion of the binary data upon initialisation. |
What is |
Oh, sorry, that's just an abstraction layer for assets. Wherever the binary data comes from we can just read the first N bytes and pass that to How do you feel about extracting the exif meta data and storing it in a |
The following overview shows, how to handle the different input types. There are actually five methods. Methods 1-2 can read exif data smoothly. Method 3-5 are problematic, because we need run additional resource intensive encoding, which may not be wanted. I'm not sure, if this should be the default on every init.
|
Thanks for the overview. I'd like some guidance on the likelihood of you accepting an approach of caching the exit data on initialisation before I spend time writing on an approach you don't like |
I have been following and investigating this issue, and was looking to suggest something much much along these lines. I would suggest a setExif / getExif on Image class, which would allow this data to be assigned on init. ExifCommand would instead simply return getExif(). It would be the responsibility of the Decoder to invoke setExif based on the functionality you describe. I would accept that there are cases where exif simply isn't accessible, but we should certainly attempt to capture it in cases where it could be, but currently isn't (e.g. streams). |
are there any infos regarding exif data from non-file image instances? |
Since PHP 7.2.0 it is possible. But from my understanding Intervention always converts the stream (in AbstractDecoder->initFromStream), therefore the ExifCommand cannot access the stream and is not able to read the EXIF data. |
It sounds like a combination of using PHP 7.2 exif reading from streams, and shifting some of the responsibility for exif init to the initFrom* methods could work.
Caveats:
|
ファイルパスではなくバイナリデータを読み込むと、Exif情報が失われる問題 Intervention/image#745 への対処を含む。
Nice work @olivervogel |
At the momement it's only possible to read exif data from images loaded from a path.
exif_read_data
supports the ability to load from base64 encoded data-urls. This means it is possible, in theory, to read exif data from images that are loaded through any of theinit
methods and not just those from file paths.Would there be any support from the maintainers of this library to add exif reading capabilities to images loaded through means other than files?
related: #336
The text was updated successfully, but these errors were encountered: