🪦 RIP Axway Amplify Titanium (2010 - 2022)
Titanium native mobile image transformation functions including the ability to scale, crop, and compress images.
- 📝 Description
- 🚀 Getting Started
- Accessing the @titanium/imagefactory Module
- ✨Features
- 📚Learn More
- 📣 Feedback
- ©️ Legal
Ti.ImageFactory provides a set of image transformation functions including the ability to scale, crop, and compress images. Additionally, this module offers the functionality of adding alpha channels and transparent borders. This is a repackaging of the compiled iOS and Android modules for Ti.ImageFactory to allow for installation via npm.
- Install
@titanium/imagefactory
in root of project
npm install @titanium/imagefactory
To access this module from JavaScript, you would do the following:
const imageFactory = require('@titanium/imagefactory');
Creates a new image by creating a copy of the given image that is rotated.
- Image blob[blob]: Image to transform
- Options[dictionary]: A dictionary specifying the options for the transformation
- degrees[int]: The degrees to rotate the image
Creates a new image by creating a copy of the given image, adding an alpha channel if it doesn't already have one.
- Image blob[blob]: Image to transform
- Options[dictionary]: A dictionary specifying the options for the transformation
- iOS: Currently there are no properties for this method -- specify an empty dictionary
- Android: format [int]: The output format of the image: either ImageFactory.PNG or ImageFactory.JPEG (default: ImageFactory.JPEG)
- Android: quality[float]: The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality). (default: 0.7)
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.
- Image blob[blob]: Image to transform
- Options[dictionary]: A dictionary specifying the options for the transformation
- borderSize[int]: The size of the border (default: 1)
- Android: format [int]: The output format of the image: either ImageFactory.PNG or ImageFactory.JPEG (default: ImageFactory.JPEG)
- Android: quality[float]: The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality). (default: 0.7)
Creates a new image by creating a copy of the given image with rounded corners.
- Image blob[blob]: Image to transform
- Options[dictionary]: A dictionary specifying the options for the transformation
- borderSize[int]: The size of the border (default: 1)
- cornerRadius[int]: The radius of the corner edges (default: 0)
- Android: format [int]: The output format of the image: either ImageFactory.PNG or ImageFactory.JPEG (default: ImageFactory.JPEG).
- Android: quality[float]: The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality). (default: 0.7).
Creates a new image by creating a copy of the given image that is squared to the thumbnail size.
- Image blob[blob]: Image to transform
- Options[dictionary]: A dictionary specifying the options for the transformation
- size[int]: The size of the thumbnail (default: 48)
- borderSize[int]: The size of the border (default: 1)
- cornerRadius[int]: The radius of the corner edges (default:0)
- iOS: quality[int]: The interpolation quality. One of the following constants (default: imagefactory.QUALITY_HIGH)
- imagefactory.QUALITY_DEFAULT
- imagefactory.QUALITY_NONE
- imagefactory.QUALITY_LOW
- imagefactory.QUALITY_MEDIUM
- imagefactory.QUALITY_HIGH
- Android: quality[float]: The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality). (default: 0.7)
- Android: dither[boolean]: Indicates if dithering should be applied while scaling. May provide better quality (default: true)
- Android: format [int]: The output format of the image: either ImageFactory.PNG or ImageFactory.JPEG (default: ImageFactory.JPEG)
Creates a new image by creating a copy of the given image that is rescaled to the specified size.
- Image blob[blob]: Image to transform
- Options[dictionary]: A dictionary specifying the options for the transformation
- width[int]: The width of the new image (default: image width)
- height[int]: The height of the new image (default: image height)
- iOS: hires[boolean]: Create a hires image (for Retina displays only)
- iOS: quality[int]: The interpolation quality. One of the following constants (default: imagefactory.QUALITY_HIGH)
- imagefactory.QUALITY_DEFAULT
- imagefactory.QUALITY_NONE
- imagefactory.QUALITY_LOW
- imagefactory.QUALITY_MEDIUM
- imagefactory.QUALITY_HIGH
- Android. format [int]: The output format of the image: either ImageFactory.PNG or ImageFactory.JPEG (default: ImageFactory.JPEG)
- quality[float]: The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality). (default: 0.7)
Creates a new image by creating a copy of the given image that is cropped to the specified bounds.
- Image blob[blob]: Image to transform
- Options[dictionary]: A dictionary specifying the options for the transformation
- width[int]: The width of the new image (default: image width)
- height[int]: The height of the new image (default: image height)
- x[int]: The x-coordinate of the upper-left corner of the bounds (default: image center - width / 2)
- y[int]: The y-coordinate of the upper-left corner of the bounds (default: image center - height / 2)
- Android: format [int]: The output format of the image: either ImageFactory.PNG or ImageFactory.JPEG (default: ImageFactory.JPEG)
- Android: quality[float]: The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality). (default: 0.7)
Creates a new image by applying a sequence of transformations to the image.
- Image blob[blob]: Image to transform
- Transform[dictionary]: A sequence of transform specifications. Transforms are listed as additional parameters to the function and are applied in the order specified. Each transform is a dictionary with the options described above for each transform along with an additional 'type' property included with each dictionary of transform options.
- type[int]: The identifier of the transform to apply. One of the following constants
- imagefactory.TRANSFORM_CROP
- imagefactory.TRANSFORM_RESIZE
- imagefactory.TRANSFORM_THUMBNAIL
- imagefactory.TRANSFORM_ROUNDEDCORNER
- imagefactory.TRANSFORM_TRANSPARENTBORDER
- imagefactory.TRANSFORM_ALPHA
- options as described in the above transforms
- type[int]: The identifier of the transform to apply. One of the following constants
Creates a new image by creating a copy of the given image and applying the specified compression quality.
- Image blob[blob]: Image to compress
- Compression Quality[float]; The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality). (default: 1.0)
iOS: ti.imagefactory 1.3.0
Android: ti.imagefactory 4.0.0
- Scale images
- Crop images
- Compress images
- Add alpha channel to images
- Add transparent borders to images
Have an idea or a comment? Join in the conversation here!
Modules are licensed under Apache 2.0 from https://github.com/appcelerator-modules/ti.imagefactory
Alloy is developed by Appcelerator and the community and is Copyright © 2012-Present by Appcelerator, Inc. All Rights Reserved.
Alloy is made available under the Apache Public License, version 2. See their license file for more information.
Appcelerator is a registered trademark of Appcelerator, Inc. Titanium is a registered trademark of Appcelerator, Inc. Please see the LEGAL information about using trademarks, privacy policy, terms of usage and other legal information at http://www.appcelerator.com/legal.