JSImage
Overview
The JSImage
class provides a scripting interface for image manipulation, enabling operations like resizing, rotating, flipping, and metadata management. It integrates with the images plugin for streamlined handling of image files.
Functionality
The class supports image transformation, including flipping vertically or horizontally with flip(type)
and rotating by a specified number of degrees using rotate(degrees)
. Images can be resized while maintaining their aspect ratio through resize(width, height)
. Methods like getWidth()
and getHeight()
retrieve image dimensions.
For metadata, getMetaDataProperties()
lists available properties, while getMetaDataDescription(property)
and getMetaDataObject(property)
provide detailed information or the actual metadata object. The getContentType()
method fetches the MIME type of the image, and getData()
retrieves the image bytes for storage or further processing.
These features enable comprehensive control and management of image files in scripting environments.
For more details, please refer to the Images plugin section of this documentation.
Methods Summarized
Flips the image verticaly (type param=0) or horizontaly (type param=1).
Gets the contenttype (image/jpeg) of this image.
Gets the bytes of this image, so that they can be saved to disk or stored the database.
Gets the height of this image.
Gets the description of a metadata property from the image.
Gets the real object of a metadata property from the image.
Gets the available metadata properties from the image.
Gets the width of this image.
Resizes the image to the width/height given, keeping aspect ratio.
Rotates the image the number of degrees that is given.
Methods Detailed
flip(type)
Flips the image verticaly (type param=0) or horizontaly (type param=1). A new JSImage is returned.
Parameters
Number type ;
Returns: JSImage A new JSImage instance flipped vertically or horizontally, based on the type parameter.
Sample
getContentType()
Gets the contenttype (image/jpeg) of this image.
Returns: String The MIME type of the image, such as "image/jpeg" or "image/png", or null if unavailable.
Sample
getData()
Gets the bytes of this image, so that they can be saved to disk or stored the database.
Returns: Array The image data as a byte array for saving or processing.
Sample
getHeight()
Gets the height of this image.
Returns: Number The height of the image in pixels.
Sample
getMetaDataDescription(property)
Gets the description of a metadata property from the image. Currently only jpg is supported.
Parameters
String property ;
Returns: String The description of the specified metadata property, or null if not found.
Sample
getMetaDataObject(property)
Gets the real object of a metadata property from the image. Currently only jpg is supported.
Parameters
String property ;
Returns: Object The metadata object associated with the specified property, or null if not found.
Sample
getMetaDataProperties()
Gets the available metadata properties from the image. Currently only jpg is supported.
Returns: Array An array of metadata property names available in the image.
Sample
getWidth()
Gets the width of this image.
Returns: Number The width of the image in pixels.
Sample
resize(width, height)
Resizes the image to the width/height given, keeping aspect ratio. A new JSImage is returned.
Parameters
Returns: JSImage A new JSImage instance resized to the specified dimensions, or null if resizing fails.
Sample
rotate(degrees)
Rotates the image the number of degrees that is given. A new JSImage is returned.
Parameters
Number degrees ;
Returns: JSImage A new JSImage instance rotated by the specified degrees.
Sample
Last updated
Was this helpful?