Giter Site home page Giter Site logo

miniman42 / ti.imagefactory Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ahmedmsayed/ti.imagefactory

0.0 2.0 0.0 872 KB

The ImageFactory Module for Appcelerator Titanium

License: Apache License 2.0

JavaScript 4.74% Java 10.85% Objective-C 20.27% Python 64.13%

ti.imagefactory's Introduction

Titanium ImageFactory Module

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.

Getting Started

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

Accessing the Ti.ImageFactory Module

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

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

Methods

imageWithRotation(blob, options)

Creates a new image by creating a copy of the given image that is rotated.

Arguments

  • Image blob[blob]: Image to transform
  • Options[dictionary]: A dictionary specifying the options for the transformation
    • degrees[int]: The degrees to rotate the image

imageWithAlpha(blob, options)

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

Arguments

  • 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)

imageWithTransparentBorder(blob, options)

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

  • 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)

imageWithRoundedCorner(blob, options)

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

Arguments

  • 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).

imageAsThumbnail(blob, options)

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

Arguments

  • 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)

imageAsResized(blob, options)

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

Arguments

  • 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)

imageAsCropped(blob, options)

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

Arguments

  • 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)

imageTransform(blob, options)

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

Arguments

  • 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

compress(blob, quality)

Creates a new image by creating a copy of the given image and applying the specified compression quality.

Arguments

  • 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)

Usage

See iOS example and Android example.

License

Apache 2

Copyright

2011-present by Axway Appcelerator

ti.imagefactory's People

Contributors

adesugbaa avatar ahmedmsayed avatar ashcoding avatar collinprice avatar hansemannn avatar ingo avatar jonalter avatar m1ga avatar miniman42 avatar muhammaddadu avatar pec1985 avatar sgtcoolguy avatar stephenfeather avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.