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

6px

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

6px

Node.js module for 6px

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
66
increased by200%
Maintainers
2
Weekly downloads
 
Created
Source

Node.js module for 6px

Node.js module for interacting with the 6px API. This module includes methods that makes sending image processing jobs to 6px easier.

Getting Started

Install the NPM package:

$ npm install 6px

##Examples If you want to simply upload an image to the 6px CDN:

var px = require('6px')({
    userId: '***USER_ID***',
    apiKey: '***API_KEY***',
    apiSecret: '***API_SECRET***'
});

px.on('connection', function() {
    var image = px({taxi: 'https://s3.amazonaws.com/ooomf-com-files/mtNrf7oxS4uSxTzMBWfQ_DSC_0043.jpg'});
    var output = image.output({ taxi: 'unsplashed_taxi' }).tag('img').url('6px');

    image.save().then(function(res) {
        console.log('Done:', res);
    }, function(err) {
        console.log('Error:', err);
    });
});

Given that vintage photos are kind of kind of popular right now, let's take this up a notch:

var px = require('6px')({
    userId: '***USER_ID***',
    apiKey: '***API_KEY***',
    apiSecret: '***API_SECRET***'
});

px.on('connection', function() {
    var image = px({taxi: 'https://s3.amazonaws.com/ooomf-com-files/mtNrf7oxS4uSxTzMBWfQ_DSC_0043.jpg'});
    var output = image.output({ taxi: 'unsplashed_taxi' })
        .tag('vintage')
        .url('6px')
        .filter({ sepia: 70 });

    image.save().then(function(res) {
        console.log('Done:', res);
    }, function(err) {
        console.log('Error:', err);
    });
});

So, we have a bit of an extreme sepia effect going on here, but that's fine. I think this deserves to be more of a thumbnail. We are going to resize it now:

var px = require('6px')({
    userId: '***USER_ID***',
    apiKey: '***API_KEY***',
    apiSecret: '***API_SECRET***'
});

px.on('connection', function() {
    var image = px({taxi: 'https://s3.amazonaws.com/ooomf-com-files/mtNrf7oxS4uSxTzMBWfQ_DSC_0043.jpg'});
    var output = image.output({ taxi: 'unsplashed_taxi' })
        .tag('vintage_thumb')
        .url('6px')
        .filter({ sepia: 70 })
        .resize({ width: 75 });

    image.save().then(function(res) {
        console.log('Done:', res);
    }, function(err) {
        console.log('Error:', err);
    });
});

Another thing we can do is change the dominate color of an image:

var px = require('6px')({
    userId: '***USER_ID***',
    apiKey: '***API_KEY***',
    apiSecret: '***API_SECRET***'
});

px.on('connection', function() {
    var image = px({taxi: 'https://s3.amazonaws.com/ooomf-com-files/mtNrf7oxS4uSxTzMBWfQ_DSC_0043.jpg'});
    var output = image.output({ taxi: 'unsplashed_taxi' })
        .tag('green')
        .url('6px')
        .filter({ colorize: { hex: '#00FF00', strength: 80 } });

    image.save().then(function(res) {
        console.log('Done:', res);
    }, function(err) {
        console.log('Error:', err);
    });
});

Let's blur the image at the same time.

var px = require('6px')({
    userId: '***USER_ID***',
    apiKey: '***API_KEY***',
    apiSecret: '***API_SECRET***'
});

px.on('connection', function() {
    var image = px({taxi: 'https://s3.amazonaws.com/ooomf-com-files/mtNrf7oxS4uSxTzMBWfQ_DSC_0043.jpg'});
    var output = image.output({ taxi: 'unsplashed_taxi' })
        .tag('green_blur')
        .url('6px')
        .filter({
            colorize: { hex: '#00FF00', strength: 80 },
            stackBlur: 20
        });

    image.save().then(function(res) {
        console.log('Done:', res);
    }, function(err) {
        console.log('Error:', err);
    });
});

Now that we have covered some of the simple use cases, feel free to refer to our documentation!

##API Documentation

Keep us posted on the cool stuff you are doing by sending us an email at ops@6px.io. We are constantly trying to improve the user experience. If you come across any issues or have suggestions please create an issue ticket.

Keywords

FAQs

Package last updated on 04 Sep 2014

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