Reputation: 1
I am trying to get image orientation details using PHP exif_read_data() Function but unfortunately I am unable to get the desired details. I am getting only
Array ( [FILE] => Array ( [FileName] => sasfasdfasd-asdf-asdasdf-afdsd-767563900.jpg [FileDateTime] => 1541527956 [FileSize] => 302871 [FileType] => 2 [MimeType] => image/jpeg [SectionsFound] => COMMENT ) [COMPUTED] => Array ( [html] => width="1000" height="750" [Height] => 750 [Width] => 1000 [IsColor] => 1 ) [COMMENT] => Array ( [0] => CREATOR: gd-jpeg v1.0 (using IJG JPEG v90), quality = 100 ) )
I am using PHP 7.2 Can someone please tell me how can I get Image orientation details using PHP? I have checked my GD libraries as well as EXIF using PHP info. They are working fine.
Upvotes: 0
Views: 722
Reputation: 393
Unfortunately the image you have created is done using LibGD, which by default does not write any extended EXIF data.
As the maintainer of the EXIF Extension that comes with PHP, I can give you a little inside of how this works under the hood:
When you load in an image using exif_read_data()
, then by default the above sections are returned (with the exception of COMMENT
in your case; as it is generated by LibGD). If a MAKERNOTE
section is found within the binary meta data of the image, then PHP will attempt to resolve the value to one of the known formats to PHP[1].
If a signature is then matched with one of the known formats, then PHP will read all the relevant IFD (Image File Data) data from the header and attempt to resolve some of the tag names according to a baked in list of tags. This makes the returned array much more reliant to work with, instead of having to write code like echo $exif['0x0112'];
(Orientation), the array becomes something like: echo $exif['Orientation'];
.
If a signature however is not matched, then PHP will still attempt to read the relevant EXIF data within an image, however tags will not be mapped for non standard tags. PHP will also continue to read things like thumbnail data etc, given the binary data is following the EXIF specification.
Finally; PHP's EXIF extension is read-only, so even if you were to know your orientation from the image in question, you can't manually write it with the default extension that comes with PHP I'm afraid.
Upvotes: 1