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

imagemin-gm

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imagemin-gm

GraphicsMagick imagemin plugin

  • 2.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
decreased by-82.31%
Maintainers
1
Weekly downloads
 
Created
Source

imagemin-gm

npm version

GraphicsMagick plugin for imagemin

Install

$ npm install --save imagemin-gm

Important: This plugin requires GraphicsMagick to be installed.
On macOS for example, you can use Homebrew: brew install graphicsmagick.

If this script throws the Exception Stream yields empty buffer, this means the GraphicsMagick binaries can not be found in your path. You can pass the location to the ImageminGm constructor.

Usage

const imagemin = require('imagemin')
const ImageminGm = require('imagemin-gm')
const imageminGm = new ImageminGm()

const plugins = [
  imageminGm.resize({ width: 250, height: 250, gravity: 'Center' }),
  imageminGm.convert('jpg')
]

imagemin(['images/*.gif'], 'output', { use: plugins })
  .then(() => console.log('Images converted'))
  .catch(err => console.error(err))

API

ImageminGm([gmPath])

Constructor, optionally pass the path to GraphicsMagick binaries (not the binary itself).

Example:

// Posix
let imageminGm = new ImageminGm('/path/to/gm/binaries/')
// Windows
let imageminGm = new ImageminGm('C:\\Path\\to\\gm\\binaries\\')

imageminGm.resize(options)

Resizes the image buffer. At least one dimension must be given, otherwise the image isn't altered. If both image dimensions are set, the image is resized to fit the constraints while maintaining the original aspect ratio. Image position can be adjusted with the gravity option.

Options
  • width
  • height
  • gravity (optional): NorthWest|North|NorthEast|West|Center|East|SouthWest|South|SouthEast

imageminGm.convert(format)

Converts the image buffer to a different image format (e.g. 'gif', 'jpeg', 'png'). Note: The original filename is used, although the image format has changed. You have to rename the file with the correct extension yourself afterwards.

License

MIT

Keywords

FAQs

Package last updated on 02 Nov 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