I have been using GeoSetter (which uses ExifTool as a back-end) to geocode my images. I then load these images into my web site where a php script uses exif_read_data to get the GPS lat/long. On some of the images, particularly older images shot with an Olympus E-20, exif_read_data doesn't return any GPS data, but according to multiple programs (PhotoShop, etc), the GPS data is encoded. I have tried using FAQ #20 to rewrite the metadata, but that hasn't helped.
If I run a test program to see what EXIF metadata exists on a "good" image (which was shot at the same time), I see:
/usr/www/users/gschultz/GeoffSchultz/photos/galleries/2004_Cruising/Guatemala_Antigua/20040215-110738.jpg :
COMPUTED.html: width="1500" height="1171"
COMPUTED.Height: 1171
COMPUTED.Width: 1500
COMPUTED.IsColor: 1
COMPUTED.ByteOrderMotorola: 1
COMPUTED.ApertureFNumber: f/2.0
COMPUTED.UserComment:
COMPUTED.UserCommentEncoding: ASCII
COMPUTED.Copyright: Copyright 2004 Geoffrey W. Schultz
COMPUTED.Thumbnail.FileType: 2
COMPUTED.Thumbnail.MimeType: image/jpeg
THUMBNAIL.Compression: 6
THUMBNAIL.XResolution: 72/1
THUMBNAIL.YResolution: 72/1
THUMBNAIL.ResolutionUnit: 2
THUMBNAIL.JPEGInterchangeFormat: 980
THUMBNAIL.JPEGInterchangeFormatLength: 5435
GPSLatitude.0: 14/1
GPSLatitude.1: 34/1
GPSLatitude.2: 1756/14633333
GPSLongitude.0: 90/1
GPSLongitude.1: 43/1
GPSLongitude.2: 499979/8333
GPSTimeStamp.0: 16/1
GPSTimeStamp.1: 7/1
GPSTimeStamp.2: 39/1
However, when I run it on a "bad" image, I see:
/usr/www/users/gschultz/GeoffSchultz/photos/galleries/2004_Cruising/Guatemala_Antigua/20040215-111916.jpg :
COMPUTED.html: width="1500" height="1125"
COMPUTED.Height: 1125
COMPUTED.Width: 1500
COMPUTED.IsColor: 1
COMPUTED.ByteOrderMotorola: 1
COMPUTED.ApertureFNumber: f/2.8
COMPUTED.UserComment:
COMPUTED.UserCommentEncoding: ASCII
COMPUTED.Copyright: Copyright 2004 Geoffrey W. Schultz
SpecialMode.0: 0
SpecialMode.1: 0
SpecialMode.2: 0
UndefinedTag:0x0206.0: -73
UndefinedTag:0x0206.1: -161
UndefinedTag:0x0206.2: -198
UndefinedTag:0x0206.3: 9
UndefinedTag:0x0206.4: 32
[clip - continues for many lines]
Any ideas on how to generate jpg images that exif_read_data can process?
-- Geoff
I have attached a copy of the "bad" image which was processed via:
exiftool -all= -tagsfromfile @ -all:all -unsafe *.jpg
I've also tried the following with no success:
exiftool -exif:all= -tagsfromfile @ -exif:all -unsafe -thumbnailimage -F *.jpg
-- Geoff
Finally, here's the php which generated the output:
<?php
$file = '/usr/www/users/gschultz/GeoffSchultz/photos/galleries/2004_Cruising/Guatemala_Antigua/20040215-111916.jpg';
// $file = '/usr/www/users/gschultz/GeoffSchultz/photos/galleries/2004_Cruising/Guatemala_Antigua/20040215-110738.jpg';
if (file_exists($file))
echo "$file :<br />\n";
$exif = exif_read_data($file, 'IFD0');
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "$key.$name: $val<br />\n";
}
}
?>
Bump: Any ideas on how to fix this?
-- Geoff
Hi Geoff,
I hadn't responded because I don't have any useful suggestions.
Maybe it makes more sense to ask the author of exif_read_data() why it doesn't read some metadata.
I'm assuming that ExifTool reads it OK.
- Phil
OK, thanks. I wasn't sure if this just got lost or what. I'll pursue it with exif_read_data.
-- Geoff
Phil,
I've just completed moving ~7,000 photos over to a new gallery system (piwigo) which is based on php/mySQL. The vast majority of these images were geotagged using GeoSetter, but in about 1,000 of them, php can't read the GPS location data. Note that the IPTC data can be read by php. Programs such as Photoshop have no issues seeing the GPS data.
What's interesting is that the images with problems span many years, but tend to be clumped within albums. By clumping I mean that all/most of the photos within a given album exhibit the problem, but other albums taken +/- a day are fine. All were shot with the same camera (within a given year) & processed with the same software (Photoshop, Thumbsplus, GeoSetter/EXIFtool).
I've tried rewriting the metadata using:
exiftool -all= -tagsfromfile @ -all:all -unsafe *.jpg
but when I do that, all of the metadata (EXIF, IPTC) is stripped from the output file. Due to the sheer volume of files that need to be fixed, I need a bulk solution.
So, my question is: Is the above command line correct for rebuilding the IPTC/EXIF metadata and/or is there something else that you can suggest that I try?
-- Geoff
Hi Geoff,
Quote from: geoffschultz on August 03, 2012, 09:31:56 AM
exiftool -all= -tagsfromfile @ -all:all -unsafe *.jpg
but when I do that, all of the metadata (EXIF, IPTC) is stripped from the output file.
This should not happen. This command should copy back all writable information. Something is wrong if it doesn't.
However, even if this command works I don't think it will solve your problem because the output file should be the same as the input file if ExifTool wrote the original metadata.
If you can figure out why php can't read the GPS location from one of these images, then a bulk solution should be easy to implement. You just need to do some detective work to figure this out.
- Phil
Phil,
The original IPTC metadata (comment, copyright, country, city, state, etc) was written by a program called Thumbsplus that I've used for years. The GPS position data in both of these files was written by GeoSetter/ExifTool.
Looking at 2 files (which in this case happen to have been taken on the same day), here's the differences that I see based upon output from php's exif_read_data:
Good: FILE.SectionsFound: ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS, INTEROP
Bad: FILE.SectionsFound: ANY_TAG, IFD0, EXIF, MAKERNOTE
Good: COMPUTED.Thumbnail.FileType: 2
COMPUTED.Thumbnail.MimeType: image/jpeg
Bad: <missing>
Good: IFD0.Exif_IFD_Pointer: 170
IFD0.GPS_IFD_Pointer: 404
Bad: <missing>
Good: IFD0.Software: Adobe Photoshop 7.0
Bad: IFD0.Software: 29-1103
Good: <missing>
Bad: EXIF.MakerNote: OLYMPF.......
The issue here seems to be original, unedited images taken with the Olympus E-20. It appears that if the file was touched by Photoshop that the metadata is OK. Other then editing a ton of files, do you have a suggestion?
-- Geoff
Hi Geoff,
It would help if you did the comparison of the ExifTool -a -G1 outputs.
- Phil
Bad file:
G:\2004_Sailing\Guatemala_Antigua>exiftool -a -G1 20040215-111916.jpg
[ExifTool] ExifTool Version Number : 8.97
[System] File Name : 20040215-111916.jpg
[System] Directory : .
[System] File Size : 3.5 MB
[System] File Modification Date/Time : 2012:07:06 18:23:39-04:00
[System] File Permissions : rw-rw-rw-
[File] File Type : JPEG
[File] MIME Type : image/jpeg
[File] Exif Byte Order : Big-endian (Motorola, MM)
[File] Current IPTC Digest : 13aa5068487cd435c9081b38f4edf4e5
[File] Image Width : 2560
[File] Image Height : 1920
[File] Encoding Process : Baseline DCT, Huffman coding
[File] Bits Per Sample : 8
[File] Color Components : 3
[File] Y Cb Cr Sub Sampling : YCbCr4:2:2 (2 1)
[IFD0] Image Description : Colorful Cloth!
[IFD0] Make : OLYMPUS OPTICAL CO.,LTD
[IFD0] Camera Model Name : E-20,E-20N,E-20P
[IFD0] Orientation : Horizontal (normal)
[IFD0] X Resolution : 144
[IFD0] Y Resolution : 144
[IFD0] Resolution Unit : inches
[IFD0] Software : 29-1103
[IFD0] Modify Date : 2004:02:15 11:19:16
[IFD0] Y Cb Cr Positioning : Co-sited
[IFD0] Copyright : Copyright 2004 Geoffrey W. Schultz
[ExifIFD] Exposure Time : 1/100
[ExifIFD] F Number : 2.8
[ExifIFD] Exposure Program : Program AE
[ExifIFD] ISO : 80
[ExifIFD] Exif Version : 0210
[ExifIFD] Date/Time Original : 2004:02:15 11:19:16
[ExifIFD] Create Date : 2004:02:15 11:19:16
[ExifIFD] Components Configuration : Y, Cb, Cr, -
[ExifIFD] Exposure Compensation : 0
[ExifIFD] Max Aperture Value : 2.0
[ExifIFD] Metering Mode : Multi-segment
[ExifIFD] Flash : No Flash
[ExifIFD] Focal Length : 19.0 mm
[ExifIFD] User Comment :
[ExifIFD] Flashpix Version : 0100
[ExifIFD] Color Space : sRGB
[ExifIFD] Exif Image Width : 2560
[ExifIFD] Exif Image Height : 1920
[ExifIFD] File Source : Digital Camera
[Olympus] Special Mode : Normal, Sequence: 0, Panorama: (none)
[Olympus] Quality : SHQ (Fine)
[Olympus] Macro : Off
[Olympus] Black And White Mode : Off
[Olympus] Digital Zoom : 0.0
[Olympus] Focal Plane Diagonal : 11.126 mm
[Olympus] Lens Distortion Params : -73 -161 -198 9 32 46
[Olympus] Camera Type : E-20,E-20N,E-20P
[Olympus] Camera ID : OLYMPUS DIGITAL CAMERA
[Olympus] Shutter Speed Value : 1/106
[Olympus] ISO Value : 50
[Olympus] Aperture Value : 2.9
[Olympus] Brightness Value : 5.80859375
[Olympus] Flash Mode : Off
[Olympus] Flash Device : Unknown (0 0)
[Olympus] Exposure Compensation : 0
[Olympus] Sensor Temperature : 34
[Olympus] Lens Temperature : 33
[Olympus] Light Condition : 0
[Olympus] Focus Range : Normal
[Olympus] Focus Mode : Auto
[Olympus] Manual Focus Distance : 0 mm
[Olympus] Zoom Step Count : 15
[Olympus] Focus Step Count : 297
[Olympus] Sharpness : Normal
[Olympus] Flash Charge Level : 0
[Olympus] Color Matrix : 328 -90 18 -30 346 -60 8 -86 334
[Olympus] Black Level : 32 32 32 32
[Olympus] WB Mode : Auto
[Olympus] Red Balance : 1.421875
[Olympus] Blue Balance : 1.4375
[Olympus] Color Matrix Number : 0
[Olympus] Serial Number : 201005601
[Olympus] Flash Exposure Comp : undef
[Olympus] Internal Flash Table : 0
[Olympus] External Flash G Value : undef
[Olympus] External Flash Bounce : No
[Olympus] External Flash Zoom : 0
[Olympus] External Flash Mode : 0
[Olympus] Contrast : Normal
[Olympus] Sharpness Factor : 352
[Olympus] Color Control : 24 1024 768 1024 8 256
[Olympus] Valid Bits : 10 0
[Olympus] Coring Filter : 2304
[Olympus] Olympus Image Width : 2572
[Olympus] Olympus Image Height : 1920
[Olympus] Scene Detect : 0
[Olympus] Compression Ratio : 2.7
[Olympus] Preview Image Valid : Yes
[Olympus] Preview Image Start : 3690694
[Olympus] Preview Image Length : 162547
[Olympus] AF Result : 0
[Olympus] CCD Scan Mode : Interlaced
[Olympus] Noise Reduction : Off
[Olympus] Focus Step Infinity : 277
[Olympus] Focus Step Near : 464
[InteropIFD] Interoperability Index : R98 - DCF basic file (sRGB)
[InteropIFD] Interoperability Version : 0100
[GPS] GPS Version ID : 2.2.0.0
[GPS] GPS Latitude Ref : North
[GPS] GPS Latitude : 14 deg 34' 0.00"
[GPS] GPS Longitude Ref : West
[GPS] GPS Longitude : 90 deg 43' 60.00"
[GPS] GPS Time Stamp : 16:19:16
[GPS] GPS Map Datum : WGS-84
[GPS] GPS Date Stamp : 2004:02:15
[IFD1] Compression : JPEG (old-style)
[IFD1] X Resolution : 72
[IFD1] Y Resolution : 72
[IFD1] Resolution Unit : inches
[IFD1] Thumbnail Offset : 5088
[IFD1] Thumbnail Length : 6674
[IPTC] Application Record Version : 4
[IPTC] City : Fronteras
[IPTC] Country-Primary Location Name : Guatemala
[IPTC] Copyright Notice : Copyright 2004 Geoffrey W. Schultz
[IPTC] Caption-Abstract : Colorful Cloth!
[IPTC] Country-Primary Location Code : GTM
[XMP-x] XMP Toolkit : Image::ExifTool 8.97
[XMP-iptcCore] Country Code : GTM
[XMP-dc] Description : Colorful Cloth!
[XMP-dc] Rights : Copyright 2004 Geoffrey W. Schultz
[XMP-exif] Color Space : sRGB
[XMP-exif] Components Configuration : Y, Cb, Cr, -
[XMP-exif] Date/Time Digitized : 2004:02:15 11:19:16-05:00
[XMP-exif] Date/Time Original : 2004:02:15 11:19:16-05:00
[XMP-exif] Exif Version : 0210
[XMP-exif] Exposure Compensation : 0
[XMP-exif] Exposure Program : Program AE
[XMP-exif] Exposure Time : 1/100
[XMP-exif] F Number : 2.8
[XMP-exif] File Source : Digital Camera
[XMP-exif] Flashpix Version : 0100
[XMP-exif] Focal Length : 19.0 mm
[XMP-exif] GPS Latitude : 14 deg 34' 0.00" N
[XMP-exif] GPS Longitude : 90 deg 43' 60.00" W
[XMP-exif] GPS Map Datum : WGS-84
[XMP-exif] GPS Date/Time : 2004:02:15 16:19:16Z
[XMP-exif] GPS Version ID : 2.2.0.0
[XMP-exif] ISO : 80
[XMP-exif] Max Aperture Value : 2.0
[XMP-exif] Metering Mode : Multi-segment
[XMP-exif] Exif Image Width : 2560
[XMP-exif] Exif Image Height : 1920
[XMP-exif] User Comment :
[XMP-photoshop] City : Fronteras
[XMP-photoshop] Country : Guatemala
[XMP-photoshop] Date Created : 2004:02:15 11:19:16
[XMP-tiff] Compression : JPEG (old-style)
[XMP-tiff] Image Description : OLYMPUS DIGITAL CAMERA
[XMP-tiff] Make : OLYMPUS OPTICAL CO.,LTD
[XMP-tiff] Camera Model Name : E-20,E-20N,E-20P
[XMP-tiff] Orientation : Horizontal (normal)
[XMP-tiff] Resolution Unit : inches
[XMP-tiff] Software : 29-1103
[XMP-tiff] X Resolution : 144
[XMP-tiff] Y Cb Cr Positioning : Co-sited
[XMP-tiff] Y Resolution : 144
[XMP-xmp] Create Date : 2004:02:15 11:19:16
[XMP-xmp] Modify Date : 2004:02:15 11:19:16-05:00
[Composite] Aperture : 2.8
[Composite] GPS Date/Time : 2004:02:15 16:19:16Z
[Composite] GPS Latitude : 14 deg 34' 0.00" N
[Composite] GPS Latitude Ref : North
[Composite] GPS Longitude : 90 deg 43' 60.00" W
[Composite] GPS Longitude Ref : West
[Composite] GPS Position : 14 deg 34' 0.00" N, 90 deg 43' 60.00" W
[Composite] Image Size : 2560x1920
[Composite] Preview Image : (Binary data 162547 bytes, use -b option to extract)
[Composite] Scale Factor To 35 mm Equivalent: 3.9
[Composite] Shutter Speed : 1/100
[Composite] Thumbnail Image : (Binary data 6674 bytes, use -b option to extract)
[Composite] Circle Of Confusion : 0.008 mm
[Composite] Field Of View : 27.4 deg
[Composite] Focal Length : 19.0 mm (35 mm equivalent: 73.9 mm)
[Composite] Hyperfocal Distance : 16.69 m
[Composite] Light Value : 9.9
Good file:
G:\2004_Sailing\Guatemala_Antigua>exiftool -a -G1 20040215-110738.jpg
[ExifTool] ExifTool Version Number : 8.97
[System] File Name : 20040215-110738.jpg
[System] Directory : .
[System] File Size : 1411 kB
[System] File Modification Date/Time : 2012:07:28 07:17:56-04:00
[System] File Permissions : rw-rw-rw-
[File] File Type : JPEG
[File] MIME Type : image/jpeg
[File] Exif Byte Order : Big-endian (Motorola, MM)
[File] Current IPTC Digest : 659a6588c1456389e709f046696d5b48
[File] Image Width : 2244
[File] Image Height : 1752
[File] Encoding Process : Baseline DCT, Huffman coding
[File] Bits Per Sample : 8
[File] Color Components : 3
[File] Y Cb Cr Sub Sampling : YCbCr4:4:4 (1 1)
[JFIF] JFIF Version : 1.02
[JFIF] Resolution Unit : inches
[JFIF] X Resolution : 144
[JFIF] Y Resolution : 144
[IFD0] Image Description : Inside Cathedral
[IFD0] Make : OLYMPUS OPTICAL CO.,LTD
[IFD0] Camera Model Name : E-20,E-20N,E-20P
[IFD0] Orientation : Horizontal (normal)
[IFD0] X Resolution : 144
[IFD0] Y Resolution : 144
[IFD0] Resolution Unit : inches
[IFD0] Software : Adobe Photoshop 7.0
[IFD0] Modify Date : 2004:02:15 11:07:39
[IFD0] Y Cb Cr Positioning : Co-sited
[IFD0] Copyright : Copyright 2004 Geoffrey W. Schultz
[ExifIFD] Exposure Time : 1/20
[ExifIFD] F Number : 2.0
[ExifIFD] Exposure Program : Program AE
[ExifIFD] ISO : 320
[ExifIFD] Exif Version : 0210
[ExifIFD] Date/Time Original : 2004:02:15 11:07:39
[ExifIFD] Create Date : 2004:02:15 11:07:39
[ExifIFD] Components Configuration : Y, Cb, Cr, -
[ExifIFD] Exposure Compensation : 0
[ExifIFD] Max Aperture Value : 2.0
[ExifIFD] Metering Mode : Multi-segment
[ExifIFD] Flash : No Flash
[ExifIFD] Focal Length : 9.0 mm
[ExifIFD] Flashpix Version : 0100
[ExifIFD] Color Space : sRGB
[ExifIFD] Exif Image Width : 2244
[ExifIFD] Exif Image Height : 1752
[ExifIFD] File Source : Digital Camera
[InteropIFD] Interoperability Index : R98 - DCF basic file (sRGB)
[InteropIFD] Interoperability Version : 0100
[GPS] GPS Version ID : 2.2.0.0
[GPS] GPS Latitude Ref : North
[GPS] GPS Latitude : 14 deg 34' 0.00"
[GPS] GPS Longitude Ref : West
[GPS] GPS Longitude : 90 deg 44' 0.00"
[GPS] GPS Time Stamp : 16:07:39
[GPS] GPS Map Datum : WGS-84
[GPS] GPS Date Stamp : 2004:02:15
[IFD1] Compression : JPEG (old-style)
[IFD1] X Resolution : 72
[IFD1] Y Resolution : 72
[IFD1] Resolution Unit : inches
[IFD1] Thumbnail Offset : 1128
[IFD1] Thumbnail Length : 5435
[XMP-x] XMP Toolkit : XMP Core 5.1.2
[XMP-iptcCore] Country Code : GTM
[XMP-photoshop] City : Fronteras
[XMP-photoshop] Country : Guatemala
[XMP-photoshop] Date Created : 2004:02:15 11:07:39-05:00
[XMP-xmp] Modify Date : 2004:02:15 11:07:39-05:00
[XMP-xmp] Create Date : 2004:02:15 11:07:39-05:00
[XMP-xmp] Creator Tool : Adobe Photoshop 7.0
[XMP-xmpMM] Document ID : adobe:docid:photoshop:f74b7af3-648e-11d8-bf5c-d454f730a591
[XMP-xmpMM] Instance ID : uuid:f74b7af5-648e-11d8-bf5c-d454f730a591
[XMP-dc] Description : Inside Cathedral
[XMP-dc] Rights : Copyright 2004 Geoffrey W. Schultz
[IPTC] Coded Character Set : UTF8
[IPTC] Application Record Version : 4
[IPTC] Date Created : 2004:02:15
[IPTC] Time Created : 11:07:39-05:00
[IPTC] City : Fronteras
[IPTC] Country-Primary Location Code : GTM
[IPTC] Country-Primary Location Name : Guatemala
[IPTC] Copyright Notice : Copyright 2004 Geoffrey W. Schultz
[IPTC] Caption-Abstract : Inside Cathedral
[Photoshop] Copyright Flag : False
[Photoshop] IPTC Digest : 659a6588c1456389e709f046696d5b48
[ICC-header] Profile CMM Type : Lino
[ICC-header] Profile Version : 2.1.0
[ICC-header] Profile Class : Display Device Profile
[ICC-header] Color Space Data : RGB
[ICC-header] Profile Connection Space : XYZ
[ICC-header] Profile Date Time : 1998:02:09 06:49:00
[ICC-header] Profile File Signature : acsp
[ICC-header] Primary Platform : Microsoft Corporation
[ICC-header] CMM Flags : Not Embedded, Independent
[ICC-header] Device Manufacturer : IEC
[ICC-header] Device Model : sRGB
[ICC-header] Device Attributes : Reflective, Glossy, Positive, Color
[ICC-header] Rendering Intent : Perceptual
[ICC-header] Connection Space Illuminant : 0.9642 1 0.82491
[ICC-header] Profile Creator : HP
[ICC-header] Profile ID : 0
[ICC_Profile] Profile Copyright : Copyright (c) 1998 Hewlett-Packard Company
[ICC_Profile] Profile Description : sRGB IEC61966-2.1
[ICC_Profile] Media White Point : 0.95045 1 1.08905
[ICC_Profile] Media Black Point : 0 0 0
[ICC_Profile] Red Matrix Column : 0.43607 0.22249 0.01392
[ICC_Profile] Green Matrix Column : 0.38515 0.71687 0.09708
[ICC_Profile] Blue Matrix Column : 0.14307 0.06061 0.7141
[ICC_Profile] Device Mfg Desc : IEC http://www.iec.ch
[ICC_Profile] Device Model Desc : IEC 61966-2.1 Default RGB colour space - sRGB
[ICC_Profile] Viewing Cond Desc : Reference Viewing Condition in IEC61966-2.1
[ICC_Profile] Luminance : 76.03647 80 87.12462
[ICC_Profile] Technology : Cathode Ray Tube Display
[ICC_Profile] Red Tone Reproduction Curve : (Binary data 2060 bytes, use -b option to extract)
[ICC_Profile] Green Tone Reproduction Curve : (Binary data 2060 bytes, use -b option to extract)
[ICC_Profile] Blue Tone Reproduction Curve : (Binary data 2060 bytes, use -b option to extract)
[ICC-view] Viewing Cond Illuminant : 19.6445 20.3718 16.8089
[ICC-view] Viewing Cond Surround : 3.92889 4.07439 3.36179
[ICC-view] Viewing Cond Illuminant Type : D50
[ICC-meas] Measurement Observer : CIE 1931
[ICC-meas] Measurement Backing : 0 0 0
[ICC-meas] Measurement Geometry : Unknown (0)
[ICC-meas] Measurement Flare : 0.999%
[ICC-meas] Measurement Illuminant : D65
[Adobe] DCT Encode Version : 100
[Adobe] APP14 Flags 0 : [14]
[Adobe] APP14 Flags 1 : (none)
[Adobe] Color Transform : YCbCr
[Composite] Aperture : 2.0
[Composite] Date/Time Created : 2004:02:15 11:07:39-05:00
[Composite] GPS Date/Time : 2004:02:15 16:07:39Z
[Composite] GPS Latitude : 14 deg 34' 0.00" N
[Composite] GPS Longitude : 90 deg 44' 0.00" W
[Composite] GPS Position : 14 deg 34' 0.00" N, 90 deg 44' 0.00" W
[Composite] Image Size : 2244x1752
[Composite] Shutter Speed : 1/20
[Composite] Thumbnail Image : (Binary data 5435 bytes, use -b option to extract)
[Composite] Focal Length : 9.0 mm
[Composite] Light Value : 4.6
There are a number of differences between these files:
1) The bad file doesn't contain a JFIF segment
2) The bad file contains makernote information
3) The bad file contains IPTC
4) The bad file contains GPS in the XMP too
5) The good file has an ICC_Profile
Plus other differences.
I suggest using exiftool to incrementally change the information in the good file to match the bad file until you find the exact difference that breaks it for your PHP reader.
- Phil
I just ran a test where I had PhotoShop re-write the file after making essentially no changes and php can now read the GPS metatdata.
Quote from: Phil Harvey on August 03, 2012, 11:53:51 AMI suggest using exiftool to incrementally change the information in the good file to match the bad file until you find the exact difference that breaks it for your PHP reader.
Sorry for being a bit dense with regards to your suggestion, but how does one do the above? Are you suggesting making changes to each section using exiftool until it works?
-- Geoff
Quote from: geoffschultz on August 03, 2012, 12:09:12 PM
Sorry for being a bit dense with regards to your suggestion, but how does one do the above? Are you suggesting making changes to each section using exiftool until it works?
Yes. Start by copying the good file to test.jpg, then do this:
1) Remove the JFIF section
exiftool -jfif:all= test.jpg2) copy the maker notes
exiftool -tagsfromfile bad.jpg -makernotes test.jpg3) copy the IPTC
exiftool -tagsfromfile bad.jpg -iptc:all test.jpg4) copy missing XMP tags
exiftool -tagsfromfile bad.jpg -xmp:all test.jpg5) delete the ICC_Profile
exiftool -icc_profile= test.jpgetc... until the test file is the same as bad.jpg.
And try reading with PHP after each step.
- Phil
Quote from: Phil Harvey on August 03, 2012, 12:14:35 PM
1) Remove the JFIF section
exiftool -jfif:all= test.jpg
When I execute the above command, I get the following message:
0 image files updated
1 image files unchanged
When I examine the file using exiftool -a -G1, it appears the same as bad.jpg
-- Geoff
Hi Geoff,
Did you start by copying the good version to "test.jpg"?
I suggest that you don't just follow my instructions blindly. Instead, think about what you are doing and use your own detective skills along with exiftool to determine what the important differences are.
- Phil
Yes, I did copy it & I have been experimenting with other options. I stripped everything by doing an exiftool -all= test.jpg and I'm currently adding things back in. I first added EXIF and while exiftool shows the GPS data, php can't read it. I'm trying to figure out if I can delete sections of the EXIF data, but that's as far as I've gotten.
The unfortunate issue is that I know just enough to be dangerous...
-- Geoff
Oh stupid me! I've copied bad.jpg to test.jpg!
The problem appears to be the makernotes. As soon as I add them back in, php can no longer read the GPS metadata. I can delete the makernotes and have it function properly. This it appears that I have 1 or 2 options.
1) Write a script to delete the makernotes from any unedited image
2) To get exiftool to modify the makernotes into a format similar to what Photoshop is doing.
Is #2 possible? I'd prefer not to lose the makernotes, but I have copies of the unedited files elsewhere should I ever need that info.
-- Geoff
Hi Geoff,
Photoshop deletes the maker notes of edited images.
- Phil
For anyone else who might be having similar issues, here's how I ended up solving it.
I decided to write a Power Shell script and found the following code to extract EXIF/IPTC/etc fields:
#Constants for Strings
$ExifIDDateTimeTaken = 36867 # 0x9003
$ExifIDImageDescription = 270 # 0x010E
$ExifIDMake = 271 # 0x010F
$ExifIDModel = 272 # 0x0110
$ExifIDSoftware = 305 # 0x0131
$ExifIDArtist = 315 # 0x013B
$ExifIDCopyright = 33432 # 0x8298
$ExifIDGPSLatRef = 1
$ExifIDGPSLongRef = 3
$ExifIDGPSAltRef = 5
#Constants For Unicode strings
$ExifIDTitle = 40091 # 0x9C9B XP Title binary data
$ExifIDAuthor = 40093 # 0x9C9D XP Author
$ExifIDKeywords = 40094 # 0x9C9E XP Keywords
$ExifIDSubject = 40095 # 0x9C9F XP Subject
#$ExifIDComment = 40092 # 0x9C9C XP Comment
$ExifIDComment = 37510 # 0x9286 UserComment
#Constants For TOKEN numbers
$ExifIDColorSpace = 40961 # 0xA001
$ExifIDContrast = 41992 # 0xA408f
$ExifIDExposureMode = 41986 # 0xA402
$ExifIDExposureProgram = 34850 # 0x8822
$ExifIDFlash = 37385 # 0x9209
$ExifIDLightSource = 37384 # 0x9208
$ExifIDMeteringMode = 37383 # 0x9207
$ExifIDSaturation = 41993 # 0xA409
$ExifIDSceneCaptutreMode = 41990 # 0xA406
$ExifIDSharpness = 41994 # 0xA40A
$ExifIDSubjectRange = 41996 # 0xA40C
$ExifIDWhiteBalance = 41987 # 0xA403
#Constants for special case ratios
$ExifIDExposuretime = 33434 # 0x829A
$ExifIDGPSLattitude = 2
$ExifIDGPSLongitude = 4
#Constants for normal numbers
$ExifIDDigitalZoomRatio = 41988 # 0xA404
$ExifIDExpbias = 37380 # 0x9204
$ExifIDFNumber = 33437 # 0x829D
$ExifIDFocalLength = 37386 # 0x920A
$ExifIDFocalLengthIn35mmFormat = 41989 # 0xa405
$ExifIDHeight = 40963 # 0xA003
$ExifIDISO = 34855 # 0x8827
$ExifIDMaxApperture = 37381 # 0x9205
$ExifIDWidth = 40962 # 0xA002
$ExifIDGPSAltitude = 6
$ExifIDOrientation = 274 # 0x0112
$ExifIDRating = 18246 # 0x4746
#Constants For Byte Arrays
$ExifIDFileSource = 41728 # 0xA300
$ExifIDMakerNote = 37500 # 0x927C
$ExifIDGPSVer = 0
Function Get-ExifItem {
[CmdletBinding()]
<#
.Synopsis
Returns an single item of Generic Exif data
.Description
Returns the data part of a single EXIF property item -not the type.
.Example
C:\PS> Get-ExifItem -image $image -ExifID $ExifIDModel
Returns the Camera model string
.Parameter image
The image from which the data will be read
.Parameter ExifID
The ID of the required data field.
The module defines constants with names beginning $ExifID for the most used ones.
#>
Param ( [Parameter(ValueFromPipeline=$true)]
[__ComObject]$image,
$ExifID
)
Process {
foreach ($id in $exifID) {
try {$item = $image.Properties.Item("$ID") }
Catch { Write-Verbose "Error getting exif item $ID - probably doesn't exist" ; continue }
if ($item) {
Write-Verbose "Type is $($item.type)"
if (($item.Type -eq 1007) -or ($item.Type -eq 1006) ) { # "Rational"=1006;"URational"=1007
if (($ExifID -eq $ExifIDExposuretime) -and ($item.Value.Numerator -eq 1) ) {"1/$($item.Value.Denominator)"} else {$item.value.value} }
elseif (($item.type -eq 1101) -or ($item.type -eq 1100)) {$item.value.string() } # "VectorOfByte"=1101
else {$item.value}
}
}
}
}
Function Get-Exif{
<#
.Synopsis
Returns an object containing Exif data
.Description
Returns an object containing Exif data
.Parameter image
The image from which the data will be read
.Example
C:\ps> get-image IMG_1234.JPG | get-exif
Returns the exif summary for the specified file
.Example
C:\ps> Get-exif .\*.JPG | format-table -auto Path, iso,Fnumber,exposuretime
Gets the exif data for all the files in the current folder
and returns a table of exposure information.
#>
Param ( [Parameter(ValueFromPipeline=$true,Mandatory=$true)]$image)
Process {
if ($image -is [system.io.fileinfo] ) {$image = $image.FullName }
if ($image -is [String] ) {$image = Get-Image $image}
if ($image.count -gt 1 ) {$image | ForEach-Object {Get-Exif $_} ; Return}
$myvar =[int](Get-ExifItem -image $image -ExifID $ExifIDFlash)
$flash=""
If ($myvar –band 1) {$Flash += "Flash fired"}
If ($myvar -bAnd 4) {$Flash += ", return"
If ($myvar -bAnd 2) {$flash += " detected"} else {$Flash += "not detected"}
}
If ($myvar -bAnd 8) { If (($myvar-bAnd 16) -eq 16) {$Flash = "Flash Auto, " + $flash} else {$flash = "Flash on, " + $flash} }
ElseIf ($myvar -bAnd 16) {$flash = "Flash off. " }
If ($myvar -bAnd 32) {$flash = "No Flash function" }
If ($myvar -bAnd 64) {$flash += ", Red Eye reduction" }
$Keywords = Get-ExifItem -image $image -ExifID $ExifIDKeywords
if ($keywords) {$keywords = $keywords.Split(";") }
$gps = ""
$l=(get-ExifItem -image $image -ExifID $ExifIDGPSLattitude)
if ($l.count -eq 3) {$gps += "$($l[0].value)°$($l[1].value)'$($l[2].value)"""}
if ($l.count -eq 2) {$gps += "$($l[0].value)°$($l[1].value)'" }
$gps = $GPS += (get-ExifItem -image $image -ExifID $ExifIDGPSLatRef)
$l=(get-ExifItem -image $image -ExifID $ExifIDGPSLongitude)
if ($l.count -eq 3) {$gps += " $($l[0].value)°$($l[1].value)'$($l[2].value)"""}
if ($l.count -eq 2) {$gps += " $($l[0].value)°$($l[1].value)'" }
$gps = $GPS += (get-ExifItem -image $image -ExifID $ExifIDGPSLongRef)
$altref = get-ExifItem -image $image -ExifID $ExifIDGPSAltRef
if ($altRef -EQ 0) {$gps += ", $(get-ExifItem -image $image -ExifID $ExifIDGPSAltitude)M above Sea Level"}
if ($altRef -EQ 1) {$gps += ", $(get-ExifItem -image $image -ExifID $ExifIDGPSAltitude)M below Sea Level"}
$dt = (get-ExifItem -image $image -ExifID $ExifIDDateTimeTaken)
if ($dt) {$dt = [DateTime]::ParseExact($dt,"yyyy:MM:dd HH:mm:ss",[System.Globalization.CultureInfo]::InvariantCulture) }
New-Object PSObject -Property @{Flash = $flash
Keywords = $Keywords
GPS = $GPS
DateTaken = $dt
Path = $Image.FullName
Manufacturer = (Get-ExifItem -image $image -ExifID $ExifIDMake)
Model = (Get-ExifItem -image $image -ExifID $ExifIDModel)
Software = (Get-ExifItem -image $image -ExifID $ExifIDSoftware)
Subject = (Get-ExifItem -image $image -ExifID $ExifIDSubject)
Title = (Get-ExifItem -image $image -ExifID $ExifIDTitle)
Comment = (Get-ExifItem -image $image -ExifID $ExifIDComment)
Author = (Get-ExifItem -image $image -ExifID $ExifIDAuthor)
Copyright = (Get-ExifItem -image $image -ExifID $ExifIDCopyright)
Artist = (Get-ExifItem -image $image -ExifID $ExifIDArtist)
StarRating = (Get-ExifItem -image $image -ExifID $ExifIDRating)
ISO = (Get-ExifItem -image $image -ExifID $ExifIDISO)
ExposureBias = (Get-ExifItem -image $image -ExifID $ExifIDExpbias)
Exposuretime = (Get-ExifItem -image $image -ExifID $ExifIDExposuretime)
FNumber = (Get-ExifItem -image $image -ExifID $ExifIDFNumber)
MaxApperture = (Get-ExifItem -image $image -ExifID $ExifIDMaxApperture)
FocalLength = (Get-ExifItem -image $image -ExifID $ExifIDFocalLength)
FocalLength35mm = (Get-ExifItem -image $image -ExifID $ExifIDFocalLengthIn35mmFormat)
DigitalZoomRatio = (Get-ExifItem -image $image -ExifID $ExifIDDigitalZoomRatio)
Height = (Get-ExifItem -image $image -ExifID $ExifIDHeight )
Width = (Get-ExifItem -image $image -ExifID $ExifIDWidth)
SubjectRange = @{1="Macro"; 2="Close"; 3="Distant"}[[int]( Get-ExifItem -image $image -ExifID $ExifIDSubjectRange)]
ExposureMode = @{0="Auto"; 1="Manual"; 2="Auto Bracket"}[[int]( Get-ExifItem -image $image -ExifID $ExifIDExposureMode)]
WhiteBalance = @{0="Auto"; 1="Manual" }[[int]( Get-ExifItem -image $image -ExifID $ExifIDWhiteBalance)]
Contrast = @{0="Normal"; 1="Soft"; 2="Hard" }[[int]( Get-ExifItem -image $image -ExifID $ExifIDContrast)]
Sharpness = @{0="Normal"; 1="Soft"; 2="Hard" }[[int]( Get-ExifItem -image $image -ExifID $ExifIDSharpness)]
Saturation = @{0="Normal"; 1="Low"; 2 ="High"}[[int]( Get-ExifItem -image $image -ExifID $ExifIDSaturation)]
Orientation = @{1="0"; 3="180"; 6="270"; 8="90"}[[int]( Get-ExifItem -image $image -ExifID $ExifIDOrientation) ] # (0 -=Row 0 is Top, Col 0 is left / 180=Inverted, Row 0 Bottom and col 0 is Right / 270=90 Degrees CounterClockWise, Row 0 is right and col 0 is top / 90=90 Degrees ClockWise, row 0 is left, Col 0 is bottom
ColorSpace = @{1="sRGB"; 2="Adobe RGB" }[[int]( Get-ExifItem -image $image -ExifID $ExifIDColorSpace) ] #'(the value of 2 is not standard EXIF. Instead, an Adobe RGB image is indicated by "Uncalibrated" with an InteropIndex of "R03"')
FileSource = @{1="Film scanner"; 2="Print scanner"; 3="Digital still camera"}[[int]( Get-ExifItem -image $image -ExifID $ExifIDFileSource)]
CaptureMode = @{0="Standard"; 1="Landscape"; 2="Portrait"; 3="NightScene"}[[int]( Get-ExifItem -image $image -ExifID $ExifIDSceneCaptutreMode)]
MeteringMode = @{1="Av"; 2="Centre"; 3="Spot"; 4="Multi-Spot"; 5="Multi-Segment"; 6="Partial"}[[int]( Get-ExifItem -image $image -ExifID $ExifIDMeteringMode)]
ExposureProgram = @{1="Manual"; 2="Program: Normal"; 3="Aperture Priority"; 4="Shutter Priority"; 5="Program: Creative"; 6="Program: Action"; 7="Portrait Mode"; 8="Landscape Mode"}[[int]( Get-ExifItem -image $image -ExifID $ExifIDExposureProgram)] # Manual includes Bulb, X-Sync Mode Pentax Sv Mode and TAv mode report 0 - unknown. Creative is Depth of field Biased and Action is shutter biased
LightSource = @{0="Auto"; 1="Daylight"; 2="Fluorescent"; 3="Tungsten"; 4="Flash"; 9="Fine Weather"; 10="Cloudy Weather"; 11="Shade"; 12="Daylight Fluorescent"; 13="Day White Fluorescent"; 14="Cool White Fluorescent"; 15="White Fluorescent"; 17="Standard Light A"; 18="Standard Light B"; 19="Standard Light C"; 20="D55"; 21="D65"; 22="D75"; 23="D50"; 24="ISO Studio Tungsten"}[[int]( Get-ExifItem -image $image -ExifID $ExifIDLightSource)]
}
}
}
#requires -version 2.0
function Get-Image {
<#
.Synopsis
Returns an image object for a file
.Description
Uses the Windows Image Acquisition COM object to get image data
.Example
Get-ChildItem $env:UserProfile\Pictures -Recurse | Get-Image
.Parameter file
The file to get an image from
#>
param(
[Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)]
[Alias('FullName',"FileName")]
[ValidateScript({Test-path $_ })][string]$Path)
process {
foreach ($file in (resolve-path -Path $path) ) {
$image = New-Object -ComObject Wia.ImageFile
try {
Write-Verbose "Loading file $($realItem.FullName)"
$image.LoadFile($file.path)
$image |
Add-Member NoteProperty FullName $File -PassThru |
Add-Member ScriptMethod Resize {
param($width, $height, [switch]$DoNotPreserveAspectRatio)
$image = New-Object -ComObject Wia.ImageFile
$image.LoadFile($this.FullName)
$filter = Add-ScaleFilter @psBoundParameters -passThru -image $image
$image = $image | Set-ImageFilter -filter $filter -passThru
Remove-Item $this.Fullname
$image.SaveFile($this.FullName)
} -PassThru |
Add-Member ScriptMethod Crop {
param([Double]$left, [Double]$top, [Double]$right, [Double]$bottom)
$image = New-Object -ComObject Wia.ImageFile
$image.LoadFile($this.FullName)
$filter = Add-CropFilter @psBoundParameters -passThru -image $image
$image = $image | Set-ImageFilter -filter $filter -passThru
Remove-Item $this.Fullname
$image.SaveFile($this.FullName)
} -PassThru |
Add-Member ScriptMethod FlipVertical {
$image = New-Object -ComObject Wia.ImageFile
$image.LoadFile($this.FullName)
$filter = Add-RotateFlipFilter -flipVertical -passThru
$image = $image | Set-ImageFilter -filter $filter -passThru
Remove-Item $this.Fullname
$image.SaveFile($this.FullName)
} -PassThru |
Add-Member ScriptMethod FlipHorizontal {
$image = New-Object -ComObject Wia.ImageFile
$image.LoadFile($this.FullName)
$filter = Add-RotateFlipFilter -flipHorizontal -passThru
$image = $image | Set-ImageFilter -filter $filter -passThru
Remove-Item $this.Fullname
$image.SaveFile($this.FullName)
} -PassThru |
Add-Member ScriptMethod RotateClockwise {
$image = New-Object -ComObject Wia.ImageFile
$image.LoadFile($this.FullName)
$filter = Add-RotateFlipFilter -angle 90 -passThru
$image = $image | Set-ImageFilter -filter $filter -passThru
Remove-Item $this.Fullname
$image.SaveFile($this.FullName)
} -PassThru |
Add-Member ScriptMethod RotateCounterClockwise {
$image = New-Object -ComObject Wia.ImageFile
$image.LoadFile($this.FullName)
$filter = Add-RotateFlipFilter -angle 270 -passThru
$image = $image | Set-ImageFilter -filter $filter -passThru
Remove-Item $this.Fullname
$image.SaveFile($this.FullName)
} -PassThru
} catch {
Write-Verbose $_
}
}
}
}
I then wrote this small Power Shell script which walks through all of single-level-deep subdirectories of a master directory. It looks for string "29-1103" in the EXIF data, which in my case indicated that the image hadn't been edited by Photoshop and had the makernotes attached. If that string was seen, then I use exiftool to delete the makernotes. This worked wonderfully on thousands of images, just updating the ones that needed to be updated. In reality I probably could have just did a "-makernotes" on *.jpg for each directory, but I didn't think of that until I had written this. Oh well, use it as you may!
-- Geoff
$dirs = @(dir -Path "G:\top-level-dir")
foreach ($dir in $dirs) {
if ($dir.GetType().FullName -eq 'System.IO.DirectoryInfo') {
$path_jpg = $dir.FullName + "\*.jpg"
$files = @(dir $path_jpg)
foreach ($file in $files) {
$software = @(Get-exif $file) | Select-String "29-1103"
if ($software) {
$command = '"-makernotes=" ' + $file
echo $command
&exiftool $command
}
}
}