Giter VIP home page Giter VIP logo

node-imagemagick-native's Introduction

node-imagemagick-native

ImageMagick's Magick++ binding for Node.

Features

  • Native bindings to the C/C++ Magick++ library
  • Async, sync, stream and promises API
  • Support for convert, identify, composite, and other utility functions

Build Status

Table of contents

Examples

Convert formats

Convert from one format to another with quality control:

fs.writeFileSync('after.png', imagemagick.convert({
	srcData: fs.readFileSync('before.jpg'),
	format: 'PNG',
	quality: 100 // (best) to 1 (worst)
}));

Original JPEG:

alt text

Converted to PNG:

quality 100 quality 50 quality 1
alt text alt text alt text

Image courtesy of David Yu.

Blur

Blur image:

fs.writeFileSync('after.jpg', imagemagick.convert({
	srcData: fs.readFileSync('before.jpg'),
	blur: 5
}));

alt text becomes alt text

Image courtesy of Tambako The Jaguar.

Resize

Resized images by specifying width and height. There are three resizing styles:

  • aspectfill: Default. The resulting image will be exactly the specified size, and may be cropped.
  • aspectfit: Scales the image so that it will not have to be cropped.
  • fill: Squishes or stretches the image so that it fills exactly the specified size.
fs.writeFileSync('after_resize.jpg', imagemagick.convert({
	srcData: fs.readFileSync('before_resize.jpg'),
	width: 100,
	height: 100,
	resizeStyle: 'aspectfill', // is the default, or 'aspectfit' or 'fill'
	gravity: 'Center' // optional: position crop area when using 'aspectfill'
}));

Original:

alt text

Resized:

aspectfill aspectfit fill
alt text alt text alt text

Image courtesy of Christoph.

Rotate, flip, and mirror

Rotate and flip images, and combine the two to mirror:

fs.writeFileSync('after_rotateflip.jpg', imagemagick.convert({
	srcData: fs.readFileSync('before_rotateflip.jpg'),
	rotate: 180,
	flip: true
}));

Original:

alt text

Modified:

rotate 90 degrees rotate 180 degrees flip flip + rotate 180 degrees = mirror
alt text alt text alt text alt text

Image courtesy of Bill Gracey.

API Reference

convert(options, [callback])

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
    srcFormat:      optional. force source format if not detected (e.g. 'ICO'), one of http://www.imagemagick.org/script/formats.php
    quality:        optional. 1-100 integer, default 75. JPEG/MIFF/PNG compression level.
    trim:           optional. default: false. trims edges that are the background color.
    trimFuzz:       optional. [0-1) float, default 0. trimmed color distance to edge color, 0 is exact.
    width:          optional. px.
    height:         optional. px.
    density         optional. Integer dpi value to convert
    resizeStyle:    optional. default: 'aspectfill'. can be 'aspectfit', 'fill'
                    aspectfill: keep aspect ratio, get the exact provided size.
                    aspectfit:  keep aspect ratio, get maximum image that fits inside provided size
                    fill:       forget aspect ratio, get the exact provided size
                    crop:       no resize, get provided size with [x|y]offset
    xoffset:        optional. default 0: when use crop resizeStyle x margin
    yoffset:        optional. default 0: when use crop resizeStyle y margin
    gravity:        optional. default: 'Center'. used to position the crop area when resizeStyle is 'aspectfill'
                              can be 'NorthWest', 'North', 'NorthEast', 'West',
                              'Center', 'East', 'SouthWest', 'South', 'SouthEast', 'None'
    format:         optional. output format, ex: 'JPEG'. see below for candidates
    filter:         optional. resize filter. ex: 'Lagrange', 'Lanczos'.  see below for candidates
    blur:           optional. ex: 0.8
    strip:          optional. default: false. strips comments out from image.
    rotate:         optional. degrees.
    flip:           optional. vertical flip, true or false.
    autoOrient:     optional. default: false. Auto rotate and flip using orientation info.
    colorspace:     optional. String: Out file use that colorspace ['CMYK', 'sRGB', ...]
    debug:          optional. true or false
    ignoreWarnings: optional. true or false
}

Notes

  • format values can be found here
  • filter values can be found here

An optional callback argument can be provided, in which case convert will run asynchronously. When it is done, callback will be called with the error and the result buffer:

imagemagick.convert({
    // options
}, function (err, buffer) {
    // check err, use buffer
});

There is also a stream version:

fs.createReadStream('input.png').pipe(imagemagick.streams.convert({
    // options
})).pipe(fs.createWriteStream('output.png'));

identify(options, [callback])

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. true or false
    ignoreWarnings: optional. true or false
}

An optional callback argument can be provided, in which case identify will run asynchronously. When it is done, callback will be called with the error and the result object:

imagemagick.identify({
    // options
}, function (err, result) {
    // check err, use result
});

The method returns an object similar to:

