apache/commons-imaging — pull request #1 by kstokoz (2014-05-22 10:31:20+00:00)
Title: XPTitle info tag can be a ascii string

Feels like another windows hack, but I have an image created by Windows Lumia Phone which contains
XP Title encoded as ascii value, which somehow contradicts exif spec.

Unfortunately I cannot contribute an image to this repository for testing, but here is
EXIF before change:
Root:
ImageDescription: 'Pyöräilykauden avaus ja samalla visiitti remontoituun talvipuutarhaan'
Make: 'Nokia'
Model: 'Nokia Lumia 800'
Orientation: 1
XResolution: 72
YResolution: 72
ResolutionUnit: 2
Software: 'Windows Phone 7.5'
Artist: ''
YCbCrPositioning: 1
Rating: 0
RatingPercent: 0
ExifOffset: 2394
GPSInfo: 4718
XPTitle: Invalid value: Text field not encoded as bytes.
Padding: 28, -22, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0... (2060)

Exif:
ExposureTime: 1/1404 (0.001)
FNumber: 22/10 (2.2)
ExifVersion: 48, 50, 50, 48
DateTimeOriginal: '2012:04:15 14:25:06'
DateTimeDigitized: '2012:04:15 14:25:06'
ComponentsConfiguration: 1, 2, 3, 0
MeteringMode: 2
Flash: 16
FlashpixVersion: 48, 49, 48, 48
ColorSpace: 1
ExifImageWidth: 3264
ExifImageLength: 2448
ImageUniqueID: '3C15D8C63616CF3528F5AB6EC5C093F3'
Padding: 28, -22, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0... (2060)

Gps:
....

Sub: (jpegImageData)
Compression: 6
XResolution: 72
YResolution: 72
ResolutionUnit: 2
JpgFromRawStart: 5064
JpgFromRawLength: 18387

With following exception reading EXIF data:
org.apache.commons.imaging.ImageWriteException: Text field not encoded as bytes.
at org.apache.commons.imaging.formats.tiff.TiffImageMetadata$Directory.getOutputDirectory(TiffImageMetadata.java:176)
at org.apache.commons.imaging.formats.tiff.TiffImageMetadata.getOutputSet(TiffImageMetadata.java:229)

EXIF Info after change:
Root:
ImageDescription: 'Pyöräilykauden avaus ja samalla visiitti remontoituun talvipuutarhaan'
Make: 'Nokia'
Model: 'Nokia Lumia 800'
Orientation: 1
XResolution: 72
YResolution: 72
ResolutionUnit: 2
Software: 'Windows Phone 7.5'
Artist: ''
YCbCrPositioning: 1
Rating: 0
RatingPercent: 0
ExifOffset: 2394
GPSInfo: 4718
XPTitle: 'Pyöräilykauden avaus ja samalla visiitti remontoituun talvipuutarhaan'
Padding: 28, -22, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0... (2060)

Exif:
ExposureTime: 1/1404 (0.001)
FNumber: 22/10 (2.2)
ExifVersion: 48, 50, 50, 48
DateTimeOriginal: '2012:04:15 14:25:06'
DateTimeDigitized: '2012:04:15 14:25:06'
ComponentsConfiguration: 1, 2, 3, 0
MeteringMode: 2
Flash: 16
FlashpixVersion: 48, 49, 48, 48
ColorSpace: 1
ExifImageWidth: 3264
ExifImageLength: 2448
ImageUniqueID: '3C15D8C63616CF3528F5AB6EC5C093F3'
Padding: 28, -22, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0... (2060)

Gps:
..

Sub: (jpegImageData)
Compression: 6
XResolution: 72
YResolution: 72
ResolutionUnit: 2
JpgFromRawStart: 5064
JpgFromRawLength: 18387

TiffOutputSet {
byteOrder: BIG_ENDIAN
directory 0: Root (0)
field 0: [TagInfo. tag: 270 (0x10e, name: ImageDescription]
field 0: [TagInfo. tag: 271 (0x10f, name: Make]
field 0: [TagInfo. tag: 272 (0x110, name: Model]
field 0: [TagInfo. tag: 274 (0x112, name: Orientation]
field 0: [TagInfo. tag: 282 (0x11a, name: XResolution]
field 0: [TagInfo. tag: 283 (0x11b, name: YResolution]
field 0: [TagInfo. tag: 296 (0x128, name: ResolutionUnit]
field 0: [TagInfo. tag: 305 (0x131, name: Software]
field 0: [TagInfo. tag: 315 (0x13b, name: Artist]
field 0: [TagInfo. tag: 531 (0x213, name: YCbCrPositioning]
field 0: [TagInfo. tag: 18246 (0x4746, name: Rating]
field 0: [TagInfo. tag: 18249 (0x4749, name: RatingPercent]
field 0: [TagInfo. tag: 40091 (0x9c9b, name: XPTitle]
field 0: [TagInfo. tag: 59932 (0xea1c, name: Padding]
directory 1: Exif (-2)
field 1: [TagInfo. tag: 33434 (0x829a, name: ExposureTime]
field 1: [TagInfo. tag: 33437 (0x829d, name: FNumber]
field 1: [TagInfo. tag: 36864 (0x9000, name: ExifVersion]
field 1: [TagInfo. tag: 36867 (0x9003, name: DateTimeOriginal]
field 1: [TagInfo. tag: 36868 (0x9004, name: DateTimeDigitized]
field 1: [TagInfo. tag: 37121 (0x9101, name: ComponentsConfiguration]
field 1: [TagInfo. tag: 37383 (0x9207, name: MeteringMode]
field 1: [TagInfo. tag: 37385 (0x9209, name: Flash]
field 1: [TagInfo. tag: 40960 (0xa000, name: FlashpixVersion]
field 1: [TagInfo. tag: 40961 (0xa001, name: ColorSpace]
field 1: [TagInfo. tag: 40962 (0xa002, name: ExifImageWidth]
field 1: [TagInfo. tag: 40963 (0xa003, name: ExifImageLength]
field 1: [TagInfo. tag: 42016 (0xa420, name: ImageUniqueID]
field 1: [TagInfo. tag: 59932 (0xea1c, name: Padding]
directory 2: Gps (-3)
field 2: [TagInfo. tag: 1 (0x1, name: GPSLatitudeRef]
field 2: [TagInfo. tag: 2 (0x2, name: GPSLatitude]
field 2: [TagInfo. tag: 3 (0x3, name: GPSLongitudeRef]
field 2: [TagInfo. tag: 4 (0x4, name: GPSLongitude]
field 2: [TagInfo. tag: 5 (0x5, name: GPSAltitudeRef]
field 2: [TagInfo. tag: 6 (0x6, name: GPSAltitude]
field 2: [TagInfo. tag: 10 (0xa, name: GPSMeasureMode]
field 2: [TagInfo. tag: 11 (0xb, name: GPSDOP]
directory 3: Sub (1)
field 3: [TagInfo. tag: 259 (0x103, name: Compression]
field 3: [TagInfo. tag: 282 (0x11a, name: XResolution]
field 3: [TagInfo. tag: 283 (0x11b, name: YResolution]
field 3: [TagInfo. tag: 296 (0x128, name: ResolutionUnit]
field 3: [TagInfo. tag: 514 (0x202, name: JpgFromRawLength]
}