![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
imagemagick-native
Advanced tools
Imagemagick's Magick++ binding for Node.
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',
filter: 'Lagrange',
blur: 0.8,
strip: true
});
require('fs').writeFileSync('./test/out.png', resizedBuffer, 'binary');
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.
density optional. Integer dpi value to convert
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"
filter: optional. ex: "Lagrange", "Lanczos". see ImageMagick's magick/option.c for candidates
blur: optional. ex: 0.8
strip: optional. default: false. strips comments out from image.
rotate: optional. degrees.
debug: optional. 1 or 0
ignoreWarnings: optional. 1 or 0
}
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
ignoreWarnings: optional. 1 or 0
}
The method returns an object similar to:
{
format: 'JPEG',
width: 3904,
height: 2622,
depth: 8,
density : {
width : 300,
height : 300
},
exif: {
orientation: 0 # 0 if none exists
}
}
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
ignoreWarnings: 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 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
ignoreWarnings: optional. 1 or 0
}
This library currently provide only these, please try node-imagemagick if you want more.
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.
Return ImageMagick's version as string.
ex: "6.7.7"
Return ImageMagick's QuantumDepth, which is defined in compile time.
ex: 16
Install Imagemagick with headers before installing this module. Tested with ImageMagick 6.7.7 on CentOS6 and MacOS10.7, Ubuntu12.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. Then:
npm install imagemagick-native
Tested on Windows 7 x64.
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.
Install Visual Studio C++ 2010 Express
(64-bit only) Install Windows 7 64-bit SDK
Install Imagemagick dll binary x86 Q16 or Imagemagick dll binary x64 Q16, check for libraries and includes during install.
Then:
npm install imagemagick-native
imagemagick: 16.09ms per iteration
imagemagick-native: 0.89ms per iteration
See node test/benchmark.js
for details.
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.
FAQs
ImageMagick's Magick++ bindings for NodeJS
The npm package imagemagick-native receives a total of 51 weekly downloads. As such, imagemagick-native popularity was classified as not popular.
We found that imagemagick-native demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.