npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

imagemagick-native-2

v0.2.9

Published

ImageMagick's Magick++ bindings for NodeJS

Downloads

5

Readme

node-imagemagick-native

Imagemagick's Magick++ binding for Node.

Build Status

Example

var imagemagick = require('imagemagick-native')
,   srcData     = require('fs').readFileSync('./test/test.png');

// returns a Buffer instance
var resizedBuffer = imagemagick.convert({
    srcData: srcData, // provide a Buffer instance
    width: 100,
    height: 100,
    resizeStyle: "aspectfill",
    quality: 80,
    format: 'JPEG'
});

require('fs').writeFileSync('./test/out.png', resizedBuffer, 'binary');

API

convert( options )

Convert a buffer provided as options.srcData and return a Buffer.

The options argument can have following values:

{
    srcData:     required. Buffer with binary image data
    quality:     optional. 0-100 integer, default 75. JPEG/MIFF/PNG compression level.
    width:       optional. px.
    height:      optional. px.
    resizeStyle: optional. default: "aspectfill". can be "aspectfit", "fill"
                 aspectfill: keep aspect ratio, get the exact provided size,
                             crop top/bottom or left/right if necessary
                 aspectfit:  keep aspect ratio, get maximum image that fits inside provided size
                 fill:       forget aspect ratio, get the exact provided size
    format:      optional. one of http://www.imagemagick.org/script/formats.php ex: "JPEG"
    rotate:      optional. degrees.
    debug:       optional. 1 or 0
}

identify( options )

Identify a buffer provided as srcData and return an object.

The options argument can have following values:

{
    srcData:     required. Buffer with binary image data
    debug:       optional. 1 or 0
}

The method returns an object similar to:

{
    format: 'JPEG',
    width: 3904,
    height: 2622,
    depth: 8,
    exif: {
        orientation: 0 # 0 if none exists
    }
}

quantizeColors( options )

Quantize the image to a specified amount of colors from a buffer provided as srcData and return an array.

The options argument can have following values:

{
    srcData:     required. Buffer with binary image data
    colors:      required. number of colors to extract, defaults to 5
    debug:       optional. 1 or 0
}

The method returns an array similar to:

[
    {
        r: 83,
        g: 56,
        b: 35,
        hex: '533823'
    },
    {
        r: 149,
        g: 110,
        b: 73,
        hex: '956e49'
    },
    {
        r: 165,
        g: 141,
        b: 111,
        hex: 'a58d6f
    }
]

composite( options )

Composite a buffer provided as options.compositeData on a buffer provided as options.srcData with gravity specified by options.gravity and return a Buffer.

The options argument can have following values:

{
    srcData:       required. Buffer with binary image data
    compositeData: required. Buffer with binary image data
    gravity:       optional. Can be one of "CenterGravity" "EastGravity" "ForgetGravity" "NorthEastGravity" "NorthGravity" "NorthWestGravity" "SouthEastGravity" "SouthGravity" "SouthWestGravity" "WestGravity"
    debug:         optional. 1 or 0
}

This library currently provide only these, please try node-imagemagick if you want more.

Installation

Linux / Mac

Install Imagemagick with headers before installing this module. Tested with ImageMagick 6.7.7 on CentOS6 and MacOS10.7, Ubuntu12.04 .

MacOS10.9 Maverick users need ImageMagick linked to libstdc++ .
see issue#17

# bottle for mountain lion is linked to libstdc++
wget "http://downloads.sourceforge.net/project/machomebrew/Bottles/imagemagick-6.8.7-7.mountain_lion.bottle.tar.gz"
brew install imagemagick-6.8.7-7.mountain_lion.bottle.tar.gz

Otherwise:

brew install imagemagick

  or

sudo yum install ImageMagick-c++ ImageMagick-c++-devel

  or

sudo apt-get install libmagick++-dev

Make sure you can find Magick++-config in your PATH. Then:

npm install imagemagick-native

Windows

Tested on Windows 7 x64.

  1. Install Python 2.7.3 only 2.7.3 nothing else works quite right!

    If you use Cygwin ensure you don't have Python installed in Cygwin setup as there will be some confusion about what version to use.

  2. Install Visual Studio C++ 2010 Express

  3. (64-bit only) Install Windows 7 64-bit SDK

  4. Install Imagemagick dll binary x86 Q16 or Imagemagick dll binary x64 Q16, check for libraries and includes during install.

Then:

npm install imagemagick-native

Performance - simple thumbnail creation

imagemagick:       16.09ms per iteration
imagemagick-native: 0.89ms per iteration

See node test/benchmark.js for details.

License (MIT)

Copyright (c) Masakazu Ohtsuka http://maaash.jp/

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.