You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by da...@apache.org on 2012/09/27 07:42:26 UTC
svn commit: r1390849 [3/3] - in
/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats:
bmp/ bmp/pixelparsers/ bmp/writers/ dcx/ gif/ icns/ ico/ jpeg/
jpeg/decoder/ jpeg/exif/ jpeg/iptc/ jpeg/segments/ jpeg/xmp/
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java?rev=1390849&r1=1390848&r2=1390849&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java Thu Sep 27 05:42:25 2012
@@ -106,26 +106,32 @@ public class JpegRewriter extends Binary
}
public boolean isExifSegment() {
- if (marker != JPEG_APP1_Marker)
+ if (marker != JPEG_APP1_Marker) {
return false;
- if (!byteArrayHasPrefix(segmentData, EXIF_IDENTIFIER_CODE))
+ }
+ if (!byteArrayHasPrefix(segmentData, EXIF_IDENTIFIER_CODE)) {
return false;
+ }
return true;
}
public boolean isPhotoshopApp13Segment() {
- if (marker != JPEG_APP13_Marker)
+ if (marker != JPEG_APP13_Marker) {
return false;
- if (!new IptcParser().isPhotoshopJpegSegment(segmentData))
+ }
+ if (!new IptcParser().isPhotoshopJpegSegment(segmentData)) {
return false;
+ }
return true;
}
public boolean isXmpSegment() {
- if (marker != JPEG_APP1_Marker)
+ if (marker != JPEG_APP1_Marker) {
return false;
- if (!byteArrayHasPrefix(segmentData, XMP_IDENTIFIER))
+ }
+ if (!byteArrayHasPrefix(segmentData, XMP_IDENTIFIER)) {
return false;
+ }
return true;
}
@@ -237,10 +243,12 @@ public class JpegRewriter extends Binary
for (int i = 0; i < segments.size(); i++) {
T piece = segments.get(i);
if (piece instanceof JFIFPieceSegment) {
- if (filter.filter((JFIFPieceSegment) piece) ^ !reverse)
+ if (filter.filter((JFIFPieceSegment) piece) ^ !reverse) {
result.add(piece);
- } else if (!reverse)
+ }
+ } else if (!reverse) {
result.add(piece);
+ }
}
return result;
@@ -251,19 +259,22 @@ public class JpegRewriter extends Binary
int firstAppIndex = -1;
for (int i = 0; i < segments.size(); i++) {
JFIFPiece piece = segments.get(i);
- if (!(piece instanceof JFIFPieceSegment))
+ if (!(piece instanceof JFIFPieceSegment)) {
continue;
+ }
JFIFPieceSegment segment = (JFIFPieceSegment) piece;
if (segment.isAppSegment()) {
- if (firstAppIndex == -1)
+ if (firstAppIndex == -1) {
firstAppIndex = i;
+ }
}
}
List<JFIFPiece> result = new ArrayList<JFIFPiece>(segments);
- if (firstAppIndex == -1)
+ if (firstAppIndex == -1) {
throw new ImageWriteException("JPEG file has no APP segments.");
+ }
result.addAll(firstAppIndex, newSegments);
return result;
}
@@ -273,21 +284,25 @@ public class JpegRewriter extends Binary
int lastAppIndex = -1;
for (int i = 0; i < segments.size(); i++) {
JFIFPiece piece = segments.get(i);
- if (!(piece instanceof JFIFPieceSegment))
+ if (!(piece instanceof JFIFPieceSegment)) {
continue;
+ }
JFIFPieceSegment segment = (JFIFPieceSegment) piece;
- if (segment.isAppSegment())
+ if (segment.isAppSegment()) {
lastAppIndex = i;
+ }
}
List<JFIFPiece> result = new ArrayList<JFIFPiece>(segments);
if (lastAppIndex == -1) {
- if (segments.size() < 1)
+ if (segments.size() < 1) {
throw new ImageWriteException("JPEG file has no APP segments.");
+ }
result.addAll(1, newSegments);
- } else
+ } else {
result.addAll(lastAppIndex + 1, newSegments);
+ }
return result;
}
@@ -305,8 +320,9 @@ public class JpegRewriter extends Binary
os = null;
} finally {
try {
- if (os != null)
+ if (os != null) {
os.close();
+ }
} catch (Exception e) {
// swallow exception; already in the context of an exception.
}