0.4.1 • Published 2 years ago

qimagemagick v0.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

node-qimagemagick

You can install this module using npm

npm install qimagemagick --save

Requirements

  • ImageMagick CLI:
    • Debian/Ubuntu: sudo apt-get install imagemagick

Examples

Convert and show info

import { QIM } from "qimagemagick";
// const { QIM } = require("qimagemagick");

async function main() {
    let image = await QIM.read_to_buffer('./example-images/coffee.png');
    
    let info = await QIM.identify(image).catch(reason => {console.log(reason)});
    console.log(info);
    
    let blob = await QIM.convert(image, {
        format: 'jpg',
        resize: '50%'
    }).catch(reason => {
        console.log('error: ', reason);
        process.exit(1);
    });
    
    let converted_info = await QIM.identify(blob).catch(reason => {console.log(reason)});
    console.log(converted_info);
}

main();
Output
Info {
  width: 1909,
  height: 1066,
  page_width: 1909,
  page_height: 1066,
  offset_x: 0,
  offset_y: 0,
  format: 'PNG',
  depth: '8-bit',
  colorspace: 'sRGB',
  size: '1.8288MiB'
}
Info {
  width: 955,
  height: 533,
  page_width: 955,
  page_height: 533,
  offset_x: 0,
  offset_y: 0,
  format: 'JPEG',
  depth: '8-bit',
  colorspace: 'sRGB',
  size: '181.8047KiB'
}

Crop from center

import { QIM } from "qimagemagick";
// const { QIM } = require("qimagemagick");

async function main() {
    let image = await QIM.read_to_buffer('./example-images/coffee.png');

    let blob = await QIM.convert(image, {
        gravity: 'Center',
        crop: '300x300+0+0'
    }).catch(reason => {
        console.log('error: ', reason);
        process.exit(1);
    });
    
    let converted_info = await QIM.identify(blob).catch(reason => {console.log(reason)});
    console.log(converted_info);
}
main();
Output
Info {
  width: 300,
  height: 300,
  page_width: 1909,
  page_height: 1066,
  offset_x: 804,
  offset_y: 383,
  format: 'PNG',
  depth: '8-bit',
  colorspace: 'sRGB',
  size: '36.2393KiB'
}

Reading images

  • From local file
    let buffer = await QIM.read_to_buffer('./coffee.png');
    let info = await QIM.identify('./coffee.png');
  • From URL
    let buffer = await QIM.read_to_buffer('https://placedog.net/640/480');
    let info = await QIM.identify('https://placedog.net/640/480');
  • From Buffer
    let buffer = await QIM.read_to_buffer('https://placedog.net/640/480');
    let info = await QIM.identify(buffer);

More Examples

Full Documentation

To see the full documentation visit: ImageMagick – Command-line Processing

0.3.9

2 years ago

0.3.0

2 years ago

0.2.1

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.4.1

2 years ago

0.3.2

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.2.0

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago