Skip to content
This repository

Plug into the power and speed of Kraken.io Image Optimizer

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 README.md
Octocat-spinner-32 package.json
README.md

kraken - a Node.js client for Kraken.io API

Build Status

With this Node module you can plug into the power and speed of Kraken.io Image Optimizer.

Installation

npm install kraken

Getting Started

First you need to create your Kraken Account (for free) and obtain your unique Kraken API Key. You will find your API Key in your Account Settings. Once you have created (and activated) your account, you can start using Kraken API in your applications.

How to use

You can optimize your images in two ways - by providing an URL of the image you want to optimize or by uploading an image file from your disk directly to Kraken API. The first option (image URL) is great for images that are already in production environment or any other place available on the Internet. The second one (image upload) is ideal for deployment process or build script where you don't have your images on the Internet yet.

Usage - Image URL

To optimize an image by providing image URL use the kraken.optimize() method:

var Kraken = require('kraken');

var kraken = new Kraken({
  'user': 'your-kraken-username',
  'pass': 'your-kraken-password',
  'apikey': 'your-kraken-api-key'
});

var image = {
  'url': 'http://image-url-to-optimize'
};

kraken.optimize(image, function(status) {
  if (status.success) {
    console.log('Success. Optimized image URL: %s', status.krakedURL);
  } else {
    console.log('Fail. Error message: %s', status.error);
  }
});

Usage - Image Upload

If you want to upload your images directly to Kraken API use the kraken.upload() method:

var Kraken = require('kraken');

var kraken = new Kraken({
  'user': 'your-kraken-username',
  'pass': 'your-kraken-password',
  'apikey': 'your-kraken-api-key'
});

var image = '/Path/To/File.jpg';

kraken.upload(image, function(status) {
  if (status.success) {
    console.log('Success. Optimized image URL: %s', status.krakedURL);
  } else {
    console.log('Fail. Error message: %s', status.error);
  }
});

LICENSE - "MIT License"

Copyright (c) 2012 Przemek Matylla przemek@matylla.pl

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.