sye8 / ImageUtils

Java class for image format conversion, compression and resizing. Includes a command line tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ImageUtils

License

Java class for image format conversion, compression and resizing. Includes a command line tool

Only requires JRE (Java SE 1.8) System Library, provides support for formats below

  • Supported read formats: [jpg, bmp, gif, png, wbmp, jpeg]

  • Supported write formats: [jpg, bmp, gif, png, wbmp, jpeg]

Note: Compress doesn't convert the image

Test Note: From tests so far, compression seems to support jpg only. Feedback welcomed

Extended Support

For extended image format support, try TwelveMonkeys ImageIO

With extended support, supported formats are:

  • Supported read formats: [psd, cur, tiff, bmp, gif, rgbe, tga, tif, wmf, ico, sgi, pgm, dcx, wbmp, jpeg, pam, pict, jpg, pct, pcx, svg, png, iff, ppm, pnm, thumbs db, icns, targa, pfm, hdr, pbm, thumbs]

  • Supported write formats: [tiff, bmp, gif, tif, pgm, wbmp, jpeg, pam, pict, jpg, pct, iff, png, ppm, pnm, pbm]

Raw Support

For camera raw image conversion to JPG, use dcraw.

So far only UNIX support is included in this java project. The current build uses dcraw v9.27

dcraw comes in C source code.

Compile with gcc -o dcraw -O4 dcraw.c -lm -ljasper -ljpeg -llcms2 or gcc -o dcraw -O4 dcraw.c -lm -DNODEPS.

Compiled unit for Windows is avaliable here

For macOS users, dcraw is also avaliable on Homebrew

  • Install brew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  • Install dcraw: brew install dcraw

Please make sure the complied file has at least execute permission, and is named "dcraw" or "dcraw.exe"

To give permission, execute in terminal with chmod 111 [compiled unit name].

If you are using this java source code, please place complied dcraw in the same directory as the complied class.

If you are using eclipse, please place complied dcraw under project directory.

If you are using the jar through terminal, please place complied dcraw in the working directory of your shell.

Main class command line tool (jar includes extended support) commands:

To run in Terminal/CMD, run with java -jar [jar file path]. Requires JVM to be installed

To see instructions, run with no arguments

  • -supportedTypes Show supported image types

  • -scale [inPath] [scale] [outPath] scale and convert and image

  • -resize [inPath] [width] [height] [maintain aspect ratio (true/false)] [outPath] resize and convert the image

    If user chooses to keep aspect ratio, then the image will be resized to best fill the space given, while keeping aspect ratio

  • -convert [inPath] [outPath] converts the image

  • -compress [inPath] [size in bytes] [outPath] compress image to maximum size under the required size in bytes

About

Java class for image format conversion, compression and resizing. Includes a command line tool

License:MIT License


Languages

Language:Java 100.0%