{
    format: 'JPEG',
    width: 3904,
    height: 2622,
    depth: 8,
    colorspace: 'sRGB',
    density : {
        width : 300,
        height : 300
    },
    exif: {
        orientation: 0 // if none exists or e.g. 3 (portrait iPad pictures)
    }
}

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. true or false
    ignoreWarnings: optional. true or false
}

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, [callback])

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. true or false
    ignoreWarnings: optional. true or false
}

An optional callback argument can be provided, in which case composite will run asynchronously. When it is done, callback will be called with the error and the result buffer:

imagemagick.composite(options, function (err, buffer) {
    // check err, use buffer
});

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

getConstPixels(options)

Get pixels of provided rectangular region.

The options argument can have following values:

{
    srcData:        required. Buffer with binary image data
    x:              required. x,y,columns,rows provide the area of interest.
    y:              required.
    columns:        required.
    rows:           required.
}

Example usage:

// retrieve first pixel of image
var pixels = imagemagick.getConstPixels({
    srcData: imageBuffer, // white image
    x: 0,
    y: 0,
    columns: 1,
    rows: 1
});

Returns:

[ { red: 65535, green: 65535, blue: 65535, opacity: 65535 } ]

Where each color value's size is imagemagick.quantumDepth bits.

quantumDepth

Return ImageMagick's QuantumDepth, which is defined in compile time.
ex: 16

version

Return ImageMagick's version as string.
ex: '6.7.7'

Promises

The namespace promises expose functions convert, composite and identify that returns a Promise.

Examples:

// convert
imagemagick.promises.convert({ /* OPTIONS */ })
  .then(function(buff) { /* Write buffer */ })
  .catch(function(err) { /* log err */ })

// ES8
const buff = await imagemagick.promises.convert({ /* OPTIONS */ })

// composite
imagemagick.promises.composite({ /* OPTIONS */ })
  .then(function(buff) { /* Write buffer */ })
  .catch(function(err) { /* log err */ })

// ES8
const buff = await imagemagick.promises.composite({ /* OPTIONS */ })

// identify
imagemagick.promises.identify({ /* OPTIONS */ })
  .then(function(info) { /* Write buffer */ })
  .catch(function(err) { /* log err */ })

// ES8
const info = await imagemagick.promises.identify({ /* OPTIONS */ })

Installation

Linux / Mac OS X

Install ImageMagick with headers before installing this module. Tested with ImageMagick 6.7.7 on CentOS 6 and Mac OS X Lion, Ubuntu 12.04 .

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. Packages on some newer distributions, such as Ubuntu 16.04, might be missing a link into /usr/bin. If that is the case, do this.

sudo ln -s `ls /usr/lib/\`uname -p\`-linux-gnu/ImageMagick-*/bin-Q16/Magick++-config | head -n 1` /usr/local/bin/

Then:

npm install imagemagick-native

Installation notes

  • RHEL/CentOS: If the version of ImageMagick required by node-imagemagick-native is not available in an official RPM repository, please try the -last version offered by Les RPM de Remi, for example:
sudo yum remove -y ImageMagick
sudo yum install -y http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo yum install -y --enablerepo=remi ImageMagick-last-c++-devel
  • Mac OS X: You might need to install pkgconfig first:
brew install pkgconfig

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.

Note: node-imagemagick-native's primary advantage is that it uses ImageMagick's API directly rather than by executing one of its command line tools. This means that it will be much faster when the amount of time spent inside the library is small and less so otherwise. See issue #46 for discussion.

Contributing

This project follows the "OPEN Open Source" philosophy. If you submit a pull request and it gets merged you will most likely be given commit access to this repository.

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.

node-imagemagick-native's People

Contributors

abetomo avatar cartuchogl avatar dcharbonnier avatar dmzkrsk avatar duralog avatar dustingraves avatar eirslett avatar elad avatar fivethreeo avatar frank-trampe avatar geta6 avatar heavyk avatar hnryjms avatar horiuchi avatar inkhsutesou avatar jvaldron avatar kabojnk avatar ken39arg avatar mash avatar ms76 avatar mvdnes avatar pentode avatar pmelisko avatar rchipka avatar royaltm avatar sapics avatar tfzxyinhao avatar timwolla avatar udipl avatar wouterb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-imagemagick-native's Issues

Use NAN für 0.11-support.

Ho,

we'd like to switch to imagemagick-native in production but since we're deploying 0.11.12 it's simply not compiling. Anyone against using NAN?

Cheers

Calling identify kills node app silently

The below code causes an issue where the node app dies silently when the block that calls identify is run. Commenting out only that block of code will allow the app to deliver the image, and continue listening for more requests.

I'm running node v0.10.12, and below is the convert -version output:
Version: ImageMagick 6.8.7-7 Q16 x86_64 2014-01-09 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib freetype jng jpeg ltdl png xml zlib

I have also attached the image that I'm using to test.

Please let me know if I can provide any additional information to help.

Aaron

// Test code:
// ------------------------------------------------------------------------------------

