Less info, refer to the Github page.

This commit is contained in:
Harald Kuhr 2021-04-24 18:33:41 +02:00
parent 41fd6a7832
commit e131db660b

View File

@ -51,15 +51,8 @@
<h2>
<a id="about" class="anchor" href="#about" aria-hidden="true"><span class="octicon octicon-link"></span></a>About</h2>
<p>TwelveMonkeys ImageIO is a collection of plugins and extensions for Java's ImageIO.</p>
<p>These plugins extend the number of image file formats supported in Java, using the <code>javax.imageio.*</code>
package. The main purpose of this project is to provide support for formats not covered by the JRE itself.</p>
<p>Support for formats is important, both to be able to read data found
"in the wild", as well as to maintain access to data in legacy formats.
Because there is lots of legacy data out there, we see the need for open implementations of readers for popular formats.
The goal is to create a set of efficient and robust ImageIO plug-ins, that can be distributed independently.</p>
<p>TwelveMonkeys ImageIO provides extended image file format support for the Java platform,
through plugins for the <code>javax.imageio.*</code>package.</p>
<hr>
@ -481,463 +474,6 @@ and make sure you use version 1.14 or later.</em></p>
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/imageio/package-summary.html" rel="nofollow">JDK standard plugins</a>.
For BMP, JPEG, and TIFF formats the TwelveMonkeys plugins provides extended format support and additional features.</p>
<h2><a id="user-content-basic-usage" class="anchor" href="#basic-usage" aria-hidden="true"><span class="octicon octicon-link"></span></a>Basic usage</h2>
<p>Most of the time, all you need to do is simply include the plugins in your project and write:</p>
<pre><code>BufferedImage image = ImageIO.read(file);
</code></pre>
<p>This will load the first image of the file, entirely into memory.</p>
<p>The basic and simplest form of writing is:</p>
<pre><code>if (!ImageIO.write(image, format, file)) {
// Handle image not written case
}
</code></pre>
<p>This will write the entire image into a single file, using the default settings for the given format.</p>
<p>The plugins are discovered automatically at run time. See the <a href="#faq">FAQ</a> for more info on how this mechanism works.</p>
<h2><a id="user-content-advanced-usage" class="anchor" href="#advanced-usage" aria-hidden="true"><span class="octicon octicon-link"></span></a>Advanced usage</h2>
<p>If you need more control of read parameters and the reading process, the common idiom for reading is something like:</p>
<pre><code>// Create input stream
ImageInputStream input = ImageIO.createImageInputStream(file);
try {
// Get the reader
Iterator&lt;ImageReader&gt; readers = ImageIO.getImageReaders(input);
if (!readers.hasNext()) {
throw new IllegalArgumentException("No reader for: " + file);
}
ImageReader reader = readers.next();
try {
reader.setInput(input);
// Optionally, listen for read warnings, progress, etc.
reader.addIIOReadWarningListener(...);
reader.addIIOReadProgressListener(...);
ImageReadParam param = reader.getDefaultReadParam();
// Optionally, control read settings like sub sampling, source region or destination etc.
param.setSourceSubsampling(...);
param.setSourceRegion(...);
param.setDestination(...);
// ...
// Finally read the image, using settings from param
BufferedImage image = reader.read(0, param);
// Optionally, read thumbnails, meta data, etc...
int numThumbs = reader.getNumThumbnails(0);
// ...
}
finally {
// Dispose reader in finally block to avoid memory leaks
reader.dispose();
}
}
finally {
// Close stream in finally block to avoid resource leaks
input.close();
}
</code></pre>
<p>Query the reader for source image dimensions using <code>reader.getWidth(n)</code> and <code>reader.getHeight(n)</code> without reading the
entire image into memory first.</p>
<p>It's also possible to read multiple images from the same file in a loop, using <code>reader.getNumImages()</code>.</p>
<p>If you need more control of write parameters and the writing process, the common idiom for writing is something like:</p>
<pre><code>// Get the writer
Iterator&lt;ImageWriter&gt; writers = ImageIO.getImageWritersByFormatName(format);
if (!writers.hasNext()) {
throw new IllegalArgumentException("No writer for: " + format);
}
ImageWriter writer = writers.next();
try {
// Create output stream
ImageOutputStream output = ImageIO.createImageOutputStream(file);
try {
writer.setOutput(output);
// Optionally, listen to progress, warnings, etc.
ImageWriteParam param = writer.getDefaultWriteParam();
// Optionally, control format specific settings of param (requires casting), or
// control generic write settings like sub sampling, source region, output type etc.
// Optionally, provide thumbnails and image/stream metadata
writer.write(..., new IIOImage(..., image, ...), param);
}
finally {
// Close stream in finally block to avoid resource leaks
output.close();
}
}
finally {
// Dispose writer in finally block to avoid memory leaks
writer.dispose();
}
</code></pre>
<p>For more advanced usage, and information on how to use the ImageIO API, I suggest you read the
<a href="http://docs.oracle.com/javase/7/docs/technotes/guides/imageio/spec/imageio_guideTOC.fm.html">Java Image I/O API Guide</a>
from Oracle.</p>
<h4><a id="user-content-deploying-the-plugins-in-a-web-app" class="anchor" href="#deploying-the-plugins-in-a-web-app" aria-hidden="true"><span class="octicon octicon-link"></span></a>Deploying the plugins in a web app</h4>
<p>Because the <code>ImageIO</code> plugin registry (the <code>IIORegistry</code>) is "VM global", it doesn't by default work well with
servlet contexts. This is especially evident if you load plugins from the <code>WEB-INF/lib</code> or <code>classes</code> folder.
Unless you add <code>ImageIO.scanForPlugins()</code> somewhere in your code, the plugins might never be available at all.</p>
<p>I addition, servlet contexts dynamically loads and unloads classes (using a new class loader per context).
If you restart your application, old classes will by default remain in memory forever (because the next time
<code>scanForPlugins</code> is called, it's another <code>ClassLoader</code> that scans/loads classes, and thus they will be new instances
in the registry). If a read is attempted using one of the remaining "old" readers, weird exceptions
(like <code>NullPointerException</code>s when accessing <code>static final</code> initialized fields or <code>NoClassDefFoundError</code>s
for uninitialized inner classes) may occur.</p>
<p>To work around both the discovery problem and the resource leak,
it is <em>strongly recommended</em> to use the <code>IIOProviderContextListener</code> that implements
dynamic loading and unloading of ImageIO plugins for web applications.</p>
<pre><code>&lt;web-app ...&gt;
...
&lt;listener&gt;
&lt;display-name&gt;ImageIO service provider loader/unloader&lt;/display-name&gt;
&lt;listener-class&gt;com.twelvemonkeys.servlet.image.IIOProviderContextListener&lt;/listener-class&gt;
&lt;/listener&gt;
...
&lt;/web-app&gt;
</code></pre>
<p>Loading plugins from <code>WEB-INF/lib</code> without the context listener installed is unsupported and will not work correctly.</p>
<p>The context listener has no dependencies to the TwelveMonkeys ImageIO plugins, and may be used with JAI ImageIO
or other ImageIO plugins as well.</p>
<p>Another safe option, is to place the JAR files in the application server's shared or common lib folder. </p>
<h4><a id="user-content-using-the-resampleop" class="anchor" href="#using-the-resampleop" aria-hidden="true"><span class="octicon octicon-link"></span></a>Using the ResampleOp</h4>
<p>The library comes with a resampling (image resizing) operation, that contains many different algorithms
to provide excellent results at reasonable speed.</p>
<pre><code>import com.twelvemonkeys.image.ResampleOp;
...
BufferedImage input = ...; // Image to resample
int width, height = ...; // new width/height
BufferedImageOp resampler = new ResampleOp(width, height, ResampleOp.FILTER_LANCZOS); // A good default filter, see class documentation for more info
BufferedImage output = resampler.filter(input, null);
</code></pre>
<h4><a id="user-content-using-the-diffusiondither" class="anchor" href="#using-the-diffusiondither" aria-hidden="true"><span class="octicon octicon-link"></span></a>Using the DiffusionDither</h4>
<p>The library comes with a dithering operation, that can be used to convert <code>BufferedImage</code>s to <code>IndexColorModel</code> using
Floyd-Steinberg error-diffusion dither.</p>
<pre><code>import com.twelvemonkeys.image.DiffusionDither;
...
BufferedImage input = ...; // Image to dither
BufferedImageOp ditherer = new DiffusionDither();
BufferedImage output = ditherer.filter(input, null);
</code></pre>
<h2><a id="user-content-building" class="anchor" href="#building" aria-hidden="true"><span class="octicon octicon-link"></span></a>Building</h2>
<p>Download the project (using <a href="http://git-scm.com/downloads">Git</a>):</p>
<pre><code>$ git clone git@github.com:haraldk/TwelveMonkeys.git
</code></pre>
<p>This should create a folder named <code>TwelveMonkeys</code> in your current directory. Change directory to the <code>TwelveMonkeys</code>
folder, and issue the command below to build.</p>
<p>Build the project (using <a href="http://maven.apache.org/download.cgi">Maven</a>):</p>
<pre><code>$ mvn package
</code></pre>
<p>Currently, the recommended JDK for making a build is Oracle JDK 7.x or 8.x. </p>
<p>It's possible to build using OpenJDK, but some tests might fail due to some minor differences between the color management systems used. You will need to either disable the tests in question, or build without tests altogether.</p>
<p>Because the unit tests needs quite a bit of memory to run, you might have to set the environment variable <code>MAVEN_OPTS</code>
to give the Java process that runs Maven more memory. I suggest something like <code>-Xmx512m -XX:MaxPermSize=256m</code>.</p>
<p>Optionally, you can install the project in your local Maven repository using:</p>
<pre><code>$ mvn install
</code></pre>
<h2><a id="user-content-installing" class="anchor" href="#installing" aria-hidden="true"><span class="octicon octicon-link"></span></a>Installing</h2>
<p>To install the plug-ins,
either use Maven and add the necessary dependencies to your project,
or manually add the needed JARs along with required dependencies in class-path.</p>
<p>The ImageIO registry and service lookup mechanism will make sure the plugins are available for use.</p>
<p>To verify that the JPEG plugin is installed and used at run-time, you could use the following code:</p>
<pre><code>Iterator&lt;ImageReader&gt; readers = ImageIO.getImageReadersByFormatName("JPEG");
while (readers.hasNext()) {
System.out.println("reader: " + readers.next());
}
</code></pre>
<p>The first line should print:</p>
<pre><code>reader: com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader@somehash
</code></pre>
<h4><a id="user-content-maven-dependency-example" class="anchor" href="#maven-dependency-example" aria-hidden="true"><span class="octicon octicon-link"></span></a>Maven dependency example</h4>
<p>To depend on the JPEG and TIFF plugin using Maven, add the following to your POM:</p>
<pre><code>...
&lt;dependencies&gt;
...
&lt;dependency&gt;
&lt;groupId&gt;com.twelvemonkeys.imageio&lt;/groupId&gt;
&lt;artifactId&gt;imageio-jpeg&lt;/artifactId&gt;
&lt;version&gt;3.7.0&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.twelvemonkeys.imageio&lt;/groupId&gt;
&lt;artifactId&gt;imageio-tiff&lt;/artifactId&gt;
&lt;version&gt;3.7.0&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
</code></pre>
<h4><a id="user-content-manual-dependency-example" class="anchor" href="#manual-dependency-example" aria-hidden="true"><span class="octicon octicon-link"></span></a>Manual dependency example</h4>
<p>To depend on the JPEG and TIFF plugin in your IDE or program, add all of the following JARs to your class path:</p>
<pre><code>twelvemonkeys-common-lang-3.7.0.jar
twelvemonkeys-common-io-3.7.0.jar
twelvemonkeys-common-image-3.7.0.jar
twelvemonkeys-imageio-core-3.7.0.jar
twelvemonkeys-imageio-metadata-3.7.0.jar
twelvemonkeys-imageio-jpeg-3.7.0.jar
twelvemonkeys-imageio-tiff-3.7.0.jar
</code></pre>
<h3><a id="user-content-links-to-prebuilt-binaries" class="anchor" href="#links-to-prebuilt-binaries" aria-hidden="true"><span class="octicon octicon-link"></span></a>Links to prebuilt binaries</h3>
<h5><a id="user-content-latest-version" class="anchor" href="#latest-version" aria-hidden="true"><span class="octicon octicon-link"></span></a>Latest version</h5>
<p>Requires Java 7 or later.</p>
<p>Common dependencies</p>
<ul>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/common/common-lang/3.7.0/common-lang-3.7.0.jar">common-lang-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/common/common-io/3.7.0/common-io-3.7.0.jar">common-io-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/common/common-image/3.7.0/common-image-3.7.0.jar">common-image-3.7.0.jar</a></li>
</ul>
<p>ImageIO dependencies</p>
<ul>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-core/3.7.0/imageio-core-3.7.0.jar">imageio-core-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-metadata/3.7.0/imageio-metadata-3.7.0.jar">imageio-metadata-3.7.0.jar</a></li>
</ul>
<p>ImageIO plugins</p>
<ul>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-bmp/3.7.0/imageio-bmp-3.7.0.jar">imageio-bmp-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-jpeg/3.7.0/imageio-jpeg-3.7.0.jar">imageio-jpeg-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-tiff/3.7.0/imageio-tiff-3.7.0.jar">imageio-tiff-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-pnm/3.7.0/imageio-pnm-3.7.0.jar">imageio-pnm-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-psd/3.7.0/imageio-psd-3.7.0.jar">imageio-psd-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-hdr/3.7.0/imageio-hdr-3.7.0.jar">imageio-hdr-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-iff/3.7.0/imageio-iff-3.7.0.jar">imageio-iff-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-pcx/3.7.0/imageio-pcx-3.7.0.jar">imageio-pcx-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-pict/3.7.0/imageio-pict-3.7.0.jar">imageio-pict-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-sgi/3.7.0/imageio-sgi-3.7.0.jar">imageio-sgi-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-tga/3.7.0/imageio-tga-3.7.0.jar">imageio-tga-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-icns/3.7.0/imageio-icns-3.7.0.jar">imageio-icns-3.7.0.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-thumbsdb/3.7.0/imageio-thumbsdb-3.7.0.jar">imageio-thumbsdb-3.7.0.jar</a></li>
</ul>
<p>ImageIO plugins requiring 3rd party libs</p>
<ul>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-batik/3.7.0/imageio-batik-3.7.0.jar">imageio-batik-3.7.0.jar</a></li>
</ul>
<p>Photoshop Path support for ImageIO</p>
<ul>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-clippath/3.7.0/imageio-clippath-3.7.0.jar">imageio-clippath-3.7.0.jar</a></li>
</ul>
<p>Servlet support</p>
<ul>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/servlet/servlet/3.7.0/servlet-3.7.0.jar">servlet-3.7.0.jar</a></li>
</ul>
<h5><a id="user-content-old-version-30x" class="anchor" href="#old-version-30x" aria-hidden="true"><span class="octicon octicon-link"></span></a>Old version (3.0.x)</h5>
<p>Use this version for projects that requires Java 6 or need the JMagick support. <em>Does not support Java 8</em>. </p>
<p>Common dependencies</p>
<ul>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/common/common-lang/3.0.2/common-lang-3.0.2.jar">common-lang-3.0.2.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/common/common-io/3.0.2/common-io-3.0.2.jar">common-io-3.0.2.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/common/common-image/3.0.2/common-image-3.0.2.jar">common-image-3.0.2.jar</a></li>
</ul>
<p>ImageIO dependencies</p>
<ul>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-core/3.0.2/imageio-core-3.0.2.jar">imageio-core-3.0.2.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-metadata/3.0.2/imageio-metadata-3.0.2.jar">imageio-metadata-3.0.2.jar</a></li>
</ul>
<p>ImageIO plugins</p>
<ul>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-jpeg/3.0.2/imageio-jpeg-3.0.2.jar">imageio-jpeg-3.0.2.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-tiff/3.0.2/imageio-tiff-3.0.2.jar">imageio-tiff-3.0.2.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-psd/3.0.2/imageio-psd-3.0.2.jar">imageio-psd-3.0.2.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-pict/3.0.2/imageio-pict-3.0.2.jar">imageio-pict-3.0.2.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-iff/3.0.2/imageio-iff-3.0.2.jar">imageio-iff-3.0.2.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-icns/3.0.2/imageio-icns-3.0.2.jar">imageio-icns-3.0.2.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-ico/3.0.2/imageio-ico-3.0.2.jar">imageio-ico-3.0.2.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-thumbsdb/3.0.2/imageio-thumbsdb-3.0.2.jar">imageio-thumbsdb-3.0.2.jar</a></li>
</ul>
<p>ImageIO plugins requiring 3rd party libs</p>
<ul>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-batik/3.0.2/imageio-batik-3.0.2.jar">imageio-batik-3.0.2.jar</a></li>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/imageio/imageio-jmagick/3.0.2/imageio-jmagick-3.0.2.jar">imageio-jmagick-3.0.2.jar</a></li>
</ul>
<p>Servlet support</p>
<ul>
<li><a href="http://search.maven.org/remotecontent?filepath=com/twelvemonkeys/servlet/servlet/3.0.2/servlet-3.0.2.jar">servlet-3.0.2.jar</a></li>
</ul>
<h2><a id="user-content-license" class="anchor" href="#license" aria-hidden="true"><span class="octicon octicon-link"></span></a>License</h2>
<p>The project is distributed under the OSI approved <a href="http://opensource.org/licenses/BSD-3-Clause">BSD license</a>:</p>
<pre><code>Copyright (c) 2008-2018, Harald Kuhr
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
o Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
o Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
o Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</code></pre>
<h2><a id="user-content-faq" class="anchor" href="#faq" aria-hidden="true"><span class="octicon octicon-link"></span></a>FAQ</h2>
<p>q: How do I use it?</p>
<p>a: The easiest way is to build your own project using Maven, and just add dependencies to the specific plug-ins you need.
If you don't use Maven, make sure you have all the necessary JARs in classpath. See the Install section above.</p>
<p>q: What changes do I have to make to my code in order to use the plug-ins?</p>
<p>a: The short answer is: None. For basic usage, like <code>ImageIO.read(...)</code> or <code>ImageIO.getImageReaders(...)</code>, there is no need
to change your code. Most of the functionality is available through standard ImageIO APIs, and great care has been taken
not to introduce extra API where none is necessary.</p>
<p>Should you want to use very specific/advanced features of some of the formats, you might have to use specific APIs, like
setting base URL for an SVG image that consists of multiple files,
or controlling the output compression of a TIFF file.</p>
<p>q: How does it work?</p>
<p>a: The TwelveMonkeys ImageIO project contains plug-ins for ImageIO. ImageIO uses a service lookup mechanism, to discover plug-ins at runtime. </p>
<p>All you have have to do, is to make sure you have the TwelveMonkeys JARs in your classpath.</p>
<p>You can read more about the registry and the lookup mechanism in the <a href="http://docs.oracle.com/javase/7/docs/api/javax/imageio/spi/IIORegistry.html">IIORegistry API doc</a>.</p>
<p>The fine print: The TwelveMonkeys service providers for JPEG, BMP and TIFF, overrides the onRegistration method, and
utilizes the pairwise partial ordering mechanism of the <code>IIOServiceRegistry</code> to make sure it is installed before
the Sun/Oracle provided <code>JPEGImageReader</code> and <code>BMPImageReader</code>, and the Apple provided <code>TIFFImageReader</code> on OS X,
respectively. Using the pairwise ordering will not remove any functionality form these implementations, but in most
cases you'll end up using the TwelveMonkeys plug-ins instead.</p>
<p>q: What about JAI? Several of the formats are already supported by JAI.</p>
<p>a: While JAI (and jai-imageio in particular) have support for some of the formats, JAI has some major issues.
The most obvious being:</p>
<ul>
<li>It's not actively developed. No issues has been fixed for years.</li>
<li>To get full format support, you need native libs.
Native libs does not exist for several popular platforms/architectures, and further the native libs are not open source.
Some environments may also prevent deployment of native libs, which brings us back to square one.</li>
</ul>
<p>q: What about JMagick or IM4Java? Can't you just use what´s already available?</p>
<p>a: While great libraries with a wide range of formats support, the ImageMagick-based libraries has some disadvantages
compared to ImageIO.</p>
<ul>
<li>No real stream support, these libraries only work with files.</li>
<li>No easy access to pixel data through standard Java2D/BufferedImage API.</li>
<li>Not a pure Java solution, requires system specific native libs.</li>
</ul>
<hr>
<p>We did it</p>