Reference

# Module `image`

awesome image API

Author:

Julien Danjou <julien@danjou.info>

Copyright© 2008-2009 Julien Danjou

## Functions

add_signal (name, func) | Add a signal.
crop (x, y, width, height) | Crop an image to the given rectangle.
crop_and_scale (x, y, width, height, dest_width, dest_height, A) | Crop the image to the given rectangle and scales it.
draw_circle (x, y, width, height, fill, color) | Draw a circle in an image.
draw_line (x1, y2, x2, color) | Draw a line in an image.
draw_pixel (x, y, The) | Draw a pixel in an image.
draw_rectangle (x, y, width, height, fill, color) | Draw a rectangle in an image.
draw_rectangle_gradient (x, y, width, height, colors, angle) | Draw a rectangle in an image with gradient color.
emit_signal (name, ...) | Emit a signal.
insert (image, offset_x, ofsset_y, offset_h_up_right, offset_v_up_right, offset_h_low_left, offset_v_low_left, source_x, source_y, source_width, source_height) | Insert one image into another.
remove_signal (name, func) | Remove a signal.
rotate (angle) | Rotate an image with specified angle radians and return a new image.
rotate (angle) | Rotate an image with specified angle radians and return a new image.
save (path) | Saves the image to the given path.

## Tables

image | Image objects.

## Functions

add_signal (name, func)
  Add a signal.

  ### Parameters

  - name: A signal name.
  - func: A function to call when the signal is emitted.
crop (x, y, width, height)
  Crop an image to the given rectangle.

  ### Parameters

  - x: The top left x coordinate of the rectangle.
  - y: The top left y coordinate of the rectangle.
  - width: The width of the rectangle.
  - height: The height of the rectangle.

  ### Return value:

  A cropped image.
crop_and_scale (x, y, width, height, dest_width, dest_height, A)
  Crop the image to the given rectangle and scales it.

  ### Parameters

  - x: The top left x coordinate of the source rectangle.
  - y: The top left y coordinate of the source rectangle.
  - width: The width of the source rectangle.
  - height: The height of the source rectangle.
  - dest_width: The width of the destination rectangle.
  - dest_height: The height of the destination rectangle.
  - A: cropped image.
draw_circle (x, y, width, height, fill, color)
  Draw a circle in an image.

  ### Parameters

  - x: The x coordinate of the center of the circle.
  - y: The y coordinate of the center of the circle.
  - width: The horizontal amplitude.
  - height: The vertical amplitude.
  - fill: True if the circle should be filled, false otherwise.
  - color: The color to draw the circle with.
draw_line (x1, y2, x2, color)
  Draw a line in an image.

  ### Parameters

  - x1: The x1 coordinate of the line to draw.
  - y2: The y2 coordinate of the line to draw.
  - x2: The x2 coordinate of the line to draw.
  - color: The color to draw the line in.
draw_pixel (x, y, The)
  Draw a pixel in an image.

  ### Parameters

  - x: The x coordinate of the pixel to draw.
  - y: The y coordinate of the pixel to draw.
  - The: color to draw the pixel in.
draw_rectangle (x, y, width, height, fill, color)
  Draw a rectangle in an image.

  ### Parameters

  - x: The x coordinate of the rectangles top left corner.
  - y: The y coordinate of the rectangles top left corner.
  - width: The width of the rectangle.
  - height: The height of the rectangle.
  - fill: True to fill the rectangle, false otherwise.
  - color: The color to draw the rectangle with.
draw_rectangle_gradient (x, y, width, height, colors, angle)
  Draw a rectangle in an image with gradient color.

  ### Parameters

  - x: The x coordinate of the rectangles top left corner.
  - y: The y coordinate of the rectangles top left corner.
  - width: The width of the rectangle.
  - height: The height of the rectangle.
  - colors: A table with the color to draw the rectangle. You can specified the color distance from the previous one by setting t[color] = distance.
  - angle: The angle of the gradient.
emit_signal (name, ...)
  Emit a signal.

  ### Parameters

  - name: A signal name.
  - ...: Various arguments, optional.
insert (image, offset_x, ofsset_y, offset_h_up_right, offset_v_up_right, offset_h_low_left, offset_v_low_left, source_x, source_y, source_width, source_height)
  Insert one image into another.

  ### Parameters

  - image: The image to insert.
  - offset_x: The x offset of the image to insert (optional).
  - ofsset_y: The y offset of the image to insert (optional).
  - offset_h_up_right: The horizontal offset of the upper right image corner (optional).
  - offset_v_up_right: The vertical offset of the upper right image corner (optional).
  - offset_h_low_left: The horizontal offset of the lower left image corner (optional).
  - offset_v_low_left: The vertical offset of the lower left image corner (optional).
  - source_x: The x coordinate of the source rectangle (optional).
  - source_y: The y coordinate of the source rectangle (optional).
  - source_width: The width of the source rectangle (optional).
  - source_height: The height of the source rectangle (optional).
remove_signal (name, func)
  Remove a signal.

  ### Parameters

  - name: A signal name.
  - func: A function to remove.
rotate (angle)
  Rotate an image with specified angle radians and return a new image.

  ### Parameters

  - angle: The angle in radians.

  ### Return value:

  A rotated image.
rotate (angle)
  Rotate an image with specified angle radians and return a new image.

  ### Parameters

  - angle: The angle in radians.

  ### Return value:

  A rotated image.
save (path)
  Saves the image to the given path. The file extension (e.g. .png or .jpg) will affect the output format.

  ### Parameters

  - path: An image path.

## Tables

image
  Image objects. Fields
  - width: The image width. Immutable.
  - height: The image height. Immutable.
  - alpha: Boolean indicating if the image alpha channel is present.