tableflip/resize-jpeg

Name: resize-jpeg

Owner: TABLEFLIP

Description: :rainbow: Resize your jpeg and preserve it's original quality

Created: 2015-07-06 13:02:05.0

Updated: 2015-11-18 15:39:54.0

Pushed: 2015-08-09 08:28:00.0

Homepage:

Size: 140

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

resize-jpeg

You want to resize a jpeg? You want to preserve it's visual quality while doing so?

ze-jpeg -w 800 original.jpg > original.w800.jpg
Resize a jpeg and optimise for the web with mozjpeg

GraphicsMagick (and ImageMagick) dial down the quality of your JPEG files when you resize them.

That's surprising. mozjpeg does a better job of optimising pixels for your eyes, and every byte counts, so instead:

ze-jpeg --minify -w 800 original.jpg > original.w800.min.jpg

That'll generally give a better output jpeg for fewer bytes. Win win!

Get started

Use a sensible package manager for you OS to install http://www.graphicsmagick.org/ Then use npm to install resize-jpeg, globally as a command line tool.

 install graphicsmagick
install -g resize-jpeg
ze-jpeg -w 800 path/to/my/picture

where -w is the new width you'd like proportionally scale the image to. Add a --minify in there to engage mozjpeg minification magic.

Use it as a module!

Add it to your project npm install --save resize-jpeg

Add you now have a transform stream that'll resize internet pugs on the fly:

fs = require('fs')
http = require('http')
resizeJpeg = require('resize-jpeg')

.get('http://aboutpug.com/wp-content/uploads/2015/01/flying-monkey-cute-pug.jpg')
n('response', function (resp) {
resp
  .pipe(resizeJpeg(800))
  .pipe(fs.createWriteStream('webpug.w800.jpg'))

or more simply, just resize jpegs from your local file system

fs = require('fs')
http = require('http')
resizeJpeg = require('resize-jpeg')

reateReadStream('flying-pug.jpg')
ipe(resizeJpeg(800))
ipe(fs.createWriteStream('pug.w800.jpg'))
How does it work?

Under the hood, resize-jpeg is just doing the work of remembering the nasty gm command arguments for you. If you prefer to do it long hand, then it's the same as:

onvert original.jpg -resize 800x800 -define jpeg:preserve-settings - > original.w800.min.jpg

A (?°?°???TABLEFLIP side project.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.