Skip to content

Latest commit

 

History

History
107 lines (80 loc) · 5.39 KB

README.en.md

File metadata and controls

107 lines (80 loc) · 5.39 KB

Imglib: lightweight Image processing library

maven-central jdk8+ license      switch

What is imglib?

Imglib is a lightweight image processing library for JAVA, which committed to simplifying frequently image processing.

What can imglib do?

Imglib mainly provides three capabilities:

  • Image Collection

    Imglib provides the ability to collect images, allowing developers to create images from nothing, such as creating transparent image, hash image, and capturing screenshot. At the same time, developers can extract images from files, such as extract whole page as image from PDF file or extract frame as image from GIF file.

  • Image Processing

    With Thumbnailator, we can easily implement the basic operations of images, including scaling, cropping, rotation, image watermarking and format conversion. On this basis, imglib extends processors such as adding border, lossless magnification, mosaics, rounded corner, graying, binarization, and drawing shapes on image.

  • Merging and Splitting

    Imglib provides merging and splitting capabilities, including merging multiple images into a single image and splitting image into multiple images. It supports cutting and jigsaw of images according to grid, and encode multiple images into GIF file. Developers can also expand freely according to actual needs.

How simple is imglib?

Like Thumbnailator, imglib shields developers from complex I/O operations and eliminates the need to manually manipulate images through Graphics2D objects. imglib has done all this for you. It's chained API allows you to configure and execute a complex image processing task step by step.

For example, the task of create a hash avatar for the user, the avatar setting to 8px*8px, the image size setting to 300px*300px, and add a border with a margin of 20px. This image generation task can be completed through the following code fragments:

ImagePipes.ofEmptySource()
        .register(new HashImageGenerator.Builder("Imglib")      // add a hash image generator
                .gridVerticalNum(8)                             // number of lattice in horizontal direction
                .bgColor(ColorUtils.of(240, 240, 240))          // the background color of hash image
                .fgColor(ColorUtils.of(50, 150, 50))            // the foreground color of hash image
                .build())   
        .toThumbnails()                                         // get object of Thumbnails
        .addFilter(new HighQualityExpandHandler.Builder()       // add a filter of lossless expansion handler
                .finalWidth(150)                                // the final width after expanded
                .keepAspectRatio(true)                          // setting of keep the aspect ratio
                .build())   
        .addFilter(new BorderHandler.Builder()                  // add a filter of border handler
                .fillColor(ColorUtils.of(240, 240, 240))        // fill color of the border
                .vMargins(15)                                   // vertical margin
                .hMargins(15)                                   // horizontal margin
                .alpha(1.0f)                                    // the transparency of the border
                .build())
        .scale(1.0)
        .toFile(".../avatar.png");

By executing the above code fragment, we will get the following user avatar.

avatar

How to use imglib?

Maven

Add the following maven dependencies in the pom.xml of your project.

  <dependency>
    <groupId>io.github.nackily</groupId>
    <artifactId>imglib-all</artifactId>
    <version>{*.*.*}</version>
  </dependency>

Jar

You can also visit maven-repository, download the corresponding version of imglib-all-*.*.*.jar and import it into your project.

Tips

It is worth mentioning that imglib is not a project started from nothing, it just stands on the shoulders of giants! imglib is based on Thumbnailator in image processing, relies on pdfbox in PDF document parsing, and references animated-gif-lib-for-java in GIF document processing. Although imglib relies on these excellent third-party dependencies in some image processing capabilities, imglib does not include relevant dependencies after packaging. If necessary, you should add corresponding dependencies to the project independently.Please refer to Dependencies for detailed lists.

See more

Get more information about imglib by visit the following links: