/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/withExif.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/noExif.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/windowsXpFields.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/NikonType2MakernoteTest1.java |
---|
0,0 → 1,149 |
/* |
* This is public domain software - that is, you can do whatever you want |
* with it, and include it software that is licensed under the GNU or the |
* BSD license, or whatever other licence you choose, including proprietary |
* closed source licenses. I do ask that you leave this header in tact. |
* |
* If you make modifications to this code that you think would benefit the |
* wider community, please send me a copy and I'll post it on my site. |
* |
* If you make use of this code, I'd appreciate hearing about it. |
* drew@drewnoakes.com |
* Latest version of this software kept at |
* http://drewnoakes.com/ |
* |
* Created by dnoakes on 3-Oct-2002 20:47:31 using IntelliJ IDEA. |
*/ |
package com.drew.metadata.exif.test; |
import com.drew.imaging.jpeg.JpegSegmentData; |
import com.drew.metadata.Metadata; |
import com.drew.metadata.MetadataException; |
import com.drew.metadata.exif.ExifReader; |
import com.drew.metadata.exif.NikonType2MakernoteDescriptor; |
import com.drew.metadata.exif.NikonType2MakernoteDirectory; |
import junit.framework.TestCase; |
import java.io.File; |
/** |
* |
*/ |
public class NikonType2MakernoteTest1 extends TestCase |
{ |
private NikonType2MakernoteDirectory _nikonDirectory; |
private NikonType2MakernoteDescriptor _descriptor; |
public NikonType2MakernoteTest1(String s) |
{ |
super(s); |
} |
protected void setUp() throws Exception |
{ |
File metadataFile = new File("src/com/drew/metadata/exif/test/nikonMakernoteType2a.metadata"); |
Metadata metadata = new ExifReader(JpegSegmentData.FromFile(metadataFile)).extract(); |
_nikonDirectory = (NikonType2MakernoteDirectory)metadata.getDirectory(NikonType2MakernoteDirectory.class); |
_descriptor = new NikonType2MakernoteDescriptor(_nikonDirectory); |
} |
/* |
[Nikon Makernote] Firmware Version = 0200 |
[Nikon Makernote] ISO = 0 320 |
[Nikon Makernote] File Format = FINE |
[Nikon Makernote] White Balance = FLASH |
[Nikon Makernote] Sharpening = AUTO |
[Nikon Makernote] AF Type = AF-C |
[Nikon Makernote] Unknown 17 = NORMAL |
[Nikon Makernote] Unknown 18 = |
[Nikon Makernote] White Balance Fine = 0 |
[Nikon Makernote] Unknown 01 = |
[Nikon Makernote] Unknown 02 = |
[Nikon Makernote] Unknown 03 = 914 |
[Nikon Makernote] Unknown 19 = |
[Nikon Makernote] ISO = 0 320 |
[Nikon Makernote] Tone Compensation = AUTO |
[Nikon Makernote] Unknown 04 = 6 |
[Nikon Makernote] Lens Focal/Max-FStop pairs = 240/10 850/10 35/10 45/10 |
[Nikon Makernote] Unknown 05 = 0 |
[Nikon Makernote] Unknown 06 = |
[Nikon Makernote] Unknown 07 = 1 |
[Nikon Makernote] Unknown 20 = 0 |
[Nikon Makernote] Unknown 08 = @ |
[Nikon Makernote] Colour Mode = MODE1 |
[Nikon Makernote] Unknown 10 = NATURAL |
[Nikon Makernote] Unknown 11 = 0100 |
- |
[Nikon Makernote] Camera Hue = 0 |
[Nikon Makernote] Noise Reduction = OFF |
[Nikon Makernote] Unknown 12 = 0100 |
[Nikon Makernote] Unknown 13 = 0100{t@7b,4x,D"Y |
[Nikon Makernote] Unknown 15 = 78/10 78/10 |
*/ |
public void testNikonMakernote_MatchesKnownValues() throws Exception |
{ |
assertEquals("48 50 48 48", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_FIRMWARE_VERSION)); |
assertEquals("0 320", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_ISO_1)); |
assertEquals("0 320", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_ISO_2)); |
assertEquals("FLASH ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_CAMERA_WHITE_BALANCE)); |
assertEquals("AUTO ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_CAMERA_SHARPENING)); |
assertEquals("AF-C ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_AF_TYPE)); |
assertEquals("NORMAL ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_FLASH_SYNC_MODE)); |
assertEquals("0", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_CAMERA_WHITE_BALANCE_FINE)); |
assertEquals("914", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_UNKNOWN_3)); |
assertEquals("AUTO ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_CAMERA_TONE_COMPENSATION)); |
assertEquals("6", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_UNKNOWN_4)); |
assertEquals("240/10 850/10 35/10 45/10", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_LENS)); |
assertEquals("0", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_UNKNOWN_5)); |
assertEquals("1", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_UNKNOWN_7)); |
assertEquals("0", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_UNKNOWN_20)); |
assertEquals("MODE1 ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_CAMERA_COLOR_MODE)); |
assertEquals("NATURAL ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_LIGHT_SOURCE)); |
assertEquals("0", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_CAMERA_HUE_ADJUSTMENT)); |
assertEquals("OFF ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_NOISE_REDUCTION)); |
assertEquals("78/10 78/10", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_UNKNOWN_15)); |
} |
public void testGetLensDescription() throws MetadataException |
{ |
assertEquals("24-85mm f/3.5-4.5", _descriptor.getDescription(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_LENS)); |
assertEquals("24-85mm f/3.5-4.5", _descriptor.getLensDescription()); |
} |
public void testGetHueAdjustmentDescription() throws MetadataException |
{ |
assertEquals("0 degrees", _descriptor.getDescription(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_CAMERA_HUE_ADJUSTMENT)); |
assertEquals("0 degrees", _descriptor.getHueAdjustmentDescription()); |
} |
public void testGetColorModeDescription() throws Exception |
{ |
assertEquals("Mode I (sRGB)", _descriptor.getDescription(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_CAMERA_COLOR_MODE)); |
assertEquals("Mode I (sRGB)", _descriptor.getColorModeDescription()); |
} |
public void testGetAutoFlashCompensationDescription() throws Exception |
{ |
NikonType2MakernoteDirectory directory = new NikonType2MakernoteDirectory(); |
NikonType2MakernoteDescriptor descriptor = new NikonType2MakernoteDescriptor(directory); |
// no entry exists |
assertEquals("Unknown", descriptor.getAutoFlashCompensationDescription()); |
directory.setByteArray(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_AUTO_FLASH_COMPENSATION, new byte[] { 0x06, 0x01, 0x06 }); |
assertEquals("1 EV", descriptor.getAutoFlashCompensationDescription()); |
directory.setByteArray(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_AUTO_FLASH_COMPENSATION, new byte[] { 0x04, 0x01, 0x06 }); |
assertEquals("0.67 EV", descriptor.getAutoFlashCompensationDescription()); |
directory.setByteArray(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_AUTO_FLASH_COMPENSATION, new byte[] { 0x02, 0x01, 0x06 }); |
assertEquals("0.33 EV", descriptor.getAutoFlashCompensationDescription()); |
directory.setByteArray(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_AUTO_FLASH_COMPENSATION, new byte[] { (byte)0xFE, 0x01, 0x06 }); |
assertEquals("-0.33 EV", descriptor.getAutoFlashCompensationDescription()); |
} |
} |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/withUncompressedYCbCrThumbnail.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/NikonType2MakernoteTest2.java |
---|
0,0 → 1,169 |
/* |
* This is public domain software - that is, you can do whatever you want |
* with it, and include it software that is licensed under the GNU or the |
* BSD license, or whatever other licence you choose, including proprietary |
* closed source licenses. I do ask that you leave this header in tact. |
* |
* If you make modifications to this code that you think would benefit the |
* wider community, please send me a copy and I'll post it on my site. |
* |
* If you make use of this code, I'd appreciate hearing about it. |
* drew@drewnoakes.com |
* Latest version of this software kept at |
* http://drewnoakes.com/ |
* |
* Created by dnoakes on 25-Nov-2002 20:47:31 using IntelliJ IDEA. |
*/ |
package com.drew.metadata.exif.test; |
import com.drew.imaging.jpeg.JpegMetadataReader; |
import com.drew.lang.Rational; |
import com.drew.metadata.Metadata; |
import com.drew.metadata.exif.ExifDirectory; |
import com.drew.metadata.exif.NikonType2MakernoteDirectory; |
import junit.framework.TestCase; |
import java.io.File; |
/** |
* |
*/ |
public class NikonType2MakernoteTest2 extends TestCase |
{ |
private NikonType2MakernoteDirectory _nikonDirectory; |
private ExifDirectory _exifDirectory; |
public NikonType2MakernoteTest2(String s) |
{ |
super(s); |
} |
protected void setUp() throws Exception |
{ |
File nikonJpeg = new File("src/com/drew/metadata/exif/test/nikonMakernoteType2b.jpg"); |
Metadata metadata = JpegMetadataReader.readMetadata(nikonJpeg); |
_nikonDirectory = (NikonType2MakernoteDirectory)metadata.getDirectory(NikonType2MakernoteDirectory.class); |
_exifDirectory = (ExifDirectory)metadata.getDirectory(ExifDirectory.class); |
} |
/* |
[Nikon Makernote] Makernote Unknown 1 = |
[Nikon Makernote] ISO Setting = Unknown (0 0) |
[Nikon Makernote] Color Mode = COLOR |
[Nikon Makernote] Quality = NORMAL |
[Nikon Makernote] White Balance = AUTO |
[Nikon Makernote] Image Sharpening = AUTO |
[Nikon Makernote] Focus Mode = AF-C |
[Nikon Makernote] Flash Setting = NORMAL |
[Nikon Makernote] Makernote Unknown 2 = 4416/500 |
[Nikon Makernote] ISO Selection = AUTO |
[Nikon Makernote] Unknown tag (0x0011) = 1300 |
[Nikon Makernote] Image Adjustment = AUTO |
[Nikon Makernote] Adapter = OFF |
[Nikon Makernote] Focus Distance = 0 |
[Nikon Makernote] Digital Zoom = No digital zoom |
[Nikon Makernote] AF Focus Position = Unknown () |
[Nikon Makernote] Unknown tag (0x008f) = |
[Nikon Makernote] Unknown tag (0x0094) = 0 |
[Nikon Makernote] Unknown tag (0x0095) = FPNR |
[Nikon Makernote] Unknown tag (0x0e00) = PrintIM |
[Nikon Makernote] Unknown tag (0x0e10) = 1394 |
*/ |
public void testNikonMakernote_MatchesKnownValues() throws Exception |
{ |
assertEquals("0 1 0 0", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_FIRMWARE_VERSION)); |
assertEquals("0 0", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_ISO_1)); |
assertEquals("COLOR", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_COLOR_MODE)); |
assertEquals("NORMAL ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_QUALITY_AND_FILE_FORMAT)); |
assertEquals("AUTO ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_CAMERA_WHITE_BALANCE)); |
assertEquals("AUTO ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_CAMERA_SHARPENING)); |
assertEquals("AF-C ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_AF_TYPE)); |
assertEquals("NORMAL ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_FLASH_SYNC_MODE)); |
// assertEquals(new Rational(4416,500), _nikonDirectory.getRational(NikonType3MakernoteDirectory.TAG_NIKON_TYPE2_UNKNOWN_2)); |
assertEquals("AUTO ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_ISO_SELECTION)); |
assertEquals(1300, _nikonDirectory.getInt(0x0011)); |
assertEquals("AUTO ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_IMAGE_ADJUSTMENT)); |
assertEquals("OFF ", _nikonDirectory.getString(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_ADAPTER)); |
assertEquals(0, _nikonDirectory.getInt(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_MANUAL_FOCUS_DISTANCE)); |
assertEquals(1, _nikonDirectory.getInt(NikonType2MakernoteDirectory.TAG_NIKON_TYPE2_DIGITAL_ZOOM)); |
assertEquals(" ", _nikonDirectory.getString(0x008f)); |
assertEquals(0, _nikonDirectory.getInt(0x0094)); |
assertEquals("FPNR", _nikonDirectory.getString(0x0095)); |
assertEquals("80 114 105 110 116 73 77 0 48 49 48 48 0 0 13 0 1 0 22 0 22 0 2 0 1 0 0 0 3 0 94 0 0 0 7 0 0 0 0 0 8 0 0 0 0 0 9 0 0 0 0 0 10 0 0 0 0 0 11 0 -90 0 0 0 12 0 0 0 0 0 13 0 0 0 0 0 14 0 -66 0 0 0 0 1 5 0 0 0 1 1 1 0 0 0 9 17 0 0 16 39 0 0 11 15 0 0 16 39 0 0 -105 5 0 0 16 39 0 0 -80 8 0 0 16 39 0 0 1 28 0 0 16 39 0 0 94 2 0 0 16 39 0 0 -117 0 0 0 16 39 0 0 -53 3 0 0 16 39 0 0 -27 27 0 0 16 39 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", _nikonDirectory.getString(0x0e00)); |
// assertEquals("PrintIM", _nikonDirectory.getString(0x0e00)); |
assertEquals(1394, _nikonDirectory.getInt(0x0e10)); |
} |
/* |
[Exif] Image Description = |
[Exif] Make = NIKON |
[Exif] Model = E995 |
[Exif] X Resolution = 72 dots per inch |
[Exif] Y Resolution = 72 dots per inch |
[Exif] Resolution Unit = Inch |
[Exif] Software = E995v1.6 |
[Exif] Date/Time = 2002:08:29 17:31:40 |
[Exif] YCbCr Positioning = Center of pixel array |
[Exif] Exposure Time = 2439024/100000000 sec |
[Exif] F-Number = F2.6 |
[Exif] Exposure Program = Program normal |
[Exif] ISO Speed Ratings = 100 |
[Exif] Exif Version = 2.10 |
[Exif] Date/Time Original = 2002:08:29 17:31:40 |
[Exif] Date/Time Digitized = 2002:08:29 17:31:40 |
[Exif] Components Configuration = YCbCr |
[Exif] Exposure Bias Value = 0 |
[Exif] Max Aperture Value = F1 |
[Exif] Metering Mode = Multi-segment |
[Exif] Light Source = Unknown |
[Exif] Flash = Flash fired |
[Exif] Focal Length = 8.2 mm |
[Exif] User Comment = |
[Exif] FlashPix Version = 1.00 |
[Exif] Color Space = sRGB |
[Exif] Exif Image Width = 2048 pixels |
[Exif] Exif Image Height = 1536 pixels |
[Exif] File Source = Digital Still Camera (DSC) |
[Exif] Scene Type = Directly photographed image |
[Exif] Compression = JPEG compression |
[Exif] Thumbnail Offset = 1494 bytes |
[Exif] Thumbnail Length = 6077 bytes |
[Exif] Thumbnail Data = [6077 bytes of thumbnail data] |
*/ |
public void testExifDirectory_MatchesKnownValues() throws Exception |
{ |
assertEquals(" ", _exifDirectory.getString(ExifDirectory.TAG_IMAGE_DESCRIPTION)); |
assertEquals("NIKON", _exifDirectory.getString(ExifDirectory.TAG_MAKE)); |
assertEquals("E995", _exifDirectory.getString(ExifDirectory.TAG_MODEL)); |
assertEquals(72, _exifDirectory.getDouble(ExifDirectory.TAG_X_RESOLUTION), 0.001); |
assertEquals(72, _exifDirectory.getDouble(ExifDirectory.TAG_Y_RESOLUTION), 0.001); |
assertEquals(2, _exifDirectory.getInt(ExifDirectory.TAG_RESOLUTION_UNIT)); |
assertEquals("E995v1.6", _exifDirectory.getString(ExifDirectory.TAG_SOFTWARE)); |
assertEquals("2002:08:29 17:31:40", _exifDirectory.getString(ExifDirectory.TAG_DATETIME)); |
assertEquals(1, _exifDirectory.getInt(ExifDirectory.TAG_YCBCR_POSITIONING)); |
assertEquals(new Rational(2439024, 100000000), _exifDirectory.getRational(ExifDirectory.TAG_EXPOSURE_TIME)); |
assertEquals(2.6, _exifDirectory.getDouble(ExifDirectory.TAG_FNUMBER), 0.001); |
assertEquals(2, _exifDirectory.getInt(ExifDirectory.TAG_EXPOSURE_PROGRAM)); |
assertEquals(100, _exifDirectory.getInt(ExifDirectory.TAG_ISO_EQUIVALENT)); |
assertEquals("48 50 49 48", _exifDirectory.getString(ExifDirectory.TAG_EXIF_VERSION)); |
assertEquals("2002:08:29 17:31:40", _exifDirectory.getString(ExifDirectory.TAG_DATETIME_DIGITIZED)); |
assertEquals("2002:08:29 17:31:40", _exifDirectory.getString(ExifDirectory.TAG_DATETIME_ORIGINAL)); |
assertEquals("1 2 3 0", _exifDirectory.getString(ExifDirectory.TAG_COMPONENTS_CONFIGURATION)); |
assertEquals(0, _exifDirectory.getInt(ExifDirectory.TAG_EXPOSURE_BIAS)); |
assertEquals("0", _exifDirectory.getString(ExifDirectory.TAG_MAX_APERTURE)); |
assertEquals(5, _exifDirectory.getInt(ExifDirectory.TAG_METERING_MODE)); |
assertEquals(0, _exifDirectory.getInt(ExifDirectory.TAG_WHITE_BALANCE)); |
assertEquals(1, _exifDirectory.getInt(ExifDirectory.TAG_FLASH)); |
assertEquals(8.2, _exifDirectory.getDouble(ExifDirectory.TAG_FOCAL_LENGTH), 0.001); |
assertEquals("0 0 0 0 0 0 0 0 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32", _exifDirectory.getString(ExifDirectory.TAG_USER_COMMENT)); |
assertEquals("48 49 48 48", _exifDirectory.getString(ExifDirectory.TAG_FLASHPIX_VERSION)); |
assertEquals(1, _exifDirectory.getInt(ExifDirectory.TAG_COLOR_SPACE)); |
assertEquals(2048, _exifDirectory.getInt(ExifDirectory.TAG_EXIF_IMAGE_WIDTH)); |
assertEquals(1536, _exifDirectory.getInt(ExifDirectory.TAG_EXIF_IMAGE_HEIGHT)); |
assertEquals(3, _exifDirectory.getInt(ExifDirectory.TAG_FILE_SOURCE)); |
assertEquals(1, _exifDirectory.getInt(ExifDirectory.TAG_SCENE_TYPE)); |
assertEquals(6, _exifDirectory.getInt(ExifDirectory.TAG_COMPRESSION)); |
assertEquals(1494, _exifDirectory.getInt(ExifDirectory.TAG_THUMBNAIL_OFFSET)); |
assertEquals(6077, _exifDirectory.getInt(ExifDirectory.TAG_THUMBNAIL_LENGTH)); |
} |
} |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/ExifDescriptorTest.java |
---|
0,0 → 1,150 |
/* |
* ExifReaderTest.java |
* |
* Test class written by Drew Noakes. |
* |
* This is public domain software - that is, you can do whatever you want |
* with it, and include it software that is licensed under the GNU or the |
* BSD license, or whatever other licence you choose, including proprietary |
* closed source licenses. I do ask that you leave this header in tact. |
* |
* If you make modifications to this code that you think would benefit the |
* wider community, please send me a copy and I'll post it on my site. |
* |
* If you make use of this code, I'd appreciate hearing about it. |
* drew@drewnoakes.com |
* Latest version of this software kept at |
* http://drewnoakes.com/ |
* |
* Created by dnoakes on 26-Oct-2002 19:15:16 using IntelliJ IDEA. |
*/ |
package com.drew.metadata.exif.test; |
import com.drew.lang.Rational; |
import com.drew.metadata.Directory; |
import com.drew.metadata.Metadata; |
import com.drew.metadata.exif.ExifDescriptor; |
import com.drew.metadata.exif.ExifDirectory; |
import com.drew.metadata.exif.ExifReader; |
import junit.framework.TestCase; |
import java.io.File; |
/** |
* JUnit test case for class ExifDescriptor. |
* @author Drew Noakes http://drewnoakes.com |
*/ |
public class ExifDescriptorTest extends TestCase |
{ |
public ExifDescriptorTest(String s) |
{ |
super(s); |
} |
public void testXResolutionDescription() throws Exception |
{ |
ExifDirectory directory = new ExifDirectory(); |
directory.setRational(ExifDirectory.TAG_X_RESOLUTION, new Rational(72, 1)); |
// 2 is for 'Inch' |
directory.setInt(ExifDirectory.TAG_RESOLUTION_UNIT, 2); |
ExifDescriptor descriptor = new ExifDescriptor(directory); |
assertEquals("72 dots per inch", descriptor.getDescription(ExifDirectory.TAG_X_RESOLUTION)); |
} |
public void testYResolutionDescription() throws Exception |
{ |
ExifDirectory directory = new ExifDirectory(); |
directory.setRational(ExifDirectory.TAG_Y_RESOLUTION, new Rational(50, 1)); |
// 3 is for 'cm' |
directory.setInt(ExifDirectory.TAG_RESOLUTION_UNIT, 3); |
ExifDescriptor descriptor = new ExifDescriptor(directory); |
assertEquals("50 dots per cm", descriptor.getDescription(ExifDirectory.TAG_Y_RESOLUTION)); |
} |
public void testUserCommentDescription_EmptyEncoding() throws Exception |
{ |
byte[] commentBytes = "\0\0\0\0\0\0\0\0This is a comment".getBytes(); |
ExifDirectory directory = new ExifDirectory(); |
directory.setByteArray(ExifDirectory.TAG_USER_COMMENT, commentBytes); |
ExifDescriptor descriptor = new ExifDescriptor(directory); |
assertEquals("This is a comment", descriptor.getDescription(ExifDirectory.TAG_USER_COMMENT)); |
} |
public void testUserCommentDescription_AsciiHeaderExtendedAsciiEncoding() throws Exception |
{ |
byte[] commentBytes = "ASCII\0\0This is a comment with extended characters æøå ÆØÅ".getBytes(); |
ExifDirectory directory = new ExifDirectory(); |
directory.setByteArray(ExifDirectory.TAG_USER_COMMENT, commentBytes); |
ExifDescriptor descriptor = new ExifDescriptor(directory); |
assertEquals("This is a comment with extended characters æøå ÆØÅ", descriptor.getDescription(ExifDirectory.TAG_USER_COMMENT)); |
} |
public void testUserCommentDescription_AsciiHeaderAsciiEncoding() throws Exception |
{ |
byte[] commentBytes = "ASCII\0\0This is a comment".getBytes(); |
ExifDirectory directory = new ExifDirectory(); |
directory.setByteArray(ExifDirectory.TAG_USER_COMMENT, commentBytes); |
ExifDescriptor descriptor = new ExifDescriptor(directory); |
assertEquals("This is a comment", descriptor.getDescription(ExifDirectory.TAG_USER_COMMENT)); |
} |
public void testUserCommentDescription_BlankAscii() throws Exception |
{ |
byte[] commentBytes = "ASCII\0\0\0 ".getBytes(); |
ExifDirectory directory = new ExifDirectory(); |
directory.setByteArray(ExifDirectory.TAG_USER_COMMENT, commentBytes); |
ExifDescriptor descriptor = new ExifDescriptor(directory); |
assertEquals("", descriptor.getDescription(ExifDirectory.TAG_USER_COMMENT)); |
} |
public void testUserCommentDescription_ZeroLengthAscii1() throws Exception |
{ |
// the 10-byte encoding region is only partially full |
byte[] commentBytes = "ASCII\0\0\0".getBytes(); |
ExifDirectory directory = new ExifDirectory(); |
directory.setByteArray(ExifDirectory.TAG_USER_COMMENT, commentBytes); |
ExifDescriptor descriptor = new ExifDescriptor(directory); |
assertEquals("ASCII", descriptor.getDescription(ExifDirectory.TAG_USER_COMMENT)); |
} |
public void testUserCommentDescription_ZeroLengthAscii2() throws Exception |
{ |
// fill the 10-byte encoding region |
byte[] commentBytes = "ASCII\0\0\0\0\0".getBytes(); |
ExifDirectory directory = new ExifDirectory(); |
directory.setByteArray(ExifDirectory.TAG_USER_COMMENT, commentBytes); |
ExifDescriptor descriptor = new ExifDescriptor(directory); |
assertEquals("", descriptor.getDescription(ExifDirectory.TAG_USER_COMMENT)); |
} |
public void testUnicodeComment_ActualBytes() throws Exception |
{ |
byte[] commentBytes = new byte[] { 85, 78, 73, 67, 79, 68, 69, 0, 84, 0, 104, 0, 105, 0, 115, 0, 32, 0, 109, 0, 97, 0, 114, 0, 109, 0, 111, 0, 116, 0, 32, 0, 105, 0, 115, 0, 32, 0, 103, 0, 101, 0, 116, 0, 116, 0, 105, 0, 110, 0, 103, 0, 32, 0, 99, 0, 108, 0, 111, 0, 115, 0, 101, 0, 46, 0, 46, 0, 46, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0, 32, 0 }; |
ExifDirectory directory = new ExifDirectory(); |
directory.setByteArray(ExifDirectory.TAG_USER_COMMENT, commentBytes); |
ExifDescriptor descriptor = new ExifDescriptor(directory); |
assertEquals("This marmot is getting close...", descriptor.getDescription(ExifDirectory.TAG_USER_COMMENT)); |
} |
public void testUnicodeComment_Ascii() throws Exception |
{ |
byte[] commentBytes = new byte[] { 65, 83, 67, 73, 73, 0, 0, 0, 73, 32, 97, 109, 32, 97, 32, 99, 111, 109, 109, 101, 110, 116, 46, 32, 89, 101, 121, 46, 0 }; |
ExifDirectory directory = new ExifDirectory(); |
directory.setByteArray(ExifDirectory.TAG_USER_COMMENT, commentBytes); |
ExifDescriptor descriptor = new ExifDescriptor(directory); |
assertEquals("I am a comment. Yey.", descriptor.getDescription(ExifDirectory.TAG_USER_COMMENT)); |
} |
public void testWindowsXpFields() throws Exception |
{ |
String fileName = "src/com/drew/metadata/exif/test/windowsXpFields.jpg"; |
Metadata metadata = new ExifReader(new File(fileName)).extract(); |
Directory directory = metadata.getDirectory(ExifDirectory.class); |
ExifDescriptor descriptor = new ExifDescriptor(directory); |
assertEquals("Testing artist", descriptor.getDescription(ExifDirectory.TAG_WIN_AUTHOR)); |
assertEquals("Testing comments", descriptor.getDescription(ExifDirectory.TAG_WIN_COMMENT)); |
assertEquals("Testing keywords", descriptor.getDescription(ExifDirectory.TAG_WIN_KEYWORDS)); |
assertEquals("Testing subject", descriptor.getDescription(ExifDirectory.TAG_WIN_SUBJECT)); |
assertEquals("Testing title", descriptor.getDescription(ExifDirectory.TAG_WIN_TITLE)); |
} |
} |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/crash01.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/withUncompressedRGBThumbnail.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/badExif.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/CanonMakernoteDescriptorTest.java |
---|
0,0 → 1,65 |
/* |
* This is public domain software - that is, you can do whatever you want |
* with it, and include it software that is licensed under the GNU or the |
* BSD license, or whatever other licence you choose, including proprietary |
* closed source licenses. I do ask that you leave this header in tact. |
* |
* If you make modifications to this code that you think would benefit the |
* wider community, please send me a copy and I'll post it on my site. |
* |
* If you make use of this code, I'd appreciate hearing about it. |
* drew@drewnoakes.com |
* Latest version of this software kept at |
* http://drewnoakes.com/ |
*/ |
package com.drew.metadata.exif.test; |
import com.drew.metadata.exif.CanonMakernoteDescriptor; |
import com.drew.metadata.exif.CanonMakernoteDirectory; |
import junit.framework.TestCase; |
public class CanonMakernoteDescriptorTest extends TestCase |
{ |
public CanonMakernoteDescriptorTest(String name) |
{ |
super(name); |
} |
public void testGetFlashBiasDescription() throws Exception |
{ |
CanonMakernoteDirectory directory = new CanonMakernoteDirectory(); |
CanonMakernoteDescriptor descriptor = new CanonMakernoteDescriptor(directory); |
// set and check values |
directory.setInt(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS, 0xFFC0); |
assertEquals("-2.0 EV", descriptor.getDescription(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS)); |
directory.setInt(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS, 0xffd4); |
assertEquals("-1.375 EV", descriptor.getDescription(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS)); |
directory.setInt(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS, 0x0000); |
assertEquals("0.0 EV", descriptor.getDescription(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS)); |
directory.setInt(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS, 0x000c); |
assertEquals("0.375 EV", descriptor.getDescription(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS)); |
directory.setInt(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS, 0x0010); |
assertEquals("0.5 EV", descriptor.getDescription(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS)); |
directory.setInt(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS, 0x0014); |
assertEquals("0.625 EV", descriptor.getDescription(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS)); |
directory.setInt(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS, 0x0020); |
assertEquals("1.0 EV", descriptor.getDescription(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS)); |
directory.setInt(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS, 0x0030); |
assertEquals("1.5 EV", descriptor.getDescription(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS)); |
directory.setInt(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS, 0x0034); |
assertEquals("1.625 EV", descriptor.getDescription(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS)); |
directory.setInt(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS, 0x0040); |
assertEquals("2.0 EV", descriptor.getDescription(CanonMakernoteDirectory.TAG_CANON_STATE2_FLASH_BIAS)); |
} |
} |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/recursiveDirectories.metadata |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/nikonMakernoteType1.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/NikonType1MakernoteTest.java |
---|
0,0 → 1,172 |
/* |
* This is public domain software - that is, you can do whatever you want |
* with it, and include it software that is licensed under the GNU or the |
* BSD license, or whatever other licence you choose, including proprietary |
* closed source licenses. I do ask that you leave this header in tact. |
* |
* If you make modifications to this code that you think would benefit the |
* wider community, please send me a copy and I'll post it on my site. |
* |
* If you make use of this code, I'd appreciate hearing about it. |
* drew@drewnoakes.com |
* Latest version of this software kept at |
* http://drewnoakes.com/ |
* |
* Created by dnoakes on 25-Nov-2002 20:47:31 using IntelliJ IDEA. |
*/ |
package com.drew.metadata.exif.test; |
import com.drew.imaging.jpeg.JpegMetadataReader; |
import com.drew.lang.Rational; |
import com.drew.metadata.Metadata; |
import com.drew.metadata.exif.ExifDirectory; |
import com.drew.metadata.exif.NikonType1MakernoteDirectory; |
import junit.framework.TestCase; |
import java.io.File; |
/** |
* |
*/ |
public class NikonType1MakernoteTest extends TestCase |
{ |
private NikonType1MakernoteDirectory _nikonDirectory; |
private ExifDirectory _exifDirectory; |
public NikonType1MakernoteTest(String s) |
{ |
super(s); |
} |
/* |
[Interoperability] Interoperability Index = Recommended Exif Interoperability Rules (ExifR98) |
[Interoperability] Interoperability Version = 1.00 |
[Jpeg] Data Precision = 8 bits |
[Jpeg] Image Width = 600 pixels |
[Jpeg] Image Height = 800 pixels |
[Jpeg] Number of Components = 3 |
[Jpeg] Component 1 = Y component: Quantization table 0, Sampling factors 1 horiz/1 vert |
[Jpeg] Component 2 = Cb component: Quantization table 1, Sampling factors 1 horiz/1 vert |
[Jpeg] Component 3 = Cr component: Quantization table 1, Sampling factors 1 horiz/1 vert |
*/ |
protected void setUp() throws Exception |
{ |
File nikonJpeg = new File("src/com/drew/metadata/exif/test/nikonMakernoteType1.jpg"); |
Metadata metadata = JpegMetadataReader.readMetadata(nikonJpeg); |
_nikonDirectory = (NikonType1MakernoteDirectory)metadata.getDirectory(NikonType1MakernoteDirectory.class); |
_exifDirectory = (ExifDirectory)metadata.getDirectory(ExifDirectory.class); |
} |
/* |
[Nikon Makernote] Makernote Unknown 1 = 08.00 |
[Nikon Makernote] Quality = Unknown (12) |
[Nikon Makernote] Color Mode = Color |
[Nikon Makernote] Image Adjustment = Contrast + |
[Nikon Makernote] CCD Sensitivity = ISO80 |
[Nikon Makernote] White Balance = Auto |
[Nikon Makernote] Focus = 0 |
[Nikon Makernote] Makernote Unknown 2 = |
[Nikon Makernote] Digital Zoom = No digital zoom |
[Nikon Makernote] Fisheye Converter = None |
[Nikon Makernote] Makernote Unknown 3 = 0 0 16777216 0 -1609193200 0 34833 6931 16178 4372 4372 -972290529 -921882880 15112 0 0 1151495 252903424 17 0 0 844038208 55184128 218129428 1476410198 370540566 -250604010 16711749 204629079 1729 |
*/ |
public void testNikonMakernote_MatchesKnownValues() throws Exception |
{ |
assertTrue(_nikonDirectory.getTagCount() > 0); |
assertEquals(8, _nikonDirectory.getDouble(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_UNKNOWN_1), 0.0001); |
assertEquals(12, _nikonDirectory.getInt(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_QUALITY)); |
assertEquals(1, _nikonDirectory.getInt(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_COLOR_MODE)); |
assertEquals(3, _nikonDirectory.getInt(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_IMAGE_ADJUSTMENT)); |
assertEquals(0, _nikonDirectory.getInt(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_CCD_SENSITIVITY)); |
assertEquals(0, _nikonDirectory.getInt(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_WHITE_BALANCE)); |
assertEquals(0, _nikonDirectory.getInt(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_FOCUS)); |
assertEquals("", _nikonDirectory.getString(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_UNKNOWN_2)); |
assertEquals(0, _nikonDirectory.getDouble(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_DIGITAL_ZOOM), 0.0001); |
assertEquals(0, _nikonDirectory.getInt(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_CONVERTER)); |
int[] unknown3 = _nikonDirectory.getIntArray(NikonType1MakernoteDirectory.TAG_NIKON_TYPE1_UNKNOWN_3); |
int[] expected = new int[] { 0, 0, 16777216, 0, -1609193200, 0, 34833, 6931, 16178, 4372, 4372, -972290529, -921882880, 15112, 0, 0, 1151495, 252903424, 17, 0, 0, 844038208, 55184128, 218129428, 1476410198, 370540566, -250604010, 16711749, 204629079, 1729 }; |
assertEquals(expected.length, unknown3.length); |
for (int i = 0; i<expected.length; i++) { |
assertEquals(expected[i], unknown3[i]); |
} |
} |
/* |
[Exif] Image Description = |
[Exif] Make = NIKON |
[Exif] Model = E950 |
[Exif] Orientation = top, left side |
[Exif] X Resolution = 300 dots per inch |
[Exif] Y Resolution = 300 dots per inch |
[Exif] Resolution Unit = Inch |
[Exif] Software = v981-79 |
[Exif] Date/Time = 2001:04:06 11:51:40 |
[Exif] YCbCr Positioning = Datum point |
[Exif] Exposure Time = 1/77 sec |
[Exif] F-Number = F5.5 |
[Exif] Exposure Program = Program normal |
[Exif] ISO Speed Ratings = 80 |
[Exif] Exif Version = 2.10 |
[Exif] Date/Time Original = 2001:04:06 11:51:40 |
[Exif] Date/Time Digitized = 2001:04:06 11:51:40 |
[Exif] Components Configuration = YCbCr |
[Exif] Compressed Bits Per Pixel = 4 bits/pixel |
[Exif] Exposure Bias Value = 0 |
[Exif] Max Aperture Value = F2.5 |
[Exif] Metering Mode = Multi-segment |
[Exif] Light Source = Unknown |
[Exif] Flash = No flash fired |
[Exif] Focal Length = 12.8 mm |
[Exif] User Comment = |
[Exif] FlashPix Version = 1.00 |
[Exif] Color Space = sRGB |
[Exif] Exif Image Width = 1600 pixels |
[Exif] Exif Image Height = 1200 pixels |
[Exif] File Source = Digital Still Camera (DSC) |
[Exif] Scene Type = Directly photographed image |
[Exif] Compression = JPEG compression |
[Exif] Thumbnail Offset = 2036 bytes |
[Exif] Thumbnail Length = 4662 bytes |
[Exif] Thumbnail Data = [4662 bytes of thumbnail data] |
*/ |
public void testExifDirectory_MatchesKnownValues() throws Exception |
{ |
assertEquals(" ", _exifDirectory.getString(ExifDirectory.TAG_IMAGE_DESCRIPTION)); |
assertEquals("NIKON", _exifDirectory.getString(ExifDirectory.TAG_MAKE)); |
assertEquals("E950", _exifDirectory.getString(ExifDirectory.TAG_MODEL)); |
assertEquals(1, _exifDirectory.getInt(ExifDirectory.TAG_ORIENTATION)); |
assertEquals(300, _exifDirectory.getDouble(ExifDirectory.TAG_X_RESOLUTION), 0.001); |
assertEquals(300, _exifDirectory.getDouble(ExifDirectory.TAG_Y_RESOLUTION), 0.001); |
assertEquals(2, _exifDirectory.getInt(ExifDirectory.TAG_RESOLUTION_UNIT)); |
assertEquals("v981-79", _exifDirectory.getString(ExifDirectory.TAG_SOFTWARE)); |
assertEquals("2001:04:06 11:51:40", _exifDirectory.getString(ExifDirectory.TAG_DATETIME)); |
assertEquals(2, _exifDirectory.getInt(ExifDirectory.TAG_YCBCR_POSITIONING)); |
assertEquals(new Rational(1, 77), _exifDirectory.getRational(ExifDirectory.TAG_EXPOSURE_TIME)); |
assertEquals(5.5, _exifDirectory.getDouble(ExifDirectory.TAG_FNUMBER), 0.001); |
assertEquals(2, _exifDirectory.getInt(ExifDirectory.TAG_EXPOSURE_PROGRAM)); |
assertEquals(80, _exifDirectory.getInt(ExifDirectory.TAG_ISO_EQUIVALENT)); |
assertEquals("48 50 49 48", _exifDirectory.getString(ExifDirectory.TAG_EXIF_VERSION)); |
assertEquals("2001:04:06 11:51:40", _exifDirectory.getString(ExifDirectory.TAG_DATETIME_DIGITIZED)); |
assertEquals("2001:04:06 11:51:40", _exifDirectory.getString(ExifDirectory.TAG_DATETIME_ORIGINAL)); |
assertEquals("1 2 3 0", _exifDirectory.getString(ExifDirectory.TAG_COMPONENTS_CONFIGURATION)); |
assertEquals(4, _exifDirectory.getInt(ExifDirectory.TAG_COMPRESSION_LEVEL)); |
assertEquals(0, _exifDirectory.getInt(ExifDirectory.TAG_EXPOSURE_BIAS)); |
// this 2.6 *apex*, which is F2.5 |
assertEquals(2.6, _exifDirectory.getDouble(ExifDirectory.TAG_MAX_APERTURE), 0.001); |
assertEquals(5, _exifDirectory.getInt(ExifDirectory.TAG_METERING_MODE)); |
assertEquals(0, _exifDirectory.getInt(ExifDirectory.TAG_WHITE_BALANCE)); |
assertEquals(0, _exifDirectory.getInt(ExifDirectory.TAG_FLASH)); |
assertEquals(12.8, _exifDirectory.getDouble(ExifDirectory.TAG_FOCAL_LENGTH), 0.001); |
assertEquals("0 0 0 0 0 0 0 0 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32", _exifDirectory.getString(ExifDirectory.TAG_USER_COMMENT)); |
assertEquals("48 49 48 48", _exifDirectory.getString(ExifDirectory.TAG_FLASHPIX_VERSION)); |
assertEquals(1, _exifDirectory.getInt(ExifDirectory.TAG_COLOR_SPACE)); |
assertEquals(1600, _exifDirectory.getInt(ExifDirectory.TAG_EXIF_IMAGE_WIDTH)); |
assertEquals(1200, _exifDirectory.getInt(ExifDirectory.TAG_EXIF_IMAGE_HEIGHT)); |
assertEquals(3, _exifDirectory.getInt(ExifDirectory.TAG_FILE_SOURCE)); |
assertEquals(1, _exifDirectory.getInt(ExifDirectory.TAG_SCENE_TYPE)); |
assertEquals(6, _exifDirectory.getInt(ExifDirectory.TAG_COMPRESSION)); |
assertEquals(2036, _exifDirectory.getInt(ExifDirectory.TAG_THUMBNAIL_OFFSET)); |
assertEquals(4662, _exifDirectory.getInt(ExifDirectory.TAG_THUMBNAIL_LENGTH)); |
} |
} |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/manuallyAddedThumbnail.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/nikonMakernoteType2a.metadata |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/nikonMakernoteType2b.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/withUncompressedYCbCrThumbnail2.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/withUncompressedYCbCrThumbnail3.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/withUncompressedYCbCrThumbnail4.jpg |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/ExifReaderTest.java |
---|
0,0 → 1,183 |
/* |
* ExifReaderTest.java |
* |
* Test class written by Drew Noakes. |
* |
* This is public domain software - that is, you can do whatever you want |
* with it, and include it software that is licensed under the GNU or the |
* BSD license, or whatever other licence you choose, including proprietary |
* closed source licenses. I do ask that you leave this header in tact. |
* |
* If you make modifications to this code that you think would benefit the |
* wider community, please send me a copy and I'll post it on my site. |
* |
* If you make use of this code, I'd appreciate hearing about it. |
* drew@drewnoakes.com |
* Latest version of this software kept at |
* http://drewnoakes.com/ |
* |
* Created by dnoakes on 26-Oct-2002 19:15:16 using IntelliJ IDEA. |
*/ |
package com.drew.metadata.exif.test; |
import com.drew.imaging.jpeg.JpegSegmentData; |
import com.drew.lang.Rational; |
import com.drew.metadata.Directory; |
import com.drew.metadata.Metadata; |
import com.drew.metadata.exif.ExifDirectory; |
import com.drew.metadata.exif.ExifReader; |
import junit.framework.TestCase; |
import java.io.File; |
/** |
* JUnit test case for class ExifReader. |
* @author Drew Noakes http://drewnoakes.com |
*/ |
public class ExifReaderTest extends TestCase |
{ |
public ExifReaderTest(String s) |
{ |
super(s); |
} |
public void testLoadFujiFilmJpeg() throws Exception |
{ |
String jpegWithExif = "src/com/drew/metadata/exif/test/withExif.jpg"; |
Metadata metadata = new ExifReader(new File(jpegWithExif)).extract(); |
Directory directory = metadata.getDirectory(ExifDirectory.class); |
assertEquals("80", directory.getDescription(ExifDirectory.TAG_ISO_EQUIVALENT)); |
// TODO decide if this should still be returned -- it was being calculated upon setting of a related tag |
// assertEquals("F9", directory.getDescription(ExifDirectory.TAG_APERTURE)); |
} |
public void testLoadJpegWithoutExifData() throws Exception |
{ |
String jpegNoExif = "src/com/drew/metadata/exif/test/noExif.jpg"; |
Metadata metadata = new ExifReader(new File(jpegNoExif)).extract(); |
assertTrue(!metadata.containsDirectory(ExifDirectory.class)); |
} |
public void testLoadJpegWithBadExifData() throws Exception |
{ |
// This test used to ensure an exception was thrown when loading a particular jpeg |
// The intention has since changed, and the API should only throw exceptions in completely |
// fatal situations. Now, the Metadata object returned has no new tags. |
String jpegBadExif = "src/com/drew/metadata/exif/test/badExif.jpg"; // Exif data segment doesn't begin with 'Exif' |
Metadata metadata = new ExifReader(new File(jpegBadExif)).extract(); |
assertEquals(0, metadata.getDirectory(ExifDirectory.class).getTagCount()); |
} |
public void testCrashRegressionTest() throws Exception |
{ |
// this image was created via a resize in ACDSee |
// it seems to have a reference to an IFD starting outside the data segment |
// i've noticed that ACDSee reports a Comment for this image, yet ExifReader doesn't report one |
String fileName = "src/com/drew/metadata/exif/test/crash01.jpg"; |
Metadata metadata = new ExifReader(new File(fileName)).extract(); |
assertTrue(metadata.getDirectory(ExifDirectory.class).getTagCount() > 0); |
} |
public void testThumbnailOffset() throws Exception |
{ |
String fileName = "src/com/drew/metadata/exif/test/manuallyAddedThumbnail.jpg"; |
Metadata metadata = new ExifReader(new File(fileName)).extract(); |
Directory directory = metadata.getDirectory(ExifDirectory.class); |
assertEquals(192, directory.getInt(ExifDirectory.TAG_THUMBNAIL_OFFSET)); |
} |
public void testThumbnailLength() throws Exception |
{ |
String fileName = "src/com/drew/metadata/exif/test/manuallyAddedThumbnail.jpg"; |
Metadata metadata = new ExifReader(new File(fileName)).extract(); |
Directory directory = metadata.getDirectory(ExifDirectory.class); |
assertEquals(2970, directory.getInt(ExifDirectory.TAG_THUMBNAIL_LENGTH)); |
} |
public void testDateTime() throws Exception |
{ |
String fileName = "src/com/drew/metadata/exif/test/manuallyAddedThumbnail.jpg"; |
Metadata metadata = new ExifReader(new File(fileName)).extract(); |
Directory directory = metadata.getDirectory(ExifDirectory.class); |
assertEquals("2002:11:27 18:00:35", directory.getString(ExifDirectory.TAG_DATETIME)); |
} |
public void testXResolution() throws Exception |
{ |
String fileName = "src/com/drew/metadata/exif/test/manuallyAddedThumbnail.jpg"; |
Metadata metadata = new ExifReader(new File(fileName)).extract(); |
Directory directory = metadata.getDirectory(ExifDirectory.class); |
Rational rational = directory.getRational(ExifDirectory.TAG_X_RESOLUTION); |
assertEquals(72, rational.getNumerator()); |
assertEquals(1, rational.getDenominator()); |
} |
public void testYResolution() throws Exception |
{ |
String fileName = "src/com/drew/metadata/exif/test/manuallyAddedThumbnail.jpg"; |
Metadata metadata = new ExifReader(new File(fileName)).extract(); |
Directory directory = metadata.getDirectory(ExifDirectory.class); |
Rational rational = directory.getRational(ExifDirectory.TAG_Y_RESOLUTION); |
assertEquals(72, rational.getNumerator()); |
assertEquals(1, rational.getDenominator()); |
} |
public void testCompression() throws Exception |
{ |
String fileName = "src/com/drew/metadata/exif/test/manuallyAddedThumbnail.jpg"; |
Metadata metadata = new ExifReader(new File(fileName)).extract(); |
Directory directory = metadata.getDirectory(ExifDirectory.class); |
// 6 means JPEG compression |
assertEquals(6, directory.getInt(ExifDirectory.TAG_COMPRESSION)); |
} |
public void testStackOverflowOnRevisitationOfSameDirectory() throws Exception |
{ |
// an error has been discovered in Exif data segments where a directory is referenced |
// repeatedly. thanks to Alistair Dickie for providing the sample image used in this |
// unit test. |
File metadataFile = new File("src/com/drew/metadata/exif/test/recursiveDirectories.metadata"); |
Metadata metadata = new ExifReader(JpegSegmentData.FromFile(metadataFile)).extract(); |
metadata.getDirectory(ExifDirectory.class); |
// String fileName = "src/com/drew/metadata/exif/test/recursiveDirectories.jpg"; |
// Metadata metadata = new ExifReader(new File(fileName)).extract(); |
// metadata.getDirectory(ExifDirectory.class); |
} |
/* |
public void testUncompressedYCbCrThumbnail() throws Exception |
{ |
String fileName = "src/com/drew/metadata/exif/test/withUncompressedYCbCrThumbnail.jpg"; |
String thumnailFileName = "src/com/drew/metadata/exif/test/withUncompressedYCbCrThumbnail.bmp"; |
Metadata metadata = new ExifReader(new File(fileName)).extract(); |
ExifDirectory directory = (ExifDirectory)metadata.getDirectory(ExifDirectory.class); |
directory.writeThumbnail(thumnailFileName); |
fileName = "src/com/drew/metadata/exif/test/withUncompressedYCbCrThumbnail2.jpg"; |
thumnailFileName = "src/com/drew/metadata/exif/test/withUncompressedYCbCrThumbnail2.bmp"; |
metadata = new ExifReader(new File(fileName)).extract(); |
directory = (ExifDirectory)metadata.getDirectory(ExifDirectory.class); |
directory.writeThumbnail(thumnailFileName); |
fileName = "src/com/drew/metadata/exif/test/withUncompressedYCbCrThumbnail3.jpg"; |
thumnailFileName = "src/com/drew/metadata/exif/test/withUncompressedYCbCrThumbnail3.bmp"; |
metadata = new ExifReader(new File(fileName)).extract(); |
directory = (ExifDirectory)metadata.getDirectory(ExifDirectory.class); |
directory.writeThumbnail(thumnailFileName); |
fileName = "src/com/drew/metadata/exif/test/withUncompressedYCbCrThumbnail4.jpg"; |
thumnailFileName = "src/com/drew/metadata/exif/test/withUncompressedYCbCrThumbnail4.bmp"; |
metadata = new ExifReader(new File(fileName)).extract(); |
directory = (ExifDirectory)metadata.getDirectory(ExifDirectory.class); |
directory.writeThumbnail(thumnailFileName); |
} |
public void testUncompressedRGBThumbnail() throws Exception |
{ |
String fileName = "src/com/drew/metadata/exif/test/withUncompressedRGBThumbnail.jpg"; |
String thumnailFileName = "src/com/drew/metadata/exif/test/withUncompressedRGBThumbnail.bmp"; |
Metadata metadata = new ExifReader(new File(fileName)).extract(); |
ExifDirectory directory = (ExifDirectory)metadata.getDirectory(ExifDirectory.class); |
directory.writeThumbnail(thumnailFileName); |
} |
*/ |
} |
/contrib/metadata-extractor/trunk/src/com/drew/metadata/exif/test/ExifDirectoryTest.java |
---|
0,0 → 1,87 |
/* |
* This is public domain software - that is, you can do whatever you want |
* with it, and include it software that is licensed under the GNU or the |
* BSD license, or whatever other licence you choose, including proprietary |
* closed source licenses. I do ask that you leave this header in tact. |
* |
* If you make modifications to this code that you think would benefit the |
* wider community, please send me a copy and I'll post it on my site. |
* |
* If you make use of this code, I'd appreciate hearing about it. |
* drew@drewnoakes.com |
* Latest version of this software kept at |
* http://drewnoakes.com/ |
* |
* Created by dnoakes on 25-Nov-2002 20:47:31 using IntelliJ IDEA. |
*/ |
package com.drew.metadata.exif.test; |
import com.drew.imaging.jpeg.JpegMetadataReader; |
import com.drew.imaging.jpeg.JpegProcessingException; |
import com.drew.imaging.jpeg.JpegSegmentReader; |
import com.drew.metadata.Directory; |
import com.drew.metadata.Metadata; |
import com.drew.metadata.exif.ExifDirectory; |
import junit.framework.TestCase; |
import java.io.File; |
/** |
* |
*/ |
public class ExifDirectoryTest extends TestCase |
{ |
public ExifDirectoryTest(String s) |
{ |
super(s); |
} |
public void testGetDirectoryName() throws Exception |
{ |
Metadata metadata = new Metadata(); |
Directory directory = metadata.getDirectory(ExifDirectory.class); |
assertEquals("Exif", directory.getName()); |
} |
public void testGetThumbnailData() throws Exception |
{ |
File file = new File("src/com/drew/metadata/exif/test/withExif.jpg"); |
Metadata metadata = JpegMetadataReader.readMetadata(file); |
ExifDirectory exifDirectory = (ExifDirectory)metadata.getDirectory(ExifDirectory.class); |
assertTrue(exifDirectory.containsTag(ExifDirectory.TAG_THUMBNAIL_DATA)); |
byte[] thumbData = exifDirectory.getThumbnailData(); |
try { |
// attempt to read the thumbnail -- it should be a legal Jpeg file |
new JpegSegmentReader(thumbData); |
} catch (JpegProcessingException e) { |
fail("Unable to construct JpegSegmentReader from thumbnail data"); |
} |
} |
public void testWriteThumbnail() throws Exception |
{ |
File file = new File("src/com/drew/metadata/exif/test/manuallyAddedThumbnail.jpg"); |
Metadata metadata = JpegMetadataReader.readMetadata(file); |
ExifDirectory exifDirectory = (ExifDirectory)metadata.getDirectory(ExifDirectory.class); |
assertTrue(exifDirectory.containsTag(ExifDirectory.TAG_THUMBNAIL_DATA)); |
File thumbnailFile = File.createTempFile("thumbnail", ".jpg"); |
try { |
exifDirectory.writeThumbnail(thumbnailFile.getAbsolutePath()); |
assertTrue(new File(thumbnailFile.getAbsolutePath()).exists()); |
} finally { |
thumbnailFile.delete(); |
} |
} |
public void testContainsThumbnail() |
{ |
ExifDirectory exifDirectory = new ExifDirectory(); |
assertTrue(!exifDirectory.containsThumbnail()); |
exifDirectory.setObject(ExifDirectory.TAG_THUMBNAIL_DATA, "foo"); |
assertTrue(exifDirectory.containsThumbnail()); |
} |
} |