Friendly tools for interacting with GraphicsMagick.
# Using npm
npm install --save gm-tools
# Using yarn
yarn add gm-tools
const gmTools = require("gm-tools");
let img = gmTools(__dirname + "/octocat.jpg");
// Get all the pixels
img.pixels((err, pixels) => {
console.log(err || pixels);
// [ PixelClass { r: 34, g: 30, b: 31, a: 2.55 },
// PixelClass { r: 34, g: 30, b: 31, a: 2.55 },
// PixelClass { r: 34, g: 30, b: 31, a: 2.55 },
// ...
// PixelClass { r: 241, g: 241, b: 243, a: 2.55 },
// ...
// PixelClass { r: 191, g: 189, b: 190, a: 2.55 },
// PixelClass { r: 195, g: 191, b: 192, a: 2.55 },
// PixelClass { r: 92, g: 90, b: 91, a: 2.55 },
// PixelClass { r: 32, g: 30, b: 31, a: 2.55 },
// PixelClass { r: 32, g: 30, b: 31, a: 2.55 },
// ...
// PixelClass { r: 34, g: 30, b: 31, a: 2.55 } ]
});
// Get pixel at given coordinates
img.getPixel(0, 0, (err, pixel) => {
console.log(err || pixel);
// PixelClass { r: 34, g: 30, b: 31, a: 2.55 }
});
There are few ways to get help:
- Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
- For bug reports and feature requests, open issues. π
- For direct and quick help, you can use Codementor. π
Creates a new instance of GmParser
.
- String|Buffer|GraphicsMagick
input
: The path to an image file, the image buffer or an existing GraphicsMagick object. - Function
cb
: The callback function.
Resizes the image.
- Number
width
: The size width. - Number
height
: The size height.
Parses the image internally.
- Function
cb
: The callback function.
Gets the image size. This appends the width
and height
functions to
the GmParser
instance that return the width and height of the image.
- Function
cb
: The callback function.
Converts the image into a buffer that is parsed by pngjs
.
- Function
cb
: The callback function.
Gets all the image pixels.
- Buffer
buffer
: An optionalpngjs
buffer. If provided, the pixels array will be returned. - Function
cb
: The callback function.
- Array An array of pixels (only if the
buffer
argument is provided).
Gets the pixel data at given coordinates.
- Number
x
: Thex
coordinate. - Number
y
: They
coordinate. - Buffer
buffer
: An optionalpngjs
buffer. If provided, the pixels array will be returned. - Function
cb
: The callback function.
- Pixel A
Pixel
instance. This will be returned only if thebuffer
argument is provided.
Friendly tools for interacting with graphicsmagick
- String|Buffer|GraphicsMagick
input
: The path to an image file, the image buffer or an existing GraphicsMagick object. - Function
cb
: The callback function.
- GmParser The
GmParser
instance.
Have an idea? Found a bug? See how to contribute.
I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).
However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:
-
Starring and sharing the projects you like π
-
βI love books! I will remember you after years if you buy me one. π π
-
βYou can make one-time donations via PayPal. I'll probably buy a
coffeetea. π΅ -
βSet up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).
-
BitcoinβYou can send me bitcoins at this address (or scanning the code below):
1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6
Thanks! β€οΈ
If you are using this library in one of your projects, add it in this list. β¨
image-parser