[
https://issues.apache.org/jira/browse/IMAGING-198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16249354#comment-16249354
]
Bruno P. Kinoshita commented on IMAGING-198:
--------------------------------------------
[~Sami32] I think the issue is really with the information in the EXIF
metadata. At one point it says it has a thumbnail at a certain offset 2778,
with a certain length 9128. But the EXIF header has only 766 bytes.
I tried extracting the thumbnail manually with dd, with exiftool, and even with
GIMP. But the data from that interval seemed corrupted. Perhaps it's a
thumbnail in a format that only Sony supports?
Anyway, with this code you should be able to parse your files.
{code:java}
public static void main(String[] args) throws Exception {
File imageFile = new File("/home/kinow/Downloads/99f.jpg");
final BufferedImage image = Imaging.getBufferedImage(imageFile,
Collections.<String, Object> emptyMap());
System.out.println(image);
ByteSource byteSource = new ByteSourceFile(imageFile);
new JpegUtils().dumpJFIF(byteSource);
Map<String, Object> params = new HashMap<>();
params.put(ImagingConstants.PARAM_KEY_READ_THUMBNAILS, false);
final JpegImageMetadata metadata = (JpegImageMetadata)
Imaging.getMetadata(imageFile, params);
System.out.println(metadata);
}
{code}
Which outputs:
{noformat}
6 markers
BufferedImage@3a3e162d: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00
bmask=ff amask=0 IntegerInterleavedRaster: width = 450 height = 300 #Bands = 3
xOff = 0 yOff = 0 dataOffset[0] 0
Segment marker: ffe1 (JPEG_APP1_MARKER), 764 bytes of segment data.
Segment marker: ffec (Unknown), 85 bytes of segment data.
Segment marker: ffee (JPEG_APP14_MARKER), 12 bytes of segment data.
Segment marker: ffdb (DQT_MARKER), 130 bytes of segment data.
Segment marker: ffc0 (SOF0_MARKER), 15 bytes of segment data.
Segment marker: ffc4 (SOF4_MARKER), 173 bytes of segment data.
SOS marker. 30678 bytes of image data.
6 markers
Exif metadata:
Root:
BitsPerSample: 8, 8, 8
ImageDescription: ''
Make: 'SONY'
Model: 'DSC-R1'
Orientation: 1
SamplesPerPixel: 3
XResolution: 72
YResolution: 72
ResolutionUnit: 2
Software: 'ImageReady'
DateTime: '2009-02-09T11:54:31+01:00'
JPEGInterchangeFormat: 2778
JPEGInterchangeFormatLength: 9128
YCbCrPositioning: 2
Copyright: ''
ExifOffset: 312
Exif:
ExposureTime: 10/6400 (0.002)
FNumber: 8
ExposureProgram: 2
PhotographicSensitivity: 160
ExifVersion: 48, 50, 50
DateTimeOriginal: '2007:02:17 22:49:04'
DateTimeDigitized: '2007:02:17 22:49:04'
ComponentsConfiguration: 0
CompressedBitsPerPixel: 8
ExposureCompensation: 0
MaxApertureValue: 47/16 (2.938)
MeteringMode: 5
LightSource: 0
Flash: 0, 0, 3, 3, 3
FocalLength: 187/10 (18.7)
FlashpixVersion: 48, 49, 48
ColorSpace: 1
ExifImageWidth: 450
ExifImageLength: 300
FileSource: 3
SceneType: 1
CustomRendered: 0
ExposureMode: 0
WhiteBalance: 0
SceneCaptureType: 0
Contrast: 2
Saturation: 0
Sharpness: 0
No Photoshop (IPTC) metadata.
{noformat}
Notice that the main change is explicitly telling the parser to ignore
thumbnails. By default the JPEG parser will instruct the TIFF Reader (used to
parse EXIF data) to try to extract the thumbnail image data. Which in your
image case, lies outside the EXIF header data.
> Error while parsing JPEG with EXIF metadata with Imaging 1.0 (Sony DSC-R1)
> --------------------------------------------------------------------------
>
> Key: IMAGING-198
> URL: https://issues.apache.org/jira/browse/IMAGING-198
> Project: Commons Imaging
> Issue Type: Bug
> Components: Format: JPEG
> Affects Versions: 1.0
> Environment: Windows and Java 7u80
> Reporter: Samuel
> Assignee: Bruno P. Kinoshita
> Labels: EXIF, JPEG
> Attachments: 99f.jpg, 99f_jpg.html
>
>
> An example of a JPEG image with EXIF metadata, coming from a Sony DSC-R1
> camera, that will not be parsed with commons-imaging 1.0.
> http://imgur.com/a/fl9D9
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)