1.0.0 • Published 8 years ago

imageplus v1.0.0

Weekly downloads
2
License
GPL-3.0
Repository
github
Last release
8 years ago

ImagePlus

ImagePlus Logo

A node.js imagemagick API

Install

Mac OS X

  1. Install ImageMagick from Homebrew, MacPorts or Binary
  2. Run npm install imageplus

Linux

Debian / Ubuntu

  1. Install ImageMagick and Magick++ sudo apt-get install imagemagick libmagick++-dev
  2. Run npm install imageplus

Redhat / CentOS / Fedora

  1. Install ImageMagick and Magick++ sudo apt-get install ImageMagick ImageMagick-devel
  2. Run npm install imageplus

Windows

Windows version may not stable on this time

Usage

ImagePlus is a object oriented imagemagick API, you can easy to edit a image / SVG file.

First, you need to require the ImagePlus module on your script.

var imageplus = require("imageplus");
var Image = imageplus.Image;

and now, you can use the API

Examples

You can find all the examples on here

API

New image

new Image(int width, int height, double red, double green, double blue)

var img = new Image(128, 640, 1, 1, 1);

width and height is pixel unit

red, green, blue is between 0.0 to 1.0

Also, you can use html color

new Image(int width, int height, string htmlHexColor)

var img = new Image(128, 640, "#FF0000");

Load image to "Image" object

new Image(buffer imgBuffer)

var myImgBuffer = fs.readFileSync("./image.png");
var img = new Image(myImgBuffer);

ImagePlus is allow you to input the buffer object

Resize

Image.resize(int width, int height);

img.resize(100, 130);

Composite

Image.composite(Image otherImage, int x, int y);

var imgBackground = new Image(fs.readFileSync("./background.png"));
var imgOther = new Image(fs.readFileSync("./other.png"));
imgBackground.composite(imgOther, 100, 30);

Shadow

Image.shadow(double x, double y, double alpha, double offset);

img.shadow(0, 0, 70, 3);

Background color

Image.setBackgroundColor(double red, double green, double blue)

img.setBackgroundColor(0.7, 0.2, 0.5);

Image.setBackgroundColor(string htmlHexColor)

img.setBackgroundColor("#00AAFF");

Filter

Image.setFilterType(string filtertype);

Here is a filter list

  • Undefined
  • Point
  • Box
  • Triangle
  • Hermite
  • Hanning
  • Hamming
  • Blackman
  • Gaussian
  • Quadratic
  • Cubic
  • Catrom
  • Mitchell
  • Lanczos
  • Bessel
  • Sinc
img.setFilterType("Point");

fillImage

Image.fillImage(int area, double red, double green, double blue);

img.fillImage(80, 0, 0, 0);

setStrokeColor

Image.setStrokeColor(string hexColorOrColorName)

img.setStrokeColor("#00AAFF");
img.setStrokeColor("blue");

setStrokeWidth

Image.setStrokeWidth(double width) width is on pixel

img.setStrokeWidth(20.5);

setFillColor

Image.setFillColor(string hexColorOrColorName)

img.setFillColor("#00AAFF");
img.setFillColor("blue");

setFont

Image.setFont(string fontName) System font name or a font file path with prefix "@"

img.setFont("helvetica-bold");
img.setFont("@/var/fonts/myCoolFont.ttf");
img.setFont("@./myLocalCoolFont.ttf");

setFontSize

Image.setFontSize(int fontSize) Font size in pixel

img.setFontSize(20);

getFontMetrics

Image.getFontMetrics(string text) This function is useful if your text is dynamic

It will return a object contain { ascent, descent, textWidth, textHeight, maxHorizontalAdvance }

var fontMetrics = img.getFontMetrics(myDynamicUserInputText);
img.drawText(2, 10,myDynamicUserInputText);
img.drawText(2 + fontMetrics.textWidth + 2, 10, "after the user input text");

drawText

Image.drawText(int x, int y, string text)

img.drawText(30, 10, "This is a text!");

clone

Image.clone();

var otherImg = img.clone();

File type

Image.setType(string fileType);

img.setType("jpg");

Save to buffer

Image.toBufer();

var outputBuffer = img.toBuffer();

Save to file

Image.toFile(string save_to_file_path);

img.toFile("output_file.bmp");

Develop

Develop by: Onikur

License

GNU GPL v3

1.0.0

8 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago