1.0.55 • Published 2 years ago

@titanium/imagefactory v1.0.55

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

👉    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 blobblob: Image to transform
  • Optionsdictionary: A dictionary specifying the options for the transformation
    • degreesint: 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 blobblob: Image to transform
  • Optionsdictionary: 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: qualityfloat: 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 blobblob: Image to transform
  • Optionsdictionary: A dictionary specifying the options for the transformation
    • borderSizeint: 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: qualityfloat: 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 blobblob: Image to transform
  • Optionsdictionary: A dictionary specifying the options for the transformation
    • borderSizeint: The size of the border (default: 1)
    • cornerRadiusint: 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: qualityfloat: 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 blobblob: Image to transform
  • Optionsdictionary: A dictionary specifying the options for the transformation
    • sizeint: The size of the thumbnail (default: 48)
    • borderSizeint: The size of the border (default: 1)
    • cornerRadiusint: The radius of the corner edges (default:0)
    • iOS: qualityint: 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: qualityfloat: 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: ditherboolean: 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 blobblob: Image to transform
  • Optionsdictionary: A dictionary specifying the options for the transformation
    • widthint: The width of the new image (default: image width)
    • heightint: The height of the new image (default: image height)
    • iOS: hiresboolean: Create a hires image (for Retina displays only)
    • iOS: qualityint: 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)
    • qualityfloat: 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 blobblob: Image to transform
  • Optionsdictionary: A dictionary specifying the options for the transformation
    • widthint: The width of the new image (default: image width)
    • heightint: The height of the new image (default: image height)
    • xint: The x-coordinate of the upper-left corner of the bounds (default: image center - width / 2)
    • yint: 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: qualityfloat: 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 blobblob: Image to transform
  • Transformdictionary: 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.
    • typeint: 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 blobblob: Image to compress
  • Compression Qualityfloat; 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

  • Scale images
  • Crop images
  • Compress images
  • Add alpha channel to images
  • 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.

1.0.55

2 years ago

1.0.54

2 years ago

1.0.53

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.40

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.49

2 years ago

1.0.51

2 years ago

1.0.50

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.52

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.8

3 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.1

5 years ago