# Io Reference

Graphics / Image / Image

|  | The Image object can read and draw images and provide the image data as a buffer. Example use:
    image = Image clone open("curly.png")
    image draw
    image scaleTo(image width / 2, image height / 2)
    image save("curly.tiff")
When loading an attempt will be made to convert the image into whichever of the following formats it is closest to: L8, LA8, RGB8, RGBA8. Currently supported formats include PNG(which supports alpha), JPG and TIFF.
|  | addAlpha Adds an opaque alpha component if the image is in RGB format and does not already contain one. Returns self. averageColor Returns the average RGB color of all pixels in the image. baselineHeight Returns the pixel height (relative to the bottom of the image) which first contains a non-white pixel or -1 if no baseline is found. bounds(cutoff) Returns an object continaing the bounds of the image. Cutoff is max bound color value for any color component. If it is negative, it is the min bound color value. componentCount Returns the number of color components in the receiver as a Number. crop(x, y, width, height) Crops the image to the specified values. Returns self. Raises an exception on error. data Returns a Buffer primitive containing the image data (loading it first if needed). Manipulating this data will affect what is drawn when the receiver's draw method is called. decodingHeightHint Returns the decoding height hint. decodingWidthHint Returns the decoding width hint. encodingQuality Returns the encodingQuality setting. error Returns a String containing the current error or nil if there is no error. flipX Flips the image on the horizonal plane (left/right mirror). Returns self. flipY Flips the image on the vertical plane (top/bottom mirror). Returns self. height Returns the image hieght. isL8 Returns true if the receiver is in L8 (8bit Luminance) format, false otherwise. isLA8 Returns true if the receiver is in LA8 (8bit Luminance-Alpha) format, false otherwise. isRGB8 Returns true if the receiver is in RGB8 format, false otherwise. isRGBA8 Returns true if the receiver is in RGBA8 format, false otherwise. open(optionalPathString) Sets the path to optionalPathString if provided and opens the image file. Returns self on success, Nil on failure. path Returns the image path. removeAlpha Removes the alpha component if the image contains one. Returns self. resizedTo(newWidth, newHeight) Scales the image up to newWidth x newHeight. Returns the newly scaled image. resizedTo(width, height) Returns a new image of the receiver resized to the given width and height. Raises an exception on error. save(optionalPathString) Sets the path to optionalPathString if provided and saves the image in the format specified by the path extension. Returns self on success, nil on failure. setDataWidthHeightComponentCount(aSequence, width, height, componentCount) Sets the image data and its parameters. Returns self. setDecodingHeightHint(width) Sets the decoding height hint. Returns self. setDecodingWidthHint(width) Sets the decoding width hint. Returns self. setEncodingQuality(aNumber) Sets the image encoding quality (range is 0.0 - 1.0, 1.0 with being the highest). setPath(aString) Sets the image path. Returns self. width Returns the image width.