npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

oenyi

v0.2.1

Published

A wrapper for image processing commands that provides a chainable API with asynchronous pipeline of commands.

Downloads

30

Readme

Oenyi

Build Status Code Climate

A very simple wrapper for a few image processing methods that just provides:

  • A convenient and consistent API.
  • Full in memory processing support to reduce i/o and increase speed.
  • Three resizing methods that will make your life easier.

It is designed to chain the transformations you need and execute them in order once you call the exec method which gives you a buffer with the image or, if you prefer, when you call the pipe method which accepts a stream.

Want to see the technical specification? Go here

Installation

You need to install imagemagick since this library depends on it.

OSX

  $ brew install imagemagick

Ubuntu

  $ sudo apt-get install imagemagick

Then install the module.

  npm install oenyi

Require oenyi

  var oenyi = require('oenyi');

Getting an oenyi image instance.

Using a string as path.

  var image = oenyi('/path/to/image');

Using a buffer

  var fs = require('fs');

  fs.readFile('/path/to/image', function(err, buffer) {
    if (err) {
      console.error(err);
      return;
    }
    var image = oenyi(buffer);
  });

Convert image to jpeg.

  image.toJPG();

Compress image to a given quality.

  image.compress({quality: 90});

Reszing Methods.

Oenyi gives you three resizing methods: Cover, Contain and Fit. They do what they promise.

Resize by Contain.

It is meant to be used when you want to ensure a maximum size but you want the aspect ratio untouched and if it fits, then the original size as well. This method will only resize down when the image to resize is bigger than the size provided.

  // original size w:400, h:400
  image.resize({width: 500, height: 255, method: 'contain'}); // => produces size w:255, h:225

  // original size w:3000, h:600
  image.resize({width: 500, height: 255, method: 'contain'}); // => produces size w:500, h:100

Resize by Fit.

So you want to grow or shrink an image to fit an area as best as it can, but want to keep the aspect ratio and the full image visible? Well, use this method.

  // original size w:640, h:2560
  image.resize({width: 1024, height: 1024, method: 'fit'}); // => produces size w:256, h:1024

  // original size w:5000, h:3000
  image.resize({width: 1000, height: 2000, method: 'fit'}); // => produces size w:1000, h:600

Resize by Cover.

Resizes an image to cover or match a size and force a new aspect ratio with no distortion.

  // original size w:640, h:2560
  image.resize({width: 500, height: 500, method: 'cover'}); // => produces size w:500, h:500

Execute all commands and return a buffer with the modified image.

  image.exec(function(err, imageBuffer) {
    // Your code here.
  });

Execute all commands and pipe to a stream.

  var wstream = require('fs').createWriteStream('/path/to/destiny');
  image.pipe(wstream);

Run a complex chained transformation.

Use method chaining to apply many transformations to a single image. Get the image buffer at the end and do with it whatever you want.

  var oenyi = require('oenyi');
  var fs = require('fs');

  oenyi('/path/to/image')
    .toJPG()
    .compress({quality: 80})
    .resize({width: 500, height: 500, method: 'cover'})
    .exec(function(err, imageBuffer) {
      if (err) return console.error(err);

      fs.writeFile('/path/to/destiny', imageBuffer);
    });

FAQ

Why the silly name?

Because of this creepy video. https://youtu.be/GzobV_qoIcQ You can blame javierbyte for that.

Why do this wrapper?

At VoxFeed we wanted to remove image processing related logic from our platform, isolate it and provide a consistent API to make our image related code more bearable...err, readable. So we designed this wrapper.