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

smartcrop-gm

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smartcrop-gm

smartcrop adapter for gm / imagemagick

  • 2.0.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

smartcrop-gm

Build Status

This is an adapter module for using smartcrop.js with node.js using gm for image decoding.

Smartcrop-gm requires image magick to be installed and available in $PATH to function.

Installation

npm install --save smartcrop-gm

API

crop(image, options)

Image: string (path to file) or buffer

Options: options object to be passed to smartcrop

returns: A promise for a cropResult

Example

var request = require('request');
var gm = require('gm').subClass({ imageMagick: true });
var smartcrop = require('smartcrop-gm');

function applySmartCrop(src, dest, width, height) {
  request(src, { encoding: null }, function process(error, response, body) {
    if (error) return console.error(error);
    smartcrop.crop(body, { width: width, height: height }).then(function(result) {
      var crop = result.topCrop;
      gm(body)
        .crop(crop.width, crop.height, crop.x, crop.y)
        .resize(width, height)
        .write(dest, function(error) {
          if (error) return console.error(error);
        });
    });
  });
}

var src = 'https://raw.githubusercontent.com/jwagner/smartcrop-gm/master/test/flower.jpg';
applySmartCrop(src, 'flower-square.jpg', 128, 128);

Face Detection

Check out smartcrop-cli for a more advanced example of how to use smartcrop from node including face detection with opencv.

Security Considerations

smartcrop-gm is using imagemagick for decoding and resampling images. A number of security issues have been found in imagemagick recently. Make sure that you take the appropriate steps to protect your infrastructure.

FAQs

Package last updated on 11 Feb 2018

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