jpg param
Last problem (I hope).
In Photoshop I can save in the jpg file some extra data like description of the image, author etc.
There is some way to exctact this information from the jpg file?
I've try with:
JPEGImageDecoder jpid=JPEGCoder.createImageDecoder(InputStream);
JPEGDecodeParam jdp=jpid.getJPEGDecodeParam();
but jpid is always NULL..
It's wrong?
This information are in the init of the file and I try to exctact it from file Stream, but if there are a builded solution is good accepted.
thanks.
[577 byte] By [
daloch] at [2007-9-26 14:02:03]

I am trying to do the same thing, though I want to extract the type of digital camera, exposure information and date taken from a different segment of the JPEG header (Photoshop uses 0xFE APPE_MARKER I think, the camera info is in 0xF1 APP1_MARKER as far as I can tell).
> JPEGImageDecoder jpid=JPEGCoder.createImageDecoder(InputStream);
> JPEGDecodeParam jdp=jpid.getJPEGDecodeParam();
> but jpid is always NULL..
...I presume you meant 'jdp' is always null. You have to actually decode something first..
The code I've written looks a little something like:
int[] markers = {JPEGDecodeParam.APP0_MARKER,
JPEGDecodeParam.APP1_MARKER,
JPEGDecodeParam.APP2_MARKER,
JPEGDecodeParam.APP3_MARKER,
JPEGDecodeParam.APP4_MARKER,
JPEGDecodeParam.APP5_MARKER,
JPEGDecodeParam.APP6_MARKER,
JPEGDecodeParam.APP7_MARKER,
JPEGDecodeParam.APP8_MARKER,
JPEGDecodeParam.APP9_MARKER,
JPEGDecodeParam.APPA_MARKER,
JPEGDecodeParam.APPB_MARKER,
JPEGDecodeParam.APPC_MARKER,
JPEGDecodeParam.APPD_MARKER,
JPEGDecodeParam.APPE_MARKER,
JPEGDecodeParam.APPF_MARKER,
JPEGDecodeParam.COMMENT_MARKER };
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in);
this.image = decoder.decodeAsBufferedImage();
JPEGDecodeParam param = decoder.getJPEGDecodeParam();
for (int i=0; i<markers.length; i++) {
byte[][] data = param.getMarkerData(markers[i]);
if (data!=null) {
for (int j=0; j><data.length; j++) {
// handle the data here... for now, just print it
String markerHex = Integer.toHexString(markers[i]).toUpperCase();
System.out.println();
System.out.println("Marker 0x"+markerHex+" part "+j+": ");
System.out.print(new String(data[j]));
System.out.println();
}
}
}
This prints out all the data, which is mostly binary mess when show as text, though you will most likely see the suff you're after in plain text.
You might find this link helpful for extraction of JPEG segments containing Photoshop meta-data.
http://www.codeproject.com/bitmap/iptc.asp
I'm still trying to find a Java implementation of this extraction, and for the extraction of digital camera information....
Anyone know of one? Sample code appreciated!>
I'm have the same problem that all of you guys : extracting meta-data from a JPEG image. I'm using JDK 1.4 and the IIOMetadata class. I can get some information, but not all of it : I don't get information for image width and height, nor information coming from my digital camera, nor information created with the Win2000 RMB+properties panel.
My question is basicaly : what are these meta-data that the Java API send back ? Why doesn't it contain all the meta-information encoded in the image ? Is it possible to get the "EXIF" information using the API ?
Thanx for helping me,
Matthieu
FYI, here is the information I get with the API
Number of images : 1
Minimum index: 0
There is no StreamMetaData associated with this image.
Native Metadata : javax_imageio_jpeg_image_1.0
metadataFormatNames :
javax_imageio_jpeg_image_1.0
javax_imageio_1.0
extraMetadataFormatNames :
[NULL]
<javax_imageio_jpeg_image_1.0>
<JPEGvariety>
<app0JFIF majorVersion="1" minorVersion="1" resUnits="0" Xdensity="1" Ydensity="1" thumbWidth="0" thumbHeight="0"/>
</JPEGvariety>
<markerSequence>
<unknown MarkerTag="225"/>
<dqt>
<dqtable elementPrecision="0" qtableId="0"/>
</dqt>
<dqt>
<dqtable elementPrecision="0" qtableId="1"/>
</dqt>
<sof process="0" samplePrecision="8" numLines="1600" samplesPerLine="1200" numFrameComponents="3">
<componentSpec componentId="1" HsamplingFactor="1" VsamplingFactor="2" QtableSelector="0"/>
<componentSpec componentId="2" HsamplingFactor="1" VsamplingFactor="1" QtableSelector="1"/>
<componentSpec componentId="3" HsamplingFactor="1" VsamplingFactor="1" QtableSelector="1"/>
</sof>
<dht>
<dhtable class="0" htableId="0"/>
</dht>
<dht>
<dhtable class="1" htableId="0"/>
</dht>
<dht>
<dhtable class="0" htableId="1"/>
</dht>
<dht>
<dhtable class="1" htableId="1"/>
</dht>
<sos numScanComponents="3" startSpectralSelection="0" endSpectralSelection="63" approxHigh="0" approxLow="0">
<scanComponentSpec componentSelector="1" dcHuffTable="0" acHuffTable="0"/>
<scanComponentSpec componentSelector="2" dcHuffTable="1" acHuffTable="1"/>
<scanComponentSpec componentSelector="3" dcHuffTable="1" acHuffTable="1"/>
</sos>
</markerSequence>
</javax_imageio_jpeg_image_1.0>
<javax_imageio_1.0>
<Chroma>
<ColorSpaceType name="YCbCr"/>
<NumChannels value="3"/>
</Chroma>
<Compression>
<CompressionTypeName value="JPEG"/>
<Lossless value="false"/>
<NumProgressiveScans value="1"/>
</Compression>
<Dimension>
<PixelAspectRatio value="1.0"/>
<ImageOrientation value="normal"/>
</Dimension>
</javax_imageio_1.0>