JAI Migration
Eclipse ImageN offers a migration path for developers using the Java Advanced Imaging Framework.
To upgrade:
-
To migrate from a project depending on JAI 1.1.3:
<properties> <jai.version>1.1.3</jai.version> </properties> ... <dependency> <groupId>javax.media</groupId> <artifactId>jai_core</artifactId> <version>1.1.3</version> </dependency> <dependency> <groupId>org.eclipse.imagen</groupId> <artifactId>jai_codec</artifactId> <version>${jai.version}</version> </dependency>
-
Replace with Eclipse ImageN dependency:
Replacing:
<properties> <imagen.version>0.4-SNAPSHOT</imagen.version> </properties> ... <dependency> <groupId>org.eclipse.imagen</groupId> <artifactId>imagen-core</artifactId> <version>${imagen.version}</version> </dependency>
Note
imagen-core
is includesimagen-codec
as a transitive dependency. -
Source code imports:
import java.awt.Frame; import java.awt.image.renderable.ParameterBlock; import java.io.IOException; import javax.media.jai.Interpolation; import javax.media.jai.JAI; import javax.media.jai.RenderedOp; import com.sun.media.jai.codec.FileSeekableStream; import javax.media.jai.widget.ScrollingImagePanel; public class JAISampleProgram { ... }
-
Can be directly replaced:
- Replace
javax.media.jai
with packageorg.eclipse.imagen
- Replace
com.sun.media.jai
with packageorg.eclipse.imagen.media
import java.awt.Frame; import java.awt.image.renderable.ParameterBlock; import java.io.IOException; import org.eclipse.imagen.Interpolation; import org.eclipse.imagen.JAI; import org.eclipse.imagen.RenderedOp; import org.eclipse.imagen.media.codec.FileSeekableStream; import org.eclipse.imagen.widget.ScrollingImagePanel; public class ImageNSampleProgram { ... }
- Replace
Java Image Formats
Both the Java platform and ImageN include encoding/decoding codecs for image formats:
Format | Java 8 ImageIO | ImageN Codec | Java 11 ImageIO |
---|---|---|---|
BMP | read/write | read/write | read/write |
FlashPix | read | ||
GIF | read/write | read | read/write |
JPEG | read/write | read/write | read/write |
PNG | read/write | read/write | read/write |
PNM | read/write | ||
TIFF | read/write | read/write | |
WBMP | read/write | read | read/write |
Oracle JDK 8 includes the internal com.sun.image.codec.jpeg
packages used by imagen-codec
JPEG read/write support listed above. These packages are not available in OpenJDK 8 or Java 11.
The key format missing from Java 8 is TIFF, which is included in ImageIO
from Java 9 onward. You may wish to continue to use imagen-codec
to provide TIFF support when operating in a Java 8 environment:
<profiles>
<profile>
<id>java8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.eclipse.imagen</groupId>
<artifactId>jai-codec</artifactId>
<version>${jai.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>
MediaLib (Unsupported)
This work is provided to aid those migrating to Eclipse ImageN and is not supported or intended for production use. Recent experience shows that improvements in JIT compiler technology have eroded the performance benefits of these native operations. While the MediaLib library was released as part of OpenSolaris the specific builds distributed with JAI remain closed source and cannot be maintained.
The operations taking advantage of mlibwrapper_jai
have been factored out into a seperate imagen_mlib
dependency:
<dependency>
<groupId>javax.media</groupId>
<artifactId>mlibwrapper_jai</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.eclipse.imagen</groupId>
<artifactId>imagen_mlib</artifactId>
<version>${imagen.version}</version>
</dependency>