The PHP function exif_read_data()
requires a filename for input, however I only have the image data in a string (such that I can use imagecreatefromstring()
) and I can not write it to a temp file. How do I extract EXIF information without writing this image string to disk? All I really want is the Orientation attribute. This is on a Linux system if it matters.
Adding @rymo’s comment on @MarcB’s answer as a separate answer:
This works:
$exif = exif_read_data("data://image/jpeg;base64," . base64_encode($image));
echo $exif['Orientation'];
A stream wrapper can turn your string/image into something useable as a filehandle, as shown here. However, I can't see any way of turning that filehandle into something that can masquerade as the filename that exif_read_data expects.
You might try passing the data://
pseudo-url listed on that page and see if the exif function will accept it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With