image

Cross platform image manipulation
https://github.com/benmerckx/image

To install, run:

haxelib install image 0.1.1 

See using Haxelib in Haxelib documentation for more information.

README.md

image

Cross platform image manipulation. Supports jpg, gif, png, bmp, tiff, webp.

Info

Image.getInfo(path)

Analyzes a given file. Some of the detection code comes from heaps. Returns a Surprise<ImageInfo, Error>.

Image.getInfo('file.jpg').handle(function (res) switch res {
	case Success(data):
    	// {format: ImageFormat.Jpg, width: 100, height: 100}
    case Failure(error):
    	trace(error.message);
});

Resizing and cropping

Supported tools

Install any of these commandline tools and pass the corresponding engine to the resize method. GD is only supported on php without the need for installing anything, as it uses built-in functions.

enum Engine {
	Vips;
	ImageMagick;
	GraphicsMagick;
	GD;
}

Image.resize(input, output, options)

Returns a Surprise<Noise, Error>.

Options being

{
	engine: Engine,
	width: Int,
	height: Int,
	?crop: Bool, // Defaults to true
	?focus: {x: Float, y: Float} // Defaults to {x: .5, y: .5}
}

Resize and crop a file from the center:

Image
.resize('file.jpg', 'thumb.jpg', {engine: Engine.Vips, width: 200, height: 200})
.handle(function (res) switch res {
	case Success(_):
    	trace('Image resized!');
    case Failure(error):
    	trace('Something went wrong: '+error.message);
});
Contributors
benmerckx
Version
0.1.1
Published
8 months ago
License
MIT

All libraries are free

Every month, more than thousand developers use haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on Github!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on Github