1.0.2 • Published 2 years ago

byd-imagemagick-client v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Description

A client to the Imagemagick micro service to edit & convert picture using gRPC communication.

Installation

$ npm install @sixense/byd-imagemagick-client

Exemple

import { ImageMagick, FormatEnum, FontFamilyEnum } from '@sixense/byd-imagemagick-client';
// Create a new ImageMagickClient connected to the ImageMagick service on localhost:5000
const Im = new ImageMagickClient('localhost', 5000);
// add a Rotation of 90° to the image
Im.rotate(90);
// add rectangle drawing
Im.drawRectangle(10, 10, 100, 100, {
    color: 'red',
});
// Add a text 
Im.drawText(50, 50, 'Hello World', {
    color: 'white',
    font: {
    family: FontFamilyEnum.DEJAVU_SANS,
    size: 10,
    },
});
// Create un stream from an image file
const readStream = fs.createReadStream('picture.jpg');
// Run all image actions onthe image stream and output the result in a file.
await Im.run(readStream, `./result.png`, FormatEnum.PNG);
Im.close();