npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@titanium-sdk/ti.imagefactory

v6.1.0

Published

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.

Downloads

4

Readme

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:

const 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: ImageFactory.JPEG, ImageFactory.PNG, ImageFactory.WEBP (default: ImageFactory.JPEG)
    • Android: quality[float]: The quality of the resulting JPEG or WebP 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: ImageFactory.JPEG, ImageFactory.PNG, ImageFactory.WEBP (default: ImageFactory.JPEG)
    • Android: quality[float]: The quality of the resulting JPEG or WebP 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: ImageFactory.JPEG, ImageFactory.PNG, ImageFactory.WEBP (default: ImageFactory.JPEG).
    • Android: quality[float]: The quality of the resulting JPEG or WebP 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 or WebP 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. (default: false)
    • Android: format [int]: The output format: ImageFactory.JPEG, ImageFactory.PNG, ImageFactory.WEBP (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 or WebP 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: ImageFactory.JPEG, ImageFactory.PNG, ImageFactory.WEBP (default: ImageFactory.JPEG)
    • Android: quality[float]: The quality of the resulting JPEG or WebP 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 [, format])

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 or WebP 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).
  • Android (optional): format [int]: The output format: ImageFactory.JPEG, ImageFactory.PNG, ImageFactory.WEBP (default: ImageFactory.JPEG)

compressToFile(blob, quality, fileUrl)

Compresses the given blob to an image file.

Arguments

  • Image blob[blob]: Image to write to file
  • Compression Quality[float]; The quality of the resulting JPEG or WebP 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).
  • fileUrl [string]: File path to write the image to. Supports extensions ".png", ".jpg", and ".jpeg". Android also supports ".webp".

Usage

See example.

License

Apache 2

Copyright

2011-present by Axway Appcelerator