API Reference and Developer Documentation

Automatic Image Orientation

The EXIF (exchangeable image file format) standard specifies an Orientation tag that can be embedded in images, and is usually set in accordance with the reading from a gravity sensor or accelerometer in digital cameras and smartphones. This enables you to take a picture with your camera sideways or upside-down, and stand a reasonable chance of having it display properly on your computer.

By default, Kraken.io API strips away the Orientation tag, as the most common value is 1 (which represents Top-Left), which means that the image is already correctly oriented.

It is useful, however, to correctly orient the image without relying on the viewer application to correctly interpret the Orientation value, so that it is suitable for viewing.

Kraken.io's "auto_orient": true flag will do just that. It will perform a lossless rotation of the JPEG image such that it is suitable for viewing, and subsequently strip the now-redundant Orientation metadata.

The resulting re-oriented image will then be optimized using the mode you have selected (either lossless or lossy).

When used together with "preserve_meta": ["orientation"], the "new" orientation will be preserved, so the value will always be "1". In other words, it is no longer useful to preserve the orientation when using our "auto_orient": true feature.

  "auth": {
      "api_key": "your-api-key",
      "api_secret": "your-api-secret"
  "url": "http://awesome-website.com/images/header.png",
  "wait": true,
  "lossy": true,
  "auto_orient": true


$kraken = new Kraken("your-api-key", "your-api-secret");

$params = array(
    "url" => "http://awesome-website.com/images/header.png",
    "wait" => true,
    "lossy" => true,
    "auto_orient" => true

$data = $kraken->url($params);

if ($data["success"]) {
    echo "Success. Optimized image URL: " . $data["kraked_url"];
} else {
    echo "Fail. Error message: " . $data["message"];
var Kraken = require("kraken");

var kraken = new Kraken({
    "api_key": "your-api-key",
    "api_secret": "your-api-secret"

var params = {
    url: "http://awesome-website.com/images/header.png",
    wait: true,
    lossy: true,
    auto_orient: true

kraken.url(params, function(status) {
    if (status.success) {
        console.log("Success. Optimized image URL: %s", status.kraked_url);
    } else {
        console.log("Fail. Error message: %s", status.message);
require 'rubygems'
require 'kraken-io'

kraken = Kraken::API.new(
    :api_key => 'your-api-key',
    :api_secret => 'your-api-secret'

params = {
    :wait => true,
    :lossy => true,
    :auto_orient => true

data = kraken.url('http://awesome-website.com/images/header.png', params)

if data.success
    puts 'Success! Optimized image URL: ' + data.kraked_url
    puts 'Fail. Error message: ' + data.message
package main

import (

func main() {
    kr, err := kraken.New("your-api-key", "your-api-secret")

    if err != nil {

    params := map[string]interface {} {
        "url": "http://awesome-website.com/images/header.png"
        "wait": true,
        "lossy": true,
        "auto_orient": true

    data, err := kr.URL(params)

    if err != nil {

    if data["success"] != true {
        log.Println("Failed, error message ", data["message"])
    } else {
        log.Println("Success, Optimized image URL: ", data["kraked_url"])
using Kraken;
using Kraken.Http;

var client = Connection.Create("your-api-key", "your-api-secret");

var response = client.OptimizeWait(
    new OptimizeWaitRequest(
      new Uri("http://awesome-website.com/images/header.png"))
          Lossy = true,
          AutoOrient = true

if (response.Result.StatusCode == HttpStatusCode.OK) {
    var url = response.Result.Body.KrakedUrl;
from krakenio import Client

api = Client('your-api-key', 'your-api-secret')

data = {
    'wait': True,
    'lossy': True,
    'auto_orient': True

result = api.url('http://awesome-website.com/images/header.png', data);

if result.get('success'):
    print result.get('kraked_url')
    print result.get('message')