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/imagefactory

v1.0.55

Published

⭐ Axway Amplify module for image transformation - scale, crop, and compress images - for Appcelerator Titanium Mobile

Downloads

65

Readme

👉    A group of Axway employees, ex-Axway employees, and some developers from Titanium community have created a legal org and now officially decide all matters related to future of these products.

API FAQ:

 

Click to watch on Youtube

  ↑ Watch video on YouTube ↑

 

@titanium/imagefactory

@titanium/imagefactory Dependabot Status

Titanium native mobile image transformation functions including the ability to scale, crop, and compress images.

📝 Description

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.

🚀 Getting Started

  1. Install @titanium/imagefactory in root of project
npm install @titanium/imagefactory

Accessing the @titanium/imagefactory Module

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

const imageFactory = require('@titanium/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)

✨Features

iOS: ti.imagefactory 1.3.0 Android: ti.imagefactory 4.0.0

  • [x] Scale images
  • [x] Crop images
  • [x] Compress images
  • [x] Add alpha channel to images
  • [x] Add transparent borders to images

📚Learn More

📣 Feedback

Have an idea or a comment? Join in the conversation here!

©️ Legal

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.