Image is a built-in prototype that extends File. It is instantiated by passing either a MimePart Object (as submitted via a multipart/formdata form post) or File System path into the constructor.
Since they extend File, Image Objects have all the properties and methods that File Objects have. Below are the methods specific to Image Objects.
Contents |
Image.addThumbnail()
Description
Image.addThumbnail(image, accessname)
Adds a thumbnail as a child to this Image Object.
Parameters
- image (ImageObject) - The new image to save as a thumbnail.
- accessname (String) - The accessname the thumbnail will use.
Examples
Assuming we have an Image Object as the "image" variable:
var thumb = image.render({maxWidth:640, maxHeight:480});
image.addThumbnail(thumb, "thumb_640");
This thumbnail can now be accessed like this:
image.getThumbnail("thumb_640");
or just:
image.get("thumb_640");
Also See...
Image.getHeight()
Description
Image.getHeight()
Returns the height of the image.
Returns
(Number) - The height of the image.
Also See...
Image.getThumbnail()
Description
Image.getThumbnail(accessname)
Returns the specified thumbnail.
Parameters
- accessname (String) - Accessname of the thumbnail.
Returns
(ImageObject) - The specified thumbnail.
Also See...
Image.getWidth()
Description
Image.getWidth()
Returns the width of the image.
Returns
(Number) - The width of the image.
Also See...
Image.removeThumbnail()
Description
Image.removeThumbnail(thumbnail)
Removes the specified thumbnail.
Parameters
- thumbnail (ImageObject) - The thumbnail to remove.
Also See...
Image.render()
Description
Image.render(params)
Returns a new Image Object, with a transformed copy of the image, preserving the aspect ratio.
Parameters
- params (Object) - An Object with the following properties/values:
- maxWidth (Number) - The maximum width of the new image.
- maxHeight (Number) - The maximum height of the new image.
Returns (ImageObject) - The new Image Object.
Image.setRendered()
Description
Image.setRendered(rendered)
Sets a flag to tell whether or not this image has been rendered from another.
Parameters
- rendered (Boolean) - True if this image has been rendered from another.
Notes
This is set to true by default for thumbnails created using Image.addThumbnail().
