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

node-imager

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-imager

A simple image resizer using imagemagick

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

node-imager

a super simple nodejs image resizer. resize files on disk or over http / https

Prerequisites

  • ImageMagick

##installation

$ npm install node-imager --save

##usage basic usage example:

const express = require('express');
const imager = require('node-imager');
const app = express();

app.get('/imager/', (req, res) => {  
  // node-imager will try to find this image relative the root of your application
  // absolute file paths or urls work too
  const url = 'http://i.imgur.com/1KDwL1M.png';

  const options = {
    width: 500,
    height: 500,
    format: 'c',
    url
  };
  
  // crop image
  imager.resizeWith(options, (contentType, imageBuffer) => {
    res.setHeader('Content-Type', contentType);
    res.send(imageBuffer);
  });
});
app.listen(3000);

##api

 option (String): 'c' - crops the image from the center outwards. 
         '' - for normal resizing
         
 width (Number): desired width
 
 height (Number): desired height
 
 url (String): can be relative path or remote file on the web
               'images/test.png'
               'http://i.imgur.com/1KDwL1M.png' --important to prefix with 'http://'
               
 next: callback function
       (contentType, imageBuffer) => { }
resize(option, width, height, url, callback);

or

const options = {
  width: 500,
  height: 500,
  format: 'c',
  url
};
resizeWith(options, callback);

Keywords

FAQs

Package last updated on 06 Feb 2017

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