Socket
Socket
Sign inDemoInstall

jpeg-turbo-scaler

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jpeg-turbo-scaler

Extremely fast JPEG scaling module based on libjpeg-turbo


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Node.js JPEG turbo scaler module

Native C++ Node.js module which uses libjpeg-turbo for extremely fast JPEG compression and decompression.

Installation

The module have been tested to build correctly only on OS X and requires libjpeg-turbo to be installed manually via Homebrew. It should be pretty easy to build it on any system, the only dependency is libjpeg-turbo library which you can easily install using your favorite package manager and simply add include and lib directories to bindings.gyp file.

Installation sequence:

  • Install libjpeg-turbo
brew install jpeg-turbo
  • Install the module using npm
npm install jpeg-turbo-scaler

Usage

function decompress(path, targetWidth, targetHeight, callback)

Reads a JPEG file referenced by path from local file system and resizes it to fit into targetWidthxtargetHeight box keeping original aspect ratio.

path: a string containing JPEG image file path (absolute or relative).

targetWidth and targetHeight: desired dimensions of decompressed image.

callback: function(bitmap, width, height) where bitmap is a Buffer with RGBA pixels data.

function scale(path, targetWidth, targetHeight, callback)

Reads a JPEG file referenced by path from local file system, resizes it to fit into targetWidthxtargetHeight box keeping original aspect ratio, and compresses the result to JPEG.

path: a string containing JPEG image file path (absolute or relative).

targetWidth and targetHeight: desired dimensions of decompressed image.

callback: function(jpeg, width, height) where bitmap is a JPEG file data.

Example

var jpeg = require('jpeg-turbo-scaler');
jpeg.decompress('image.jpg', 300, 300, function(bitmap, width, height) {
  console.log('Got ' + bitmap.length + ' bytes RGBA bitmap');
});

jpeg.scale('image.jpg', 300, 300, function(jpeg, width, height) {
  console.log('Got ' + jpeg.length + ' scaled JPEG file');
  require('fs').writeFileSync('output.jpg', jpeg);
});

FAQs

Last updated on 06 Mar 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc