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 Orientation value #336

Closed
potsky opened this issue Mar 9, 2015 · 5 comments
Closed

EXIF Orientation value #336

potsky opened this issue Mar 9, 2015 · 5 comments

Comments

@potsky
Copy link

potsky commented Mar 9, 2015

Hi !

I have read all closed issues about EXIF and Orientation. $image->orientate() does not work for me and when I launch a $image->exif(), nothing is returned.

EXIF is enabled on my PHP installation. But when looking on exif data on my file with the original PHP function, I can read orientation :

$exif = exif_read_data ( "data://image/jpeg;base64," . base64_encode($data) , 0 , true );
$orientation = $exif['IFD0']['Orientation'];

If I display all informations about my file, I can see these EXIF data :

FILE.FileName: 9k=
FILE.FileDateTime: 0
FILE.FileSize: 1274762
FILE.FileType: 2
FILE.MimeType: image/jpeg
FILE.SectionsFound: ANY_TAG
COMPUTED.html: width="3264" height="2448"
COMPUTED.Height: 2448
COMPUTED.Width: 3264
COMPUTED.IsColor: 1
COMPUTED.ByteOrderMotorola: 1
IFD0.Orientation: 6
IFD0.Exif_IFD_Pointer: 38
EXIF.ColorSpace: 1
EXIF.ExifImageWidth: 3264
EXIF.ExifImageLength: 2448

The image has been taken with my iPhone 6 with latest version of iOS.

@olivervogel
Copy link
Member

exif() tries to read information from file path. I don't know how you initiate your image object, but if there is no path, exif() can't read any information.

@potsky
Copy link
Author

potsky commented Mar 9, 2015

Well done !

I get the image from MongoDb in a GridFS, so I initiate file with a binary string and not a file indeed !

Perhaps we could load data from the image binary and then call PHP as I have done :

$exif = exif_read_data ( "data://image/jpeg;base64," . base64_encode($data) , 0 , true );

Do you know how I can retrieve image binary data from the $image object ? I will make a pull request if you want. It will be cleaner to get exif data from an image regardless of the way it has been loaded.

@olivervogel
Copy link
Member

The image is stored as a GD resource or an Imagick object, depending on your driver. There is no binary data, unless you call encode().

@potsky
Copy link
Author

potsky commented Mar 9, 2015

Ok so there is not better solution because encode on GD will remove EXIF data. You should perhaps tell in the documentation that the exif method is only available when loading an image from a file path and throws an exception if provided file path does not exist.

Thank you for your time.

@briedis
Copy link
Contributor

briedis commented Jan 9, 2017

I would like to note, that a fix should be available in PHP 7.2
Ticket: https://bugs.php.net/bug.php?id=65187

They are plannign to fix that exif functions can work with streams too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants