commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1331325 - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java
Date Fri, 27 Apr 2012 09:54:56 GMT
Author: damjan
Date: Fri Apr 27 09:54:55 2012
New Revision: 1331325

URL: http://svn.apache.org/viewvc?rev=1331325&view=rev
Log:
Allow TIFF fields to change size during encoding.
Fix a broken test that assumes they never do.

Jira issue key: SANSELAN-77


Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java?rev=1331325&r1=1331324&r2=1331325&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java
Fri Apr 27 09:54:55 2012
@@ -164,7 +164,6 @@ public class TiffImageMetadata extends I
 
                     TagInfo tagInfo = srcField.tagInfo;
                     FieldType fieldType = srcField.fieldType;
-                    int count = srcField.length;
                     //            byte bytes[] = srcField.fieldType.getRawBytes(srcField);
 
                     //                    Debug.debug("tagInfo", tagInfo);
@@ -182,6 +181,7 @@ public class TiffImageMetadata extends I
                     //                                        + Integer.toHexString(srcField.tag)
                     //                                        + ") bytes", bytes);
 
+                    int count = bytes.length / fieldType.length;
                     TiffOutputField dstField = new TiffOutputField(
                             srcField.tag, tagInfo, fieldType, count, bytes);
                     dstField.setSortHint(srcField.getSortHint());

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java?rev=1331325&r1=1331324&r2=1331325&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java
Fri Apr 27 09:54:55 2012
@@ -419,16 +419,7 @@ public class ExifRewriteTest extends Exi
                 assertEquals(oldField.tag, newField.tag);
                 assertEquals(dirType.intValue(), newField.directoryType);
                 assertEquals(oldField.directoryType, newField.directoryType);
-                assertEquals(oldField.length, newField.length);
-                assertEquals(oldField.isLocalValue(), newField.isLocalValue());
-
-                if (oldField.tag == 0x202)
-                {
-                    // ignore "jpg from raw length" value. may have off-by-one bug in certain
cameras.
-                    // i.e. Sony DCR-PC110
-                    continue;
-                }
-
+                
                 if (oldField.fieldType == TiffFieldTypeConstants.FIELD_TYPE_ASCII)
                 {
                     // Sanselan currently doesn't correctly rewrite
@@ -448,6 +439,16 @@ public class ExifRewriteTest extends Exi
                         continue;
                 }
 
+                assertEquals(oldField.length, newField.length);
+                assertEquals(oldField.isLocalValue(), newField.isLocalValue());
+
+                if (oldField.tag == 0x202)
+                {
+                    // ignore "jpg from raw length" value. may have off-by-one bug in certain
cameras.
+                    // i.e. Sony DCR-PC110
+                    continue;
+                }
+
                 if (!oldField.tagInfo.isOffset())
                 {
                     if (oldField.tagInfo.isText())



Mime
View raw message