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

gm-image-tile

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gm-image-tile

Creates image tiles in Node.js using GraphicsMagick.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

gm-image-tile NPM Version

Creates image tiles in Node.js using GraphicsMagick.

Install

First, install GraphicsMagick. This is part of requirement for gm package.

Then, install this package by npm install gm-image-tile --save.

Usage

To create image tiles from file otters.jpg with tile size of 512 pixels. Call imageTile in a Promise-fashion. By default, the output is in PNG format of type Buffer.

const imageBuffer = fs.readFileSync('otters.jpg');

imageTile(imageBuffer, 512).then(result => {
  // Further processing here
});

Result from imageTile call

Assumes the input image is 1024x768 and tile size is set to 512 pixels. After calling imageTile, the result will be returned as Buffer, as follow. Notes the bottommost tiles are truncated and height is 256 pixels.

[
  [
    { buffer: <Buffer>, x: 0,   y: 0, width: 512, height: 512 },
    { buffer: <Buffer>, x: 512, y: 0, width: 512, height: 512 }
  ], [
    { buffer: <Buffer>, x: 0,   y: 512, width: 512, height: 256 },
    { buffer: <Buffer>, x: 512, y: 512, width: 512, height: 256 }
  ]
]

Options

By default, the output tiles are in PNG format. To output in JPEG format of quality level 80, you can call imageTile as below.

const options = {
  format: 'JPG',
  quality: 80
}

imageTile(imageBuffer, 512, options).then(result => {
  // Output buffers will be JPEG images of quality level 80
});

Contribution

Like us? Please star us in GitHub and npm.

Bugs or suggestions? Please file us an issue.

FAQs

Package last updated on 04 Jan 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