Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gm

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gm

GraphicsMagick and ImageMagick for node.js

  • 1.25.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
356K
increased by6.39%
Maintainers
1
Weekly downloads
 
Created

What is gm?

The gm (GraphicsMagick) npm package is a Node.js wrapper for the GraphicsMagick and ImageMagick image processing libraries. It allows you to perform a wide range of image manipulation tasks such as resizing, cropping, rotating, and adding text to images.

What are gm's main functionalities?

Image Resizing

This feature allows you to resize an image to the specified dimensions. In this example, the image is resized to 240x240 pixels.

const gm = require('gm');
gm('/path/to/image.jpg')
  .resize(240, 240)
  .write('/path/to/resized_image.jpg', function (err) {
    if (!err) console.log('Image resized successfully');
  });

Image Cropping

This feature allows you to crop an image to the specified width and height, starting from the specified x and y coordinates. In this example, a 100x100 pixel area is cropped from the image starting at coordinates (50, 50).

const gm = require('gm');
gm('/path/to/image.jpg')
  .crop(100, 100, 50, 50)
  .write('/path/to/cropped_image.jpg', function (err) {
    if (!err) console.log('Image cropped successfully');
  });

Image Rotation

This feature allows you to rotate an image by a specified angle. In this example, the image is rotated by 45 degrees with a green background fill.

const gm = require('gm');
gm('/path/to/image.jpg')
  .rotate('green', 45)
  .write('/path/to/rotated_image.jpg', function (err) {
    if (!err) console.log('Image rotated successfully');
  });

Adding Text to Image

This feature allows you to add text to an image. In this example, the text 'Hello World' is added to the image at coordinates (30, 50) with a font size of 68.

const gm = require('gm');
gm('/path/to/image.jpg')
  .fontSize(68)
  .drawText(30, 50, 'Hello World')
  .write('/path/to/text_image.jpg', function (err) {
    if (!err) console.log('Text added to image successfully');
  });

Other packages similar to gm

Keywords

FAQs

Package last updated on 21 Sep 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc