Skip to content

exif read : warnings and errors : Potentially invalid endianess, Illegal IFD size and Undefined index #9397

Closed
@Ben29980

Description

@Ben29980

Hello community,
I read that on older php versions exif read function was not working properly on certain images.
I should have been patched with new php versions... But not fully...

On recent DJI images, I have a persistent uncapacity to correctly "read exif data" from image

Image example:
DJI_20220813101819_0001_W

here an example of errors I have:
php_exif_error

Please note that with other images, it works like a charm. And not problem for me to extract data.

Here is my code:
`//get the EXIF
$exif = exif_read_data($file, 'IFD0');
echo $exif===false ? "Aucun en-tête de donnés n'a été trouvé.
\n" : "L'image contient des en-têtes
\n";
$exif = exif_read_data($file);

//get the Hemisphere multiplier
$LatM = 1; 
$LongM = 1;
if($exif["GPSLatitudeRef"] == 'S')
{
$LatM = -1;
}
if($exif["GPSLongitudeRef"] == 'W')
{
$LongM = -1;
}

$alt      = explode('/', $exif["GPSAltitude"]);
$altitude = (isset($alt[1])) ? ($alt[0] / $alt[1]) : $alt[0];

//get the GPS data
$gps['LatDegree']=$exif["GPSLatitude"][0];
$gps['LatMinute']=$exif["GPSLatitude"][1];
$gps['LatgSeconds']=$exif["GPSLatitude"][2];
$gps['LongDegree']=$exif["GPSLongitude"][0];
$gps['LongMinute']=$exif["GPSLongitude"][1];
$gps['LongSeconds']=$exif["GPSLongitude"][2];`

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions