Download the PHP package kraken-io/kraken-php without Composer

On this page you can find all versions of the php package kraken-io/kraken-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package kraken-php

PHP library for Kraken.io Image Optimizer API

This is the official Kraken.io PHP library, which should help users very quickly integrate our Image Optimization into their PHP projects. Kraken.io Image Optimizer.

Installation

Composer

If you're using Composer, you can simply add a dependency on kraken-io/kraken-php to your project's composer.json file. Here's an example of a dependency on version 1.2:

Alternatively you can also execute the following command in your project's root directory:

Git

If you already have git, the easiest way to download the Kraken-PHP library is with the git command:

By Hand

Alternatively, you may download the PHP files from GitHub and place them within your PHP project:

Getting Started

First you need to sign up for the Kraken.io API and obtain your unique API Key and API Secret. You will find both under API Credentials. Once you have set up your account, you can start using Kraken.io API in your applications.

Downloading Images

Remember - never link to optimized images offered to download. You have to download them first, and then replace them in your websites or applications. Due to security reasons optimized images are available on our servers for one hour only.

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 directly to Kraken.io API.

The first option (image URL) is great for images that are already in production or any other place on the Internet. The second one (direct upload) is ideal for your deployment process, build script or the on-the-fly processing of your user's uploads where you don't have the images available online yet.

Wait and Callback URL

Kraken.io gives you two options for fetching optimization results. With the wait option set the results will be returned immediately in the response. With the callback_url option set the results will be posted to the URL specified in your request.

Wait option

With the wait option turned on for every request to the API, the connection will be held open until the image has been optimized. Once this is done you will get an immediate response with a JSON object containing your optimization results. To use this option simply set "wait": true in your request.

Request:

`

Response

`

Callback URL

With the Callback URL the HTTPS connection will be terminated immediately and a unique id will be returned in the response body. After the optimization is over Kraken.io will POST a message to the callback_url specified in your request. The ID in the response will reflect the ID in the results posted to your Callback URL.

We recommend RequestBin as an easy way to capture optimization results for initial testing.

Request:

`

Response:

`

Results posted to the Callback URL:

`

Authentication

The first step is to authenticate to Kraken.io API by providing your unique API Key and API Secret while creating a new Kraken.io instance:

``

Usage - Image URL

To optimize an image by providing image URL use the kraken.url() method. You will need to provide two mandatory parameters in an array - url to the image and wait or callback_url:

``

Depending on a chosen response option (Wait or Callback URL) in the data array you will find either the optimization ID or optimization results containing a success property, file name, original file size, kraked file size, amount of savings and optimized image URL:

``

Usage - Image Upload

If you want to upload your images directly to Kraken.io API use the kraken->upload() method. You will need to provide two mandatory parameters in an array - file which is the absolute path to the file and wait or callback_url.

In the $data array you will find the same optimization properties as with the url option above.

``

Lossy Optimization

When you decide to sacrifice just a small amount of image quality (usually unnoticeable to the human eye), you will be able to save up to 90% of the initial file weight. Lossy optimization will give you outstanding results with just a fraction of image quality loss.

To use lossy optimizations simply set "lossy" => true in your request:

``

PNG Images

PNG images will be converted from 24-bit to paletted 8-bit with full alpha channel. This process is called PNG quantization in RGBA format and means the amount of colours used in an image will be reduced to 256 while maintaining all information about alpha transparency.

JPEG Images

For lossy JPEG optimizations Kraken.io will generate multiple copies of a input image with a different quality settings. It will then intelligently pick the one with the best quality to filesize ration. This ensures your JPEG image will be at the smallest size with the highest possible quality, without the need for a human to select the optimal image.

Image Resizing

Image resizing option is great for creating thumbnails or preview images in your applications. Kraken.io will first resize the given image and then optimize it with its vast array of optimization algorithms. The resize option needs a few parameters to be passed like desired width and/or height and a mandatory strategy property. For example:

``

The strategy property can have one of the following values:

More information about image resizing and cropping can be found in the Kraken.io API Reference

WebP Compression

WebP is a new image format introduced by Google in 2010 which supports both lossy and lossless compression. According to Google, WebP lossless images are 26% smaller in size compared to PNGs and WebP lossy images are 25-34% smaller in size compared to JPEG images.

To recompress your PNG or JPEG files into WebP format simply set "webp": true flag in your request JSON. You can also optionally set "lossy": true flag to leverage WebP's lossy compression:

``

Image Type Conversion

Kraken.io API allows you to easily convert different images from one type/format to another. If, for example, you would like to turn you transparent PNG file into a JPEG with a grey background Kraken.io API has you covered.

In order to convert between different image types you need to add an extra convert object to you request JSON. This object takes three properties:

Mandatory Parameters:

Optional Parameters:

Preserving Metadata

By default Kraken.io API will strip all the metadata found in an image to make the image file as small as it is possible, and in both lossy and lossless modes. Entries like EXIF, XMP and IPTC tags, colour profile information, etc. will be stripped altogether.

However there are situations when you might want to preserve some of the meta information contained in the image, for example, copyright notice or geotags. In order to preserve the most important meta entries add an additional preserve_meta array to your request with one or more of the following values:

`

Example integration:

``

External Storage

Kraken.io API allows you to store optimized images directly in your S3 bucket, Cloud Files container, Azure container or SoftLayer Object Storage container. With just a few additional parameters your optimized images will be pushed to your external storage in no time.

Amazon S3

Mandatory Parameters:

Optional Parameters:

The above parameters must be passed in a s3_store key:

``

The $data array will contain a kraked_url key pointing directly to the optimized file in your Amazon S3 account:

``

Rackspace Cloud Files

Mandatory Parameters:

Optional Parameters:

The above parameters must be passed in a cf_store key:

``

If your container is CDN-enabled, the optimization results will contain kraked_url which points directly to the optimized file location in your Cloud Files account, for example:

``

If your container is not CDN-enabled optimized file will be stored in your CloudFiles account anyways but the kraked_url will point to the optimized image URL in the Kraken.io API Storage:

``

Microsoft Azure

Mandatory Parameters:

Optional Parameters:

The above parameters must be passed in a azure_store key:

``

SoftLayer Object Storage

Mandatory Parameters:

Optional Parameters:

The above parameters must be passed in a sl_store object:

` Below you can find an example of a complete JSON request that usessl_store` to push optimized image into your SoftLayer Object Storage container. We will use url option to feed the API with a URL of image to be optimized:

``

If your SoftLayer container is CDN-enabled and you've passed "cdn_url": true parameter in your JSON request the optimization results will contain kraked_url which points directly to the optimized file location in your SoftLayer CDN, for example:

``

If your container is not CDN-enabled kraked_url will point to the optimized image URL in the Kraken.io API:

``

LICENSE - MIT

Copyright (c) 2013 - 2015 Nekkra UG

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.


All versions of kraken-php with dependencies

PHP Build Version
Package Version
Requires ext-curl Version *
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kraken-io/kraken-php contains the following files

Loading the files please wait ....