Image utilities for Titanium – native manipulation and control of JPEG compression
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Classes
UIImage
assets
documentation
example
hooks
imaging.xcodeproj
.gitignore
ComSpiirImaging_Prefix.pch
LICENSE
README.textile
README.titanium
build.py
clean
install
manifest
module.xcconfig
timodule.xml
titanium.xcconfig

README.textile

2013-07-10: The module is not in active development – but as far as I have heard, it works with version 3.3.1 and older of the SDK. Make sure to configure it before building (see below).

Imaging module for Titanium on iOS

This module adds native image manipulation methods and control of JPEG compression to Titanium.

It provides a subclass of TiBlob, ComSpiirImage, enriched with new methods and properties.

var blob = Ti.Filesystem.getFile('file.jpg').read();
var image = imaging.createImageFromBlob(blob);

As images are blobs, they can be used anywhere where Titanium expectes blobs.

Below are simple examples of use — check out example/app.js for more code.

Configuration

To get the module to build, you most likely need to adjust TITANIUM_SDK_VERSION and possibly also TITANIUM_SDK in titanium.xcconfig, to reflect the SDK you are building against.

Examples

Compression quality

By default, Titanium compresses JPEG images using 100% quality, which results in huge files. The Imaging module addresses this:

var blob = Ti.Filesystem.getFile('large.jpg').read();

var image = imaging.createImageFromBlob(blob);
image.compressionQuality = 0.1;

Titanium.Filesystem.getFile('small.jpg').write(image);

Scaling an image down

The method scaleImage scales an image down, retaining proportions:

var image = imaging.createImageFromBlob(blob);
var scaledImage = image.scaleImageDown(600, 400);