Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): compress thread #336

Open
wants to merge 4 commits into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 64 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,30 @@ const ImageFactory = require('ti.imagefactory');

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

#### Arguments
##### 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
* object with:
* Image blob[blob]: Image to transform
* degrees[int]: The degrees to rotate the image
* success [function]: Method that will be called when the compressin is done. It will return `image` [blob].

### 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
##### 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)
* object with:
* Image blob[blob]: Image to transform
* 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)
* success [function]: Method that will be called when the compressin is done. It will return `image` [blob].

### 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
##### Arguments

* Image blob[blob]: Image to transform
* Options[dictionary]: A dictionary specifying the options for the transformation
Expand All @@ -55,7 +56,7 @@ Creates a new image by creating a copy of the given image, adding a transparent

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

#### Arguments
##### Arguments

* Image blob[blob]: Image to transform
* Options[dictionary]: A dictionary specifying the options for the transformation
Expand All @@ -68,63 +69,66 @@ Creates a new image by creating a copy of the given image with rounded corners.

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)
##### Arguments

* object with:
* Image blob[blob]: Image to transform
* 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)
* success [function]: Method that will be called when the compressin is done. It will return `image` [blob].

### 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)
##### Arguments

* object with:
* Image blob[blob]: Image to transform
* 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)
* success [function]: Method that will be called when the compressin is done. It will return `image` [blob].

### imageAsCropped(blob, options)

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

#### Arguments
##### 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)
* object with:
* Image blob[blob]: Image to transform
* 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)
* success [function]: Method that will be called when the compressin is done. It will return `image` [blob].

### imageTransform(blob, options)

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

#### Arguments
##### 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.
Expand All @@ -141,17 +145,19 @@ Creates a new image by applying a sequence of transformations to the image.

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

#### Arguments
##### 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)
* object with:
* blob [blob]: Image to compress
* 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).
* format [int]: The output format: ImageFactory.JPEG, ImageFactory.PNG, ImageFactory.WEBP (default: ImageFactory.JPEG)
* success [function]: Method that will be called when the compressin is done. It will return `image` [blob].

### compressToFile(blob, quality, fileUrl)

Compresses the given blob to an image file.

#### Arguments
##### 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).
Expand Down
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 5.1.0
version: 5.2.0
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86 x86_64
description: Image Factory
Expand Down
Loading