GitHub - jeffhain/jimsizr: Java Image reSizer

2 min read Original article ↗

Jimsizr stands for Java Image reSizer (JIS for short).

Jimsizr provides an API to convert between BufferedImage objects, doing both type conversion and resizing as needed, possibly in parallel. Ex.:

Jimsizr.resize(
    ScalingType.BOXSAMPLED, // downscaling type
    ScalingType.BICUBIC, // upscaling type
    srcImage,
    dstImage,
    parallelExecutor); // can be null

One of the main points of this library, other than allowing for speed-up with parallelism (which in case of drawImage() usage introduces small color components inaccuracies, due to how clipping is handled), is to also allow for better speed and/or accuracy through use of intermediary images, because for some image types AWT's drawImage() can be very inaccurate and/or very slow.

The available scaling algorithms are: NEAREST, BILINEAR, BICUBIC, BOXSAMPLED, ITERATIVE_BILINEAR, and ITERATIVE_BICUBIC. Except for BOXSAMPLED, they are already implemented by AWT, or can be simply for iterative ones, which allows for good performances (when ending up in optimized C code). Scaling algorithms are chosen independently for the downscaling and the upscaling part, which is useful in case of non-uniform scaling. Cf. ScalingType javadoc for more information.

This library also provides (and uses) the BufferedImageHelper class, which provides efficient read, write and copy operations, including for a few easily useful (e.g. for OpenGL) int-array based custom types.

The class JimsizrTestGuiMain launches a GUI for exploratory testing (speed and quality, depending on algorithms and spans resizing) with sample images.

License

Apache License V2.0

Current external dependencies

  • src/main:

    • Java 5+
  • src/test:

    • Java 7+ (for JComboBox generics)
    • JUnit 3.8.1
    • Jadecy 2.1.0 (for cycles tests)
  • src/build:

    • Java 6+
    • Jadecy 2.1.0

Miscellaneous

  • Jar is built with JisBuildMain.

  • The choices of brand of algorithms (AWT/JIS) and of intermediary images to use for copy were generated by BestCopyAlgoTuningMain.

  • The choices of brand of algorithms (AWT/JIS) and of intermediary images to use for resize were generated by BestResizeAlgoTuningMain.

  • The split thresholds for parallelization were chosen using ThresholdTuningMain.

Donation

paypal