var imagemagick = require('imagemagick-native');
var http = require('http');
var url = require('url');
var file_system = require('fs');

var server = http.createServer(function (request, response) {

    var raw_image_path = './wimages/cat.jpg'

    var raw_image = file_system.readFileSync(raw_image_path);

    var raw_image_info = imagemagick.identify({
        srcData:raw_image
    });

    response.writeHead(200, {'Content-Type': 'image/jpeg'});
    response.end(raw_image);
});

server.listen(8080);

cat

imagemagick-native crashes with SIGABRT

When passing an invalid format to Convert imagemagick-native crashes with a SIGABRT:

terminate called after throwing an instance of 'Magick::ErrorMissingDelegate'
what(): Magick: no decode delegate for this image format `' @ error/blob.c/ImageToBlob/1520

Provided benchmark correct only for small files

I have ran your benchmark with medium/large size images and got completely different result.
According to my measurements, imagemagick-native was 1.5/3 times slower than imagemagick.

I have tested it with this photo.

I downloaded the "Standard 4:3" and "HD 16:9" sizes of the same photo.

Here are my results:

  1. Provided test.jpg, 6.9 kB, 58x66
    imagemagick: 15.23ms per iteration
    imagemagick-native: 1.45ms per iteration
    Winner: imagemagick-native is 1050% faster
  2. Above wallpaper, standard, 139.3 kB, 800x600
    imagemagick: 33.06ms per iteration
    imagemagick-native: 47.16ms per iteration
    Winner: imagemagick is 142% faster
  3. Above wallpaper, standard, 1.0 MB, 2800x2100
    imagemagick: 248ms per iteration
    imagemagick-native: 556.9ms per iteration
    Winner: imagemagick is 224% faster
  4. Above wallpaper, HD,153.9 kB, 960x540
    imagemagick: 37.4ms per iteration
    imagemagick-native: 48.59ms per iteration
    Winner: imagemagick is 129% faster
  5. Above wallpaper, HD, 965.4 kB, 2880x1620
    imagemagick: 178.96ms per iteration
    imagemagick-native: 440.14ms per iteration
    Winner: imagemagick is 254% faster

As far as I can tell, using imagmagick-native makes sense, only with small files.
What is your input on this?

With thanks,
Laszlo

transparency of pngs is removed

i'm doing two convert calls on images, first to pad the images to an even number of pixes then to reduce the image size by half (processing retina images for non-retina browsers), but my final images have white backgrounds instead of transparency.

has anyone else encountered this?

OSX

Hello,
sicne the brew install failed under osx I tried the following:

http://cactuslab.com/imagemagick/

but when I run sudo npm install imagemagick-native i get:

npm WARN package.json SWIG-KISS@0.0.1 No repository field.
npm WARN package.json SWIG-KISS@0.0.1 No readme data.
npm WARN package.json consolidate@0.9.1 No repository field.
npm http GET https://registry.npmjs.org/imagemagick-native
npm http 200 https://registry.npmjs.org/imagemagick-native
npm http GET https://registry.npmjs.org/imagemagick-native/-/imagemagick-native-0.2.3.tgz
npm http 200 https://registry.npmjs.org/imagemagick-native/-/imagemagick-native-0.2.3.tgz

> imagemagick-native@0.2.3 install /Users/daslicht/node/swig/node_modules/imagemagick-native
> node-gyp rebuild

/bin/sh: Magick++-config: command not found
gyp: Call to 'Magick++-config --ldflags --libs' returned exit status 127. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:415:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 12.4.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/daslicht/node/swig/node_modules/imagemagick-native
gyp ERR! node -v v0.10.12
gyp ERR! node-gyp -v v0.10.0
gyp ERR! not ok 
npm ERR! weird error 1
npm ERR! not ok code 0

Any idea whats going on there?

background none in svg2png covert

When I converting svg with transparent background to png, I get png with white background color instead of transparent.

If I run "convert -background none file.svg file.png" from command line then everything works fine.

How can I add "-background none" parameter in convert API?

FreeBSD support in binding.gyp

Hello,
I was trying to install on FreeBSD but FreeBSD is not in de binding.gyp. If you change the line
['OS=="linux" or OS=="solaris"', { # not windows not mac

to

['OS=="linux" or OS=="solaris" or OS=="freebsd"', { # not windows not mac

it will work fine.
Thank you,

Arno de Vries

Unable to install on Ubuntu 12.04.3 LTS and node v.0.11.9-pre

ubuntu@mongodb:~/node/customcode/TestNodeExpressProject$ sudo npm install -g imagemagick-native
npm http GET http://registry.npmjs.org/imagemagick-native
npm http 304 http://registry.npmjs.org/imagemagick-native

[email protected] install /usr/local/lib/node_modules/imagemagick-native
node-gyp rebuild

gyp ERR! configure error
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
gyp ERR! stack at install (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:65:16)
gyp ERR! stack at Object.self.commands.(anonymous function) as install
gyp ERR! stack at getNodeDir (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:271:20)
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:112:9
gyp ERR! stack at ChildProcess.exithandler (child_process.js:659:7)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:101:17)
gyp ERR! stack at maybeClose (child_process.js:773:16)
gyp ERR! stack at Socket. (child_process.js:986:11)
gyp ERR! stack at Socket.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Pipe.close (net.js:459:12)
gyp ERR! System Linux 3.8.0-33-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/imagemagick-native
gyp ERR! node -v v0.11.9-pre
gyp ERR! node-gyp -v v0.11.0
gyp ERR! not ok
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the imagemagick-native package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls imagemagick-native
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.8.0-33-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "imagemagick-native"
npm ERR! cwd /home/ubuntu/node/customcode/TestNodeExpressProject
npm ERR! node -v v0.11.9-pre
npm ERR! npm -v 1.3.13
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/ubuntu/node/customcode/TestNodeExpressProject/npm-debug.log
npm ERR! not ok code 0
ubuntu@mongodb:~/node/customcode/TestNodeExpressProject$

Ha error in linux

> [email protected] install /home/pol/Work/node_modules/imagemagick-native
> node-gyp rebuild

/bin/sh: 1: Magick++-config: not found
gyp: Call to 'Magick++-config --ldflags --libs' returned exit status 127. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:344:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.16.0-30-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/pol/Work/node_modules/imagemagick-native
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1

Fails with .TIF images

I'm unsure if this is a problem with node-imagemagick-native, the system libs or if i'm just doing something wrong. However whenever I try to convert a .tif image, the process fails.

You can see more in this gist, which includes the image that I'm currently using, the node script and the vagrant setup that provides the ubuntu environment where i'm running this.

Sorry for the lack of info/description on this issue, but I'm just starting with image manipulation, so I'm unsure on where to start to be more helpful.

Density argument didn't work as expected.

Density doesn't work for me for converting from svg to png.

code

var IM = require('imagemagick-native'),
    fs = require('fs');

fs.writeFileSync('help.png', IM.convert({
    srcData: fs.readFileSync('help.svg'),
    srcFormat: 'SVG',
    format: 'PNG',
    width: 2000,
    height: 2000,
    density: 1000,
}));

original svg file http://take.ms/Sxra2 (github doesn't support svg in comments yet).

and result
help

while converting by imagemagick
convert -resize 2000x2000 -density 1000 help.svg help2.png
produces:
help2

Strip comments/profiles when converting

When switching from node-imagemagick to node-imagemagick-native I noticed that the resized (and probably all converted) images with the native module are significantly larger than before.

A quick look at the code showed that node-imagemagick calls convert with -strip which removes all comments/profiles from the image. To illustrate:

$ du -h input.jpg
792K    input.jpg
$ convert input.jpg -resize 300x200 -quality 80 output-unstripped.jpg
$ convert input.jpg -resize 300x200 -quality 80 -strip output-stripped.jpg
$ du -h output-{un,}stripped.jpg
64K output-unstripped.jpg
24K output-stripped.jpg
$ 

The way I achieved the same is with a simple image.strip() call (per the documentation) around line 242 of src/imagemagick.cc (after rotation, before writing the blob).

At the very least, please add an option for it.

Thanks! :)

npm install fails on node-gyp rebuild

I am having trouble getting this module installed. I am using Fedora 20.

As for ImageMagick, here is what I have installed:

Package ImageMagick-6.8.6.3-4.fc20.x86_64 already installed and latest version
Package ImageMagick-devel-6.8.6.3-4.fc20.x86_64 already installed and latest version

I also have the Fedora dev tools group installed.

Here is the output when I try to install:

[portaj@portaj-air coffeeshop]$ npm install imagemagick-native
npm WARN package.json [email protected] No repository field.
npm http GET https://registry.npmjs.org/imagemagick-native
npm http 304 https://registry.npmjs.org/imagemagick-native

> [email protected] install /home/portaj/devel/portaj/coffeeshop/node_modules/imagemagick-native
> node-gyp rebuild

Traceback (most recent call last):
  File "/home/portaj/bin/nodejs/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module>
    sys.exit(gyp.script_main())
AttributeError: 'module' object has no attribute 'script_main'
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/portaj/bin/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:340:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:807:12)
gyp ERR! System Linux 3.14.2-200.fc20.x86_64
gyp ERR! command "node" "/home/portaj/bin/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/portaj/devel/portaj/coffeeshop/node_modules/imagemagick-native
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok 
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the imagemagick-native package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls imagemagick-native
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.14.2-200.fc20.x86_64
npm ERR! command "/home/portaj/bin/nodejs/bin/node" "/home/portaj/bin/nodejs/bin/npm" "install" "imagemagick-native"
npm ERR! cwd /home/portaj/devel/portaj/coffeeshop
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/portaj/devel/portaj/coffeeshop/npm-debug.log
npm ERR! not ok code 0

convert error

Hi i had strange error when trying to convert images form buffer.
Here is code :

request = Meteor.require("request");
        request({
            url: url,
            method: "GET",
            encoding: null,
            jar: false
            },  Meteor.bindEnvironment(function(error, res, body) {
                    if (!error) {
                        var resizedBuffer = magick.convert({
                            srcData: body, 
                        });
                        console.log(resizedBuffer);
                        var data =
                            Images.storeBuffer('photo.jpg', resizedBuffer, {
                                contentType: res.headers['content-type'],
                                owner: Meteor.userId(),
                                metadata: {
                                    status:   "BUY",
                                    products: products
                                },
                                encoding : 'binary',
                            });

                    }
                }, function(err,) {
                   console.log("an error" + err + "occured");
                }));
    }

i have error : [Error: end cannot be longer than parent.length]
im using node v 10.24 imagemagick-native v 0.2.9
Can anybody help me ?
thx in advance.

OSX requirement

OSX need to install pkg-config manually

please add to README :)

brew install pkgconfig

install on unix has some problem

i don't know what's the version of imagemagick when you install on your system.
now the compiler give me some error show that imagemagick library may change some function in new release version,something like add some function and remove some function,so node-imagemagick-native must install fail.
so do you have some solution to fix this problem ?

temporary at least, https://github.com/mash/node-imagemagick-native/blob/master/src/imagemagick.cc#L199 has error "error: no matching function for call to imagemagick::Image::extent(Magick::Geometry&, Magick::Color&)
/usr/include/ImageMagick/Magick++/Image.h:296: note: candidates are: void Magick::Image::extent(const Magick::Geometry&)"

Asynchronous conversion

It would be great if the conversion process could be made asynchronous so that it doesn't slow down the responsiveness when used in a web server.

It would be pretty straightforward to do this using uv_queue_work

Throws error even in the included tests

i'm getting the following error both on windows and linux :

This is the error i'm getting on linux

imagemagick-native$ node test

module.js:340
    throw err;
          ^
Error: Cannot find module 'imagemagick-native/test'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

And this on windows :

module.js:355
  Module._extensions[extension](this, filename);
                               ^
Error: The specified module could not be found.
M:\Work\myMailIs\servers\mml-manipulator\node_modules\imagemagick-native\build\Release\imagemagick.node
    at Error (native)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (M:\Work\myMailIs\servers\mml-manipulator\node_modules\imagemagick-native\index.js:1:80)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)

Any ideas?

Streams2 interface

I'd like to see a streams2 API for functions like convert. While the greatest advantage the lowered memory usage probably will not be usable here it will allow for more clean code:

fs.createReadStream('myimage.png').pipe(imagemagick.convert({
    width: 100,
    height: 100 
})).pipe(fs.createWriteStream('myimage-scaled.png'));

vs.

fs.readFile('myimage.png', function (err, data) {
    imagemagick.convert({
        width: 100, 
        height: 100,
        srcData: data 
    }, function (err, data) {
        fs.writeFile('myimage-scaled.png', data);
    });
});

SmartOS Installation

Any tips for running on SmartOS (Joyent)? Right now, I am getting this error:

Error: ld.so.1: node: fatal: libMagick++.so.4: open failed: No such file or directory
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/node/cloudcash-server/app/node_modules/imagemagick-native/index.js:1:80)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

I have ImageMagick-6.8.6.9 installed.

Can't install

[email protected] install /Users/zhubofei/imgmg/node_modules/imagemagick-native
node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
/usr/local/bin/Magick++-config: line 53: pkg-config: command not found
/usr/local/bin/Magick++-config: line 56: pkg-config: command not found
gyp: Call to 'Magick++-config --ldflags --libs' returned exit status 0. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:343:16)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Darwin 14.1.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/zhubofei/imgmg/node_modules/imagemagick-native
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
npm ERR! Darwin 14.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "imagemagick-native"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the imagemagick-native package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls imagemagick-native
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/zhubofei/imgmg/npm-debug.log

Segmentation fault: 11

Hi,

Thanks for writing a great module. I am currently doing some experimenting and am running into issues when using the identify() method. Interestingly, convert() and quantizeColors() both work and the identify command works in the terminal, but not with your module. I am running Mac OSX 10.9.1 and installed imagemagick 6.8.7-7 through Homebrew. Here is the setup.

I download the node logo:

curl -O http://nodejs.org/images/logo-light.png

I run identify in the terminal and it works as expected:

identify identify logo-light.png
# logo-light.png PNG 245x66 245x66+0+0 8-bit sRGB 33c 1.45KB 0.000u 0:00.000

If start the node REPL and try to run identify() using the module:

imagemagick = require('imagemagick-native');
srcData = require('fs').readFileSync('./logo-light.png');
imagemagick.identify({srcData:srcData});
// Segmentation fault: 11

I can recreate the issue with any image format, not just PNGs.

Do you have any idea why this may be happening or how to correct this behavior?

Thanks for you time,
Lucas

imagemagick-native doesn't compile on io.js

I am able to make imagemagick-native work with Node.js.
but impossible to make it compile for io.js: I've tried both iojs-v1.2.0 and iojs-v1.6.4

I'm on OS X (10.10.2)
Version: ImageMagick 6.8.9-8 Q16 x86_64 2014-10-23 http://www.imagemagick.org

$ cd /tmp; npm install imagemagick-native
\
> [email protected] install /private/tmp/node_modules/imagemagick-native
> node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
  CXX(target) Release/obj.target/imagemagick/src/imagemagick.o
In file included from ../src/imagemagick.cc:9:
In file included from ../src/imagemagick.h:4:
../node_modules/nan/nan.h:616:19: error: no type named 'ExternalAsciiStringResource' in 'v8::String'; did you mean 'ExternalStringResource'?
      v8::String::ExternalAsciiStringResource *resource) {
      ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
                  ExternalStringResource
/Users/gre/.node-gyp/1.2.0/deps/v8/include/v8.h:2016:19: note: 'ExternalStringResource' declared here
  class V8_EXPORT ExternalStringResource
                  ^
In file included from ../src/imagemagick.cc:9:
In file included from ../src/imagemagick.h:4:
../node_modules/nan/nan.h:615:36: error: redefinition of 'NanNew'
  NAN_INLINE v8::Local<v8::String> NanNew(
                                   ^
../node_modules/nan/nan.h:610:36: note: previous definition is here
  NAN_INLINE v8::Local<v8::String> NanNew(
                                   ^
../node_modules/nan/nan.h:1973:12: error: no member named 'IsExternalAscii' in 'v8::String'; did you mean 'IsExternal'?
  if (str->IsExternalAscii()) {
           ^~~~~~~~~~~~~~~
           IsExternal
/Users/gre/.node-gyp/1.2.0/deps/v8/include/v8.h:1980:8: note: 'IsExternal' declared here
  bool IsExternal() const;
       ^
In file included from ../src/imagemagick.cc:9:
In file included from ../src/imagemagick.h:4:
../node_modules/nan/nan.h:1974:23: error: no type named 'ExternalAsciiStringResource' in 'v8::String'; did you mean 'ExternalStringResource'?
    const v8::String::ExternalAsciiStringResource* ext;
          ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
                      ExternalStringResource
/Users/gre/.node-gyp/1.2.0/deps/v8/include/v8.h:2016:19: note: 'ExternalStringResource' declared here
  class V8_EXPORT ExternalStringResource
                  ^
In file included from ../src/imagemagick.cc:9:
In file included from ../src/imagemagick.h:4:
../node_modules/nan/nan.h:1975:16: error: no member named 'GetExternalAsciiStringResource' in 'v8::String'; did you mean 'GetExternalOneByteStringResource'?
    ext = str->GetExternalAsciiStringResource();
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               GetExternalOneByteStringResource
/Users/gre/.node-gyp/1.2.0/deps/v8/include/v8.h:2083:40: note: 'GetExternalOneByteStringResource' declared here
  const ExternalOneByteStringResource* GetExternalOneByteStringResource() const;
                                       ^
In file included from ../src/imagemagick.cc:9:
In file included from ../src/imagemagick.h:4:
../node_modules/nan/nan.h:1975:9: error: assigning to 'const v8::String::ExternalStringResource *' from incompatible type
      'const v8::String::ExternalOneByteStringResource *'
    ext = str->GetExternalAsciiStringResource();
        ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:1976:11: error: assigning to 'const char *' from incompatible type 'const uint16_t *' (aka 'const unsigned short *')
    *data = ext->data();
          ^ ~~~~~~~~~~~
7 errors generated.
make: *** [Release/obj.target/imagemagick/src/imagemagick.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/gre/.nvm/versions/io.js/v1.2.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at emitTwo (events.js:85:13)
gyp ERR! stack     at ChildProcess.emit (events.js:153:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1044:12)
gyp ERR! System Darwin 14.1.0
gyp ERR! command "node" "/Users/gre/.nvm/versions/io.js/v1.2.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /private/tmp/node_modules/imagemagick-native
gyp ERR! node -v v1.2.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
npm ERR! Darwin 14.1.0
npm ERR! argv "/Users/gre/.nvm/versions/io.js/v1.2.0/bin/iojs" "/Users/gre/.nvm/versions/io.js/v1.2.0/bin/npm" "install" "imagemagick-native"
npm ERR! node v1.2.0
npm ERR! npm  v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the imagemagick-native package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls imagemagick-native
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /private/tmp/npm-debug.log

1.3.0 + Centos 6 = compilation error with "standard" version of ImageMagick-c++-devel

RHEL/Centos 6 provides version 6.5.4.7 of ImageMagick-c++-devel as the most recent version in its Updates repo.

imagemagick-native v1.2.2 compiles against 6.5.4.7, but it looks like v1.3.0 takes advantage of some more recent API additions and fails to compile.

CXX(target) Release/obj.target/imagemagick/src/imagemagick.o
../src/imagemagick.cc: In function ‘v8::Handle<v8::Value> Convert(const v8::Arguments&)’:
../src/imagemagick.cc:131: error: ‘class Magick::Image’ has no member named ‘strip’
../src/imagemagick.cc:156: error: ‘ParseCommandOption’ is not a member of ‘MagickCore’

Les RPM de Remi Repo provides ImageMagick 6.8.9.7 as the slightly renamed ImageMagick-last-c++-devel (note the -last- in there).

Removing ImageMagick and installing the -last- alternative via:

sudo yum remove -y ImageMagick
sudo yum install -y http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo yum install -y --enablerepo=remi ImageMagick-last-c++-devel

...then allows this module to compile (with unrelated warnings).

"Symbol not found" issue for OSX 10.9

Node is reporting the following error when using imagemagick-native:

dyld: lazy symbol binding failed: Symbol not found: __ZN6Magick5Image6magickERKSs
  Referenced from: /dev/node_modules/imagemagick-native/build/Release/imagemagick.node
  Expected in: dynamic lookup

dyld: Symbol not found: __ZN6Magick5Image6magickERKSs
  Referenced from: /dev/node_modules/imagemagick-native/build/Release/imagemagick.node
  Expected in: dynamic lookup

Trace/BPT trap: 5

environment:
Node: v0.10.22 - installed from nodejs.org package
OSX: 10.9
ImageMagick: stable 6.8.7-0 installed from homebrew
Xcode: 5.02

Thank you in advance :)

Build fails on solaris

Solaris is missing in the OS built target conditions. This results in a incomplete build on solaris systems like smartOS.

Library license

Can you list what license you are using for this project? Can it be used in commercial projects?

Edit: Just noticed it's MIT in the readme, but can you put it in the package.json so it's more clear?

Flip support

I need to flip images.

Code:

int flip = obj->Get( String::NewSymbol("flip") )->Uint32Value();
if ( flip ) {
    if (debug) printf( "flip\n" );
    image.flip();
}

Usage:

var flipped_data = imagemagick.convert({
    srcData: orig_data,
    flip: true
});

Maintener Wanted

Actually, honestly, I'm not using this in my own project anymore. Nothing bad about node or this module, I just quit my job last year and not manipulating images right now.

I can merge pull requests and increment version semantically in my spare time, if the pull request looks good, but if you're using this module in real work or somehow rely on this, please raise your hand!

Not building on x86 Windows

Running on Win 7 x64 (32-bit node), I get:

c:\program files (x86)\imagemagick-6.8.5-q16\include\magick/magick-baseconfig.h(182): error C2371: 'ssize_t' : redefinition; different basic types

D:\Users\Josh\Documents\js\node-imagemagick-native>node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | ia32
gyp info spawn python
gyp info spawn args [ 'D:\\Users\\Josh\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=auto',
gyp info spawn args   '-I',
gyp info spawn args   'D:\\Users\\Josh\\Documents\\js\\node-imagemagick-native\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'D:\\Users\\Josh\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'D:\\Users\\Josh\\.node-gyp\\0.10.13\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=D:\\Users\\Josh\\.node-gyp\\0.10.13',
gyp info spawn args   '-Dmodule_root_dir=D:\\Users\\Josh\\Documents\\js\\node-imagemagick-native',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--generator-output',
gyp info spawn args   'D:\\Users\\Josh\\Documents\\js\\node-imagemagick-native\\build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=Win32' ]
  imagemagick.cc
c:\program files (x86)\imagemagick-6.8.5-q16\include\magick/magick-baseconfig.h(182): error C2371: 'ssize_t' : redefinition; different basic types [D:\Users\Josh\Docum ents\js\node-imagemagick-native\build\imagemagick.vcxproj]
          d:\users\josh\.node-gyp\0.10.13\deps\uv\include\uv-private/uv-win.h(27) : see declaration of 'ssize_t'
c:\program files (x86)\imagemagick-6.8.5-q16\include\magick/pixel-accessor.h(163): warning C4244: 'argument' : conversion from 'double' to 'const MagickCore::MagickRea lType', possible loss of data [D:\Users\Josh\Documents\js\node-imagemagick-native\build\imagemagick.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xlocale(323): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify / EHsc [D:\Users\Josh\Documents\js\node-imagemagick-native\build\imagemagick.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (D:\Users\Josh\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:232:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "D:\\Users\\Josh\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\Users\Josh\Documents\js\node-imagemagick-native
gyp ERR! node -v v0.10.13
gyp ERR! node-gyp -v v0.8.1
gyp ERR! not ok

Not working on Node v0.11.16

This module works fine on node v0.10.* but if I try to use it with v0.11.16, I get the following error when I run the application. & yes, I did reinstall all node modules after switching to v0.11.16

module.js:519
    paths.unshift(path.resolve(homeDir, '.node_modules'));
Error: Module did not self-register.
    at Error (native)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/var/www/apps/node_modules/imagemagick-native/index.js:1:80)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)

Installed with npm, no getConstPixels method

It seems like the npm install of this library is missing some method exports in the init method. After using npm install imagemagick-native, the init method in imagemagick.cc looks like this:

void init(Handle<Object> exports) {
#if NODE_MODULE_VERSION >= 14
    NODE_SET_METHOD(exports, "convert", Convert);
    NODE_SET_METHOD(exports, "identify", Identify);
    NODE_SET_METHOD(exports, "quantizeColors", QuantizeColors);
    NODE_SET_METHOD(exports, "composite", Composite);
    NODE_SET_METHOD(exports, "version", Version);
#else
    exports->Set(NanNew<String>("convert"), FunctionTemplate::New(Convert)->GetFunction());
    exports->Set(NanNew<String>("identify"), FunctionTemplate::New(Identify)->GetFunction());
    exports->Set(NanNew<String>("quantizeColors"), FunctionTemplate::New(QuantizeColors)->GetFunction());
    exports->Set(NanNew<String>("composite"), FunctionTemplate::New(Composite)->GetFunction());
    exports->Set(NanNew<String>("version"), FunctionTemplate::New(Version)->GetFunction());
#endif
}

Seems like it's missing these lines:

    NODE_SET_METHOD(exports, "getConstPixels", GetConstPixels);
    NODE_SET_METHOD(exports, "quantumDepth", GetQuantumDepth); // QuantumDepth is already defined

Any thoughts?

Question about getConstPixel return value

I was really pleased to find this module, but my lack of familiarity with the C API is letting me down — please could you provide a little more info on the return value of getConstPixel? I realise the colour value relates to the quantum depth of my IM install, but am unsure who to convert the values to the format returned by the quantizeColors method.

Thanks in anticipation
Lee

Please add ability to pull EXIF data from image

for example options would be

{
srcData: required. Buffer with binary image data
debug: optional. 1 or 0
width: true,
make: true,
model : true,
orientation: true
}

this indicates that selective exif data is to be pulled.

ERROR reading files

Hello, i have this errors passing the test:

C:\nodejs\node_modules\imagemagick-native\test>node test.js
image magick's version is: 6.7.7
TAP version 13
convert invalid number of arguments
ok 1 should be equal
ok 2 should be equal
convert invalid resizeStyle
ok 3 err message
ok 4 buffer undefined
convert srcData is a Buffer
ok 5 should be equal
ok 6 buffer undefined
convert filter not supported
ok 7 should be equal
ok 8 buffer undefined
convert filter Lagrange
ok 9 buffer is Buffer
convert blur
ok 10 buffer is Buffer
convert strip
ok 11 buffer is Buffer
convert png -> png aspectfill
ok 12 buffer is Buffer
convert png -> jpg aspectfill
ok 13 buffer is Buffer
convert png.wide -> png.wide aspectfill
ok 14 buffer is Buffer
convert jpg -> jpg fill
ok 15 buffer is Buffer
convert jpg -> jpg aspectfit
ok 16 buffer is Buffer
convert broken png
not ok 17 should be similar


file:    events.js
line:    117
column:  20
stack:
  - | getCaller (C:\nodejs\node_modules\imagemagick-native\node_modules\tap\lib\tap-assert.js:418:17)
  - |  Function.assert (C:\nodejs\node_modules\imagemagick-native\node_modules\tap\lib\tap-assert.js:21:16)
  - |  Function.similar (C:\nodejs\node_modules\imagemagick-native\node_modules\tap\lib\tap-assert.js:251:19)
  - |  Test._testAssert [as similar] (C:\nodejs\node_modules\imagemagick-native\node_modules\tap\lib\tap-test.js:87:16)
  - | Test.imagemagick.convert.srcData (C:\nodejs\node_modules\imagemagick-native\test\test.js:224:11)
  - | Test.emit (events.js:117:20)
  - | Test.emit (C:\nodejs\node_modules\imagemagick-native\node_modules\tap\lib\tap-test.js:104:8)
  - |  GlobalHarness.Harness.process (C:\nodejs\node_modules\imagemagick-native\node_modules\tap\lib\tap-harness.js:87:13)
  - | process._tickCallback (node.js:419:13)
  - | Function.Module.runMain (module.js:499:11) pattern: "/CRC error|image\\.read failed with error:Magick:/"
string:  | image.read failed with error: node.exe: corrupt image `' @ error/png.c/ReadPNGImage/3715
match:   ~

...

windows 8.1
node 10.33 32b
Python 2.7.3
imagemagick 6.7.7.5 Q16
Visual Studio 2012 express

resizeStyle no upscale

Add an option to allow downscale only
By default upscale=true.
Most of the time it's useless to upscale an image, if displayed on a native application or on the browser there is a way to upscale the images and that save bandwidth.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.