RMagick 2.9.0: RVG Reference: RVG::Image Class

###### RMagick 2.9.0 User's Guide and Reference

# class RVG::Image < Object

## class methods

### new

RVG::Image.new(raster_image, width=nil, height=nil, x=0, y=0) -> image

#### Description

Constructs a raster image object. The viewbox is defined by the image bounds. This method is usually called indirectly via the `image` method in the RVG, RVG::Group, or RVG::Pattern classes.

#### Arguments

raster_image
  A Magick::Image object.
width, height
  The width and height of the rectangle in which the image is placed.
x, y
  The x- and y-axis location of the rectangle in which the image is placed.

#### Example

See preserve_aspect_ratio

## attributes

### desc, desc=

img.desc -> string
img.desc = string

#### Description

Use the `desc` attribute to assign a text description to the image.

### metadata, metadata=

img.metadata -> string
img.metadata = string

#### Description

Use the `metadata` attribute to assign additional metadata to the image.

### title, title=

img.title -> string
img.title = string

#### Description

Use the `title` attribute to assign a title to the image.

## instance methods

### preserve_aspect_ratio

img.preserve_aspect_ratio(align, meet_or_slice='meet') -> self

#### Description

Use `preserve_aspect_ratio` to specify whether or not the image is stretched to fit the rectangle in which it is placed. If not, you can specify how to fit the image into the space.

#### Arguments

align
  When the value of the `meet_or_slice` argument is 'meet' or 'slice', this argument controls the placement of the image within the viewport. The `align` argument is the concatenation of an x-alignment and a y-alignment. The values are shown in these lists:

  ###### x-alignment

  xMin
    align the minimum x value of the image with the left corner of the viewport.
  xMid
    vertically center the image within the viewport.
  xMax
    align the maximum x value of the image with the right corner of the viewport.

  ###### y-alignment

  YMin
    align the minimum y value of the image with the top of the viewport.
  YMid
    horizontally center the image within the viewport.
  YMax
    align the maximum y value of the image with the bottom of the viewport
meet_or_slice
  This argument can have one of these three values:
  'none'
    The image is scaled as necessary so that it fits exactly within the viewport. The aspect ratio is not maintained.
  'meet'
    The image is scaled as necessary so that the larger dimension exactly fits the viewport. There may be some unused space in the viewport. The aspect ratio is maintained.
  'slice'
    The image is scaled as necessary so that the smaller dimension exactly fits the viewport. Some of the image in the larger dimension may be cut off. The aspect ratio is maintained.

#### Example

#### Returns

self

#### See Also

RVG#preserve_aspect_ratio