mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-02 19:15:29 -04:00
Remove runtime dependency to TIFF plugin from contrib module
Also removed public flag from plugin classes again. Replaced by temporary clones.
This commit is contained in:
parent
342dbe7d83
commit
c6e8711639
@ -43,10 +43,16 @@
|
|||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
|
<artifactId>imageio-metadata</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio-tiff</artifactId>
|
<artifactId>imageio-tiff</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
|
@ -29,28 +29,25 @@
|
|||||||
package com.twelvemonkeys.contrib.tiff;
|
package com.twelvemonkeys.contrib.tiff;
|
||||||
|
|
||||||
import com.twelvemonkeys.imageio.metadata.AbstractDirectory;
|
import com.twelvemonkeys.imageio.metadata.AbstractDirectory;
|
||||||
|
import com.twelvemonkeys.imageio.metadata.AbstractEntry;
|
||||||
import com.twelvemonkeys.imageio.metadata.CompoundDirectory;
|
import com.twelvemonkeys.imageio.metadata.CompoundDirectory;
|
||||||
import com.twelvemonkeys.imageio.metadata.Directory;
|
import com.twelvemonkeys.imageio.metadata.Directory;
|
||||||
import com.twelvemonkeys.imageio.metadata.Entry;
|
import com.twelvemonkeys.imageio.metadata.Entry;
|
||||||
import com.twelvemonkeys.imageio.metadata.exif.EXIFReader;
|
import com.twelvemonkeys.imageio.metadata.exif.EXIFReader;
|
||||||
import com.twelvemonkeys.imageio.metadata.exif.EXIFWriter;
|
import com.twelvemonkeys.imageio.metadata.exif.EXIFWriter;
|
||||||
|
import com.twelvemonkeys.imageio.metadata.exif.Rational;
|
||||||
import com.twelvemonkeys.imageio.metadata.exif.TIFF;
|
import com.twelvemonkeys.imageio.metadata.exif.TIFF;
|
||||||
import com.twelvemonkeys.imageio.plugins.tiff.TIFFBaseline;
|
|
||||||
import com.twelvemonkeys.imageio.plugins.tiff.TIFFExtension;
|
|
||||||
import com.twelvemonkeys.imageio.plugins.tiff.TIFFImageWriter;
|
|
||||||
import com.twelvemonkeys.imageio.plugins.tiff.TIFFImageWriter.TIFFEntry;
|
|
||||||
import com.twelvemonkeys.lang.Validate;
|
import com.twelvemonkeys.lang.Validate;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.imageio.stream.ImageInputStream;
|
import javax.imageio.stream.ImageInputStream;
|
||||||
import javax.imageio.stream.ImageOutputStream;
|
import javax.imageio.stream.ImageOutputStream;
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
import java.awt.image.AffineTransformOp;
|
import java.awt.image.AffineTransformOp;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.ColorModel;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -66,8 +63,6 @@ public class TIFFUtilities {
|
|||||||
private TIFFUtilities() {
|
private TIFFUtilities() {
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merges all pages from the input TIFF files into one TIFF file at the
|
* Merges all pages from the input TIFF files into one TIFF file at the
|
||||||
* output location.
|
* output location.
|
||||||
@ -422,9 +417,98 @@ public class TIFFUtilities {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newIDFData.add(new TIFFImageWriter.TIFFEntry(TIFF.TAG_ORIENTATION, (short) orientation));
|
newIDFData.add(new TIFFEntry(TIFF.TAG_ORIENTATION, (short) orientation));
|
||||||
IFD = new AbstractDirectory(newIDFData) {
|
IFD = new AbstractDirectory(newIDFData) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Temporary clone, to be removed after TMI204 has been closed
|
||||||
|
*/
|
||||||
|
public static final class TIFFEntry extends AbstractEntry {
|
||||||
|
// TODO: Expose a merge of this and the EXIFEntry class...
|
||||||
|
private final short type;
|
||||||
|
|
||||||
|
private static short guessType(final Object val) {
|
||||||
|
// TODO: This code is duplicated in EXIFWriter.getType, needs refactor!
|
||||||
|
Object value = Validate.notNull(val);
|
||||||
|
|
||||||
|
boolean array = value.getClass().isArray();
|
||||||
|
if (array) {
|
||||||
|
value = Array.get(value, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: This "narrowing" is to keep data consistent between read/write.
|
||||||
|
// TODO: Check for negative values and use signed types?
|
||||||
|
if (value instanceof Byte) {
|
||||||
|
return TIFF.TYPE_BYTE;
|
||||||
|
}
|
||||||
|
if (value instanceof Short) {
|
||||||
|
if (!array && (Short) value < Byte.MAX_VALUE) {
|
||||||
|
return TIFF.TYPE_BYTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TIFF.TYPE_SHORT;
|
||||||
|
}
|
||||||
|
if (value instanceof Integer) {
|
||||||
|
if (!array && (Integer) value < Short.MAX_VALUE) {
|
||||||
|
return TIFF.TYPE_SHORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TIFF.TYPE_LONG;
|
||||||
|
}
|
||||||
|
if (value instanceof Long) {
|
||||||
|
if (!array && (Long) value < Integer.MAX_VALUE) {
|
||||||
|
return TIFF.TYPE_LONG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value instanceof Rational) {
|
||||||
|
return TIFF.TYPE_RATIONAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value instanceof String) {
|
||||||
|
return TIFF.TYPE_ASCII;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: More types
|
||||||
|
|
||||||
|
throw new UnsupportedOperationException(String.format("Method guessType not implemented for value of type %s", value.getClass()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public TIFFEntry(final int identifier, final Object value) {
|
||||||
|
this(identifier, guessType(value), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
TIFFEntry(int identifier, short type, Object value) {
|
||||||
|
super(identifier, value);
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return TIFF.TYPE_NAMES[type];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Temporary clone, to be removed after TMI204 has been closed
|
||||||
|
*/
|
||||||
|
public interface TIFFExtension {
|
||||||
|
int ORIENTATION_TOPRIGHT = 2;
|
||||||
|
int ORIENTATION_BOTRIGHT = 3;
|
||||||
|
int ORIENTATION_BOTLEFT = 4;
|
||||||
|
int ORIENTATION_LEFTTOP = 5;
|
||||||
|
int ORIENTATION_RIGHTTOP = 6;
|
||||||
|
int ORIENTATION_RIGHTBOT = 7;
|
||||||
|
int ORIENTATION_LEFTBOT = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Temporary clone, to be removed after TMI204 has been closed
|
||||||
|
*/
|
||||||
|
public interface TIFFBaseline {
|
||||||
|
int ORIENTATION_TOPLEFT = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
package com.twelvemonkeys.contrib.tiff;
|
package com.twelvemonkeys.contrib.tiff;
|
||||||
|
|
||||||
import com.twelvemonkeys.imageio.plugins.tiff.TIFFExtension;
|
import com.twelvemonkeys.contrib.tiff.TIFFUtilities.TIFFExtension;
|
||||||
import com.twelvemonkeys.imageio.plugins.tiff.TIFFMedataFormat;
|
import com.twelvemonkeys.imageio.plugins.tiff.TIFFMedataFormat;
|
||||||
import com.twelvemonkeys.io.FileUtil;
|
import com.twelvemonkeys.io.FileUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -35,7 +35,7 @@ package com.twelvemonkeys.imageio.plugins.tiff;
|
|||||||
* @author last modified by $Author: haraldk$
|
* @author last modified by $Author: haraldk$
|
||||||
* @version $Id: TIFFBaseline.java,v 1.0 08.05.12 16:43 haraldk Exp$
|
* @version $Id: TIFFBaseline.java,v 1.0 08.05.12 16:43 haraldk Exp$
|
||||||
*/
|
*/
|
||||||
public interface TIFFBaseline {
|
interface TIFFBaseline {
|
||||||
int COMPRESSION_NONE = 1;
|
int COMPRESSION_NONE = 1;
|
||||||
int COMPRESSION_CCITT_MODIFIED_HUFFMAN_RLE = 2;
|
int COMPRESSION_CCITT_MODIFIED_HUFFMAN_RLE = 2;
|
||||||
int COMPRESSION_PACKBITS = 32773;
|
int COMPRESSION_PACKBITS = 32773;
|
||||||
|
@ -35,7 +35,7 @@ package com.twelvemonkeys.imageio.plugins.tiff;
|
|||||||
* @author last modified by $Author: haraldk$
|
* @author last modified by $Author: haraldk$
|
||||||
* @version $Id: TIFFExtension.java,v 1.0 08.05.12 16:45 haraldk Exp$
|
* @version $Id: TIFFExtension.java,v 1.0 08.05.12 16:45 haraldk Exp$
|
||||||
*/
|
*/
|
||||||
public interface TIFFExtension {
|
interface TIFFExtension {
|
||||||
/** CCITT T.4/Group 3 Fax compression. */
|
/** CCITT T.4/Group 3 Fax compression. */
|
||||||
int COMPRESSION_CCITT_T4 = 3;
|
int COMPRESSION_CCITT_T4 = 3;
|
||||||
/** CCITT T.6/Group 4 Fax compression. */
|
/** CCITT T.6/Group 4 Fax compression. */
|
||||||
|
@ -113,7 +113,7 @@ public final class TIFFImageWriter extends ImageWriterBase {
|
|||||||
// TODO: Allow appending/partly overwrite of existing file...
|
// TODO: Allow appending/partly overwrite of existing file...
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class TIFFEntry extends AbstractEntry {
|
static final class TIFFEntry extends AbstractEntry {
|
||||||
// TODO: Expose a merge of this and the EXIFEntry class...
|
// TODO: Expose a merge of this and the EXIFEntry class...
|
||||||
private final short type;
|
private final short type;
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ public final class TIFFImageWriter extends ImageWriterBase {
|
|||||||
throw new UnsupportedOperationException(String.format("Method guessType not implemented for value of type %s", value.getClass()));
|
throw new UnsupportedOperationException(String.format("Method guessType not implemented for value of type %s", value.getClass()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public TIFFEntry(final int identifier, final Object value) {
|
TIFFEntry(final int identifier, final Object value) {
|
||||||
this(identifier, guessType(value), value);
|
this(identifier, guessType(value), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user