Unable to Read EXIF attributes from Image
Posted: 2013-04-04T10:21:55-07:00
I am attempting to read EXIF data from Images so I can store this information for later use and I am unable to read any attributes from the images I have. I downloaded and built the latest source for Windows ImageMagick-6.8.4 sucessfully, and when I run the provided application for viewing image info (identify.exe) it works fine:
However when I attempt the same thing pragmatically, I am getting NULL for the values:
Generates the following ouput:
What am I missing?
Code: Select all
D:\common\ImageMagick-6.8.4\VisualMagick\bin>identify.exe -verbose d:\exif.jpg
Image: d:\exif.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 3264x2448+0+0
Resolution: 72x72
Print size: 45.3333x34
Units: PixelsPerInch
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Red:
min: 0 (0)
max: 255 (1)
mean: 109.709 (0.430231)
standard deviation: 54.4065 (0.213359)
kurtosis: -0.694073
skewness: 0.288088
Green:
min: 0 (0)
max: 255 (1)
mean: 91.2706 (0.357924)
standard deviation: 63.2079 (0.247874)
kurtosis: -0.838898
skewness: 0.540127
Blue:
min: 0 (0)
max: 255 (1)
mean: 79.2321 (0.310714)
standard deviation: 65.8599 (0.258274)
kurtosis: -0.0994204
skewness: 0.905364
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 93.4039 (0.36629)
standard deviation: 61.3537 (0.240603)
kurtosis: -0.491345
skewness: 0.545162
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 3264x2448+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 98
Orientation: RightTop
Properties:
date:create: 2013-04-03T14:26:08-04:00
date:modify: 2013-03-26T13:01:18-04:00
exif:ApertureValue: 281/100
exif:BrightnessValue: 497/100
exif:ColorSpace: 1
exif:Compression: 6
exif:DateTime: 2013:03:26 13:00:13
exif:DateTimeDigitized: 2013:03:26 13:00:13
exif:DateTimeOriginal: 2013:03:26 13:00:13
exif:ExifImageLength: 2448
exif:ExifImageWidth: 3264
exif:ExifOffset: 224
exif:ExifVersion: 48, 50, 50, 48
exif:ExposureBiasValue: 0/100
exif:ExposureMode: 0
exif:ExposureProgram: 3
exif:ExposureTime: 1/50
exif:Flash: 9
exif:FlashPixVersion: 48, 49, 48, 48
exif:FNumber: 265/100
exif:FocalLength: 397/100
exif:ImageLength: 2448
exif:ImageUniqueID: OMEF01
exif:ImageWidth: 3264
exif:ISOSpeedRatings: 32
exif:JPEGInterchangeFormat: 860
exif:JPEGInterchangeFormatLength: 59136
exif:Make: SAMSUNG
exif:MakerNote: 5, 0, 1, 0, 7, 0, 4, 0, 0, 0, 48, 49, 48, 48, 2, 0, 4, 0, 1,
0, 0, 0, 0, 32, 1, 0, 64, 0, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 80, 0, 4, 0, 1, 0, 0
, 0, 1, 0, 0, 0, 0, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
exif:MaxApertureValue: 281/100
exif:MeteringMode: 2
exif:Model: GT-I9100
exif:Orientation: 6
exif:ResolutionUnit: 2
exif:SceneCaptureType: 0
exif:ShutterSpeedValue: 564/100
exif:Software: I9100XXLPQ
exif:thumbnail:Orientation: 6
exif:thumbnail:ResolutionUnit: 2
exif:thumbnail:XResolution: 72/1
exif:thumbnail:YResolution: 72/1
exif:UserComment: 65, 83, 67, 73, 73, 0, 0, 0, 85, 115, 101, 114, 32, 99, 11
1, 109, 109, 101, 110, 116, 115
exif:WhiteBalance: 0
exif:XResolution: 72/1
exif:YCbCrPositioning: 1
exif:YResolution: 72/1
jpeg:colorspace: 2
jpeg:sampling-factor: 2x1,1x1,1x1
signature: ec1b7da9de8b91c89bc7e79d69965b05a07262054f5b0fb778a9e58a58504ae4
Profiles:
Profile-exif: 60002 bytes
Artifacts:
filename: d:\exif.jpg
verbose: true
Tainted: False
Filesize: 3.692MB
Number pixels: 7.99M
Pixels per second: 10.23MB
User time: 0.750u
Elapsed time: 0:01.781
Version: ImageMagick 6.8.4-6 2013-04-01 Q16 http://www.imagemagick.org
Code: Select all
void main()
{
//-- ImageMagick
InitializeMagick("D:\\common\\ImageMagick-6.8.4\\VisualMagick\\bin");
char cInFile[MAX_PATH];
char cOutFile[MAX_PATH];
strcpy_s( cInFile, MAX_PATH, "d:\\exif.jpg" );
Image img_test;
img_test.read(cInFile);
img_test.verbose(true);
printf("DateTime: %s\n", img_test.attribute("EXIF:DateTime" ));
printf("Make: %s\n", img_test.attribute("EXIF:Make" ));
printf("Flash: %s\n", img_test.attribute("EXIF:Flash" ));
printf("Compression: %s\n", img_test.attribute("EXIF:Compression" ));
printf("XResolution: %s\n", img_test.attribute("EXIF:XResolution" ));
printf("YResolution: %s\n", img_test.attribute("EXIF:YResolution" ));
printf("MeteringMode: %s\n", img_test.attribute("EXIF:MeteringMode" ));
printf("ExposureProgram: %s\n", img_test.attribute("EXIF:ExposureProgram" ));
printf("ColorSpace: %s\n", img_test.attribute("EXIF:ColorSpace" ));
printf("UserComment: %s\n", img_test.attribute("EXIF:UserComment" ));
printf("ImageLength: %s\n", img_test.attribute("EXIF:ImageLength" ));
printf("Orientation: %s\n", img_test.attribute("EXIF:Orientation" ));
printf("ExposureTime: %s\n", img_test.attribute("EXIF:ExposureTime" ));
printf("ApertureValue: %s\n", img_test.attribute("EXIF:ApertureValue" ));
printf("ImageWidth: %s\n", img_test.attribute("EXIF:ImageWidth" ));
printf("ISOSpeedRatings: %s\n", img_test.attribute("EXIF:ISOSpeedRatings" ));
printf("ShutterSpeedValue: %s\n", img_test.attribute("EXIF:ShutterSpeedValue" ));
printf("WhiteBalance: %s\n", img_test.attribute("EXIF:WhiteBalance" ));
}
Code: Select all
DateTime: (null)
Make: (null)
Flash: (null)
Compression: (null)
XResolution: (null)
YResolution: (null)
MeteringMode: (null)
ExposureProgram: (null)
ColorSpace: (null)
UserComment: (null)
ImageLength: (null)
Orientation: (null)
ExposureTime: (null)
ApertureValue: (null)
ImageWidth: (null)
ISOSpeedRatings: (null)
ShutterSpeedValue: (null)
WhiteBalance: (null)