Ti.ImageFactory Module

Description

This module provides a set of image transformation functions.

Getting Started

View the Using Titanium Modules document for instructions on getting started with using this module in your application.

Note that there may be two versions of this module available to you, one for use with pre-1.8.0.1 SDKs and one for use with 1.8.0.1 or newer. In your tiapp.xml file, make sure that you specify the version of the module that corresponds to the version of Titanium Mobile SDK that you are targeting. For Appcelerator modules, specify the 1.X version of the module if building for versions of Titanium Mobile SDK prior to 1.8.0.1 and specify the 2.X version of the module if building for versions of Titanium Mobile SDK 1.8.0.1 or newer.

Accessing the Ti.ImageFactory Module

To access this module from JavaScript, you would do the following:

var ImageFactory = require('ti.imagefactory');

Functions

imageWithAlpha

Creates a new image by creating a copy of the given image, adding an alpha channel if it doesn't already have one.

Arguments

imageWithTransparentBorder

Creates a new image by creating a copy of the given image, adding a transparent border of the given size around its edges. The size of the image will be expanded by the specified border size.

Arguments

imageWithRoundedCorner

Creates a new image by creating a copy of the given image with rounded corners.

Arguments

imageAsThumbnail

Creates a new image by creating a copy of the given image that is squared to the thumbnail size.

Arguments

imageAsResized

Creates a new image by creating a copy of the given image that is rescaled to the specified size.

Arguments

imageAsCropped

Creates a new image by creating a copy of the given image that is cropped to the specified bounds.

Arguments

imageTransform

Creates a new image by applying a sequence of transformations to the image.

Arguments

compress

Creates a new image by creating a copy of the given image and applying the specified compression quality. Returns a JPEG, as PNG does not support compression.

Arguments

compressToFile(image, compression, fileURL)

Compresses the provided image straight out to a file. This method is quite a bit lighter on memory usage than the others. Returns a JPEG, as PNG does not support compression.

Arguments

Constants

JPEG

Pass as the value for the "format" key to the methods above, and the resulting image will be formatted as a JPEG. Lossy, so it supports compression. (Image quality may degrade when using this format.)

PNG

Pass as the value for the "format" key to the methods above, and the resulting image will be formatted as a PNG. Lossless, so it does NOT support compression. (Image sizes may increase when using this format.)

TRANSFORM_NONE

TRANSFORM_CROP

TRANSFORM_RESIZE

TRANSFORM_THUMBNAIL

TRANSFORM_ROUNDEDCORNER

TRANSFORM_TRANSPARENTBORDER

TRANSFORM_ALPHA

Usage

See example.

Author

Jeff English

Module History

View the change log for this module.

Feedback and Support

Please direct all questions, feedback, and concerns to info@appcelerator.com.

License

Copyright(c) 2010-2011 by Appcelerator, Inc. All Rights Reserved. Please see the LICENSE file included in the distribution for further details.