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

picel

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

picel

Picel accompanying tool for encoding images.

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

picel-js Build Status NPM version NPM downloads

JavaScript library for string-encoding images to be served using the picel image processing service microservice / middleware.

Learn more about Picel by reading the project docs.

Install

Install via Bower, npm or clone the repo.

This encoder library works both with Node.JS and on browsers.

API

picel.encode(image)

Image is a JSON that can contain any of the following keys:

  • prefix: picel end-point
  • backend: image storage end-point (only when picel server is open / unrestricted)
  • path: path to the file relative to the backend server
  • raw: boolean flag to retrieve the original file
  • crop: {x, y, width, height}
  • width
  • height
  • output

All methods inside the price object that starts with _ (underscore) are to be considered private and you should not rely on them. The only reason it's not scoped inside of a closure is to facilitate testing (but that may change on the future).

Examples

It's pretty easy to compose image transformation urls using this library.

Let's start with

var img = {
    prefix: "http://localhost:8123/",
    path: "7386/11274440243_10456d457d_h.jpg"
};

From there we will extend the img object and invoke the picel.encode successively.

picel.encode(img);

returns http://localhost:8123/7386/11274440243__10456d457d__h

Which won't work unless you're using a single backend. If you aren't, you've to extend the img object:

img.backend = "https://farm8.staticflickr.com/";

picel.encode(img);

returns http://localhost:8123/s:farm8.staticflickr.com/7386/11274440243__10456d457d__h

If you want to crop:

img.crop = {
    x: 0,
    y: 10,
    width: 600,
    height: 600
};

picel.encode(img);

will return

http://localhost:8123/s:farm8.staticflickr.com/7386/11274440243__10456d457d__h_0x10:600x600

and so on.

By omitting the extension the server will serve you the more appropriate extension.

If you want to force an extension just use img.output = 'jpg', for example.

For example:

picel.encode({
    "path": "/foo.gif",
    "width": 600,
    "height": 400,
    "output": "webp"
})

should return /foo_600x400_gif.webp

More examples can be recovered from the picel-js/test/fixtures/encode.json test data provider file.

Keywords

FAQs

Package last updated on 05 May 2015

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