class Image < Object (attribute methods)
mixes in Comparable

Table of Contents

attribute methods

attribute methods

background_color

image.background_color -> aString
image.background_color = aString or aPixel

Description

The image's background color. By default the background color is "white".

Arguments

Either a color name or a Pixel object.

Returns

A color name.

base_columns

image.base_columns -> anInteger

Description

The number of columns in the image before any transformations. Get-only.

base_filename

image.base_filename -> aString

Description

The image's original filename before any transformations. Get-only.

base_rows

image.base_rows -> anInteger

Description

The number of rows in the image before any transformations. Get-only.

blur

image.blur -> aFloat
image.blur = aFloat

Description

The blur factor to use when resizing. See resize.

border_color

image.border_color -> aString
image.border_color = aString or aPixel

Description

The image's border color. The default border color is "#dfdfdf" (gray).

Arguments

Either a color name or a Pixel object.

Returns

A color name.

bounding_box

bounding_box -> aRectangle

Description

The image's bounding box. The bounding box is the rectangle that encloses all the pixels not in the border color. Uses the current fuzz value. Get-only.

Returns

A Rectangle object.

Example

In this example, the bounding box is the gray square enclosing the blue circle. (The coordinates and red circles were added after the bounding box was computed.)

ex/bounding_box.rb

chromaticity

image.chromaticity -> aChromaticity
image.chromaticity = aChromaticity

Description

The red, green, blue, and white-point chromaticity values..

Arguments

A Chromaticity object.

Returns

A Chromaticity object.

class_type

image.class_type -> aClassType
image.class_type = aClassType

Description

The image's storage class. If DirectClass then the pixels contain valid RGB or CMYK colors. If PseudoClass then the image has a colormap referenced by the pixel's index member.

Arguments

A ClassType constant.

Returns

A ClassType constant.

clip_mask

image.clip_mask = anImage or anImageList or nil

Description

Associates a clip mask with the image. The clip mask must have the same dimensions as the image. Set any pixel component of the clip mask to TransparentOpacity to prevent that corresponding image pixel component from being updated. Set-only.

Arguments

If an imagelist, uses the current image as the clip mask. Assign nil to remove the clip mask.

color_profile

image.color_profile -> aString
image.color_profile = aString

Description

The ICC color profile.

Arguments

A color profile is represented as a string.

Returns

The current color profile, or nil if there is no profile.

colors

image.colors -> anInteger

Description

The number of colors in the colormap. Only meaningful for PseudoClass images. Get-only.

colorspace

image.colorspace -> aColorspace
image.colorspace = aColorspace

Description

Image pixel interpretation. If the colorspace is RGBColorspace the pixels are red, green, blue. If matte is true, then red, green, blue, and opacity. If it is CMYKColorspace, the pixels are cyan, yellow, magenta, black. Otherwise the colorspace is ignored.

Arguments

A Colorspace constant.

Returns

A Colorspace constant.

columns

image.columns -> anInteger

Description

The width of the image in pixels. Get-only.

compose

image.compose -> aCompositeOperator
image.compose = aCompositeOperator

Description

The image composite operator. The default is OverCompositeOp. See montage.

Arguments

A composite operator constant.

Returns

A composite operator constant.

compression

image.compression -> aCompressionType
image.compression = aCompressionType

Description

The image compression type. The default is the compression type of the specified image file.

Arguments

A CompressionType constant.

Returns

A CompressionType constant.

delay

image.delay -> anInteger
image.delay = anInteger

Description

Time in 1/100ths of a second which must expire before displaying the next image in an animated sequence. The default is 0.

Arguments

An integer value between 0 and 65535, inclusive.

Returns

The current delay value.

density

image.density -> aString
image.density = aString or aGeometry

Description

The vertical and horizontal resolution in pixels of the image. The default is "72x72".

Arguments

The density may be expressed either as a string or a Geometry object. If a string, it is in the form "XxY", or simply "X". If "Y" is omitted it is set to "X". To specify the density with a Geometry object, set the width attribute to the x resolution and the height argument to the y resolution. If height is nil, width will be used as the y resolution as well.

Returns

The image density represented as a string.

See also

Also see x_resolution and y_resolution.

depth

image.depth -> anInteger

Description

The image depth (8, 16, or 32). Get-only.

directory

image.directory -> aString

Description

Tile names from within an image montage. Only valid after calling montage or reading a MIFF file which contains a directory. Get-only.

Returns

A newline ("\n")-delimited list of the images in the montage.

dispose

image.dispose -> anInteger
image.dispose = aDisposeType

Description

GIF disposal method. This attribute is used to control how successive images are rendered (how the preceding image is disposed of) when creating a GIF animation.

Arguments

An integer corresponding to the disposal method.

Returns

A DisposeType constant.

endian

image.endian -> anEndianType
image.endian = anEndianType

Description

Get or set the endian attribute. (As best I can tell, only the TIFF format supports this attribute.)

Arguments

An EndianType value.

Returns

An EndianType value.

extract_info

image.extract_info -> aRectangle
image.extract_info = aRectangle

Description

Specify a rectangle within an image, or retrieve the rectangle specified when the image was constituted. See extract=.

Arguments

A Rectangle object.

Returns

A Rectangle object.

Note

This attribute replaces the tile_info attribute in releases of ImageMagick starting with 5.5.6. With releases of ImageMagick prior to 5.5.6, this attribute is a synonym for tile_info.

filename

image.filename -> aString

Description

The image filename. Get-only.

filesize

image.filesize -> anInteger

Description

The image filesize in bytes. Get-only.

filter

image.filter -> aFilterType
image.filter = aFilterType

Description

Filter to use when resizing image. The reduction filter employed has a significant effect on the time required to resize an image and the resulting quality. The default filter is Lanczos which has been shown to produce high quality results when reducing most images.

Arguments

A FilterType constant.

Returns

A FilterType constant.

format

image.format -> aString
image.format = aString

Description

The image encoding format. For example, "GIF" or "PNG". See formats.

Arguments

The format name.

Returns

The format name.

fuzz

image.fuzz -> aFloat
image.fuzz = aNumeric or aString

Description

Colors within this distance are considered equal. A number of algorithms search for a target color. By default the color must be exact. Use this [attribute] to match colors that are close to the target color in RGB space.

See opaque, texture_floodfill, and transparent.

Arguments

The argument may be a floating-point numeric value or a string in the form "NN%". In the second case, the argument is computed as a percentage of MaxRGB. For example, a value of '5%' sets fuzz to 0.05*MaxRGB.

Returns

A Float

gamma

image.gamma -> aFloat
image.gamma = aFloat

Description

Gamma level of the image. The same color image displayed on two different workstations may look different due to differences in the display monitor. Use gamma correction to adjust for this color difference.

geometry

image.geometry -> aString
image.geometry = aString or aGeometry

Description

Preferred size of the image when encoding.

Arguments

A geometry string or a Geometry object.

Returns

A geometry string.

image_type

image.image_type -> anImageType
image.image_type = anImageType

Description

The image type classification. For example, GrayscaleType. Don't confuse this attribute with the format, that is "GIF" or "JPG".

Arguments

An ImageType constant.

Returns

An ImageType constant.

interlace

image.interlace -> anInterlaceType
image.interlace = anInterlaceType

Description

The type of interlacing scheme (default NoInterlace). This option is used to specify the type of interlacing scheme for raw image formats such as RGB or YUV. NoInterlace means do not interlace, LineInterlace uses scanline interlacing, and PlaneInterlace uses plane interlacing. PartitionInterlace is like PlaneInterlace except the different planes are saved to individual files (e.g. image.R, image.G, and image.B). Use LineInterlace or PlaneInterlace to create an interlaced GIF or progressive JPEG image.

Arguments

An InterlaceType constant.

Returns

An InterlaceType constant.

iptc_profile

image.iptc_profile -> aString
image.iptc_profile = aString or nil

Description

IPTC profile. Specifications are available from the International Press Telecommunications Council for IPTC profiles.

Arguments

To remove an existing profile, assign nil to the attribute.

Returns

The current profile, or nil if the image has no IPTC profile.

matte

image.matte -> true or false
image.matte = true or false

Description

If true, honor the opacity values in the image pixels. See Pixel.

mean_error_per_pixel

image.mean_error_per_pixel -> aFloat

Description

The mean error per pixel computed when a image is color reduced. This parameter is only valid if the verbose argument to quantize[ImageList][Image] is set to true. Get-only.

mime_type

image.mime_type -> aString

Description

Returns the officially registered (or de facto) MIME media-type. If there is no registered media-type, returns "image/x-magick". Get-only.

montage

image.montage -> aString
image.montage = nil

Description

Tile size and offset within an image montage. Only valid for [images produced by montage.] The string is in the form of a geometry string.

Arguments

To release the montage string, set this attribute to nil.

normalized_mean_error

image.normalized_mean_error -> aFloat

Description

The normalized mean error computed when an image is color reduced. This parameter is only valid if the verbose argument to quantize[ImageList][Image] is set to true. Get-only.

normalized_maximum_error

image.normalized_maximum_error -> aFloat

Description

The normalized mean error per pixel computed when an image is color reduced. This parameter is only valid if the verbose argument to quantize[ImageList][Image] is set to true. Get-only.

number_colors

image.number_colors -> anInteger

Description

Number of unique colors in the image. Get-only.

offset

image.offset -> anInteger
image.offset = anInteger

Description

Number of initial bytes to skip over when reading raw image.

opacity

image.opacity = anInteger

Description

Attenuates the opacity channel of an image. If the image pixels are opaque, they are set to the specified opacity level. Otherwise, the pixel opacity values are blended with the supplied transparency value. Set-only.

Arguments

A number between 0 and MaxRGB. Higher numbers increase transparency.

orientation

image.orientation -> anOrientationType

Description

Returns the value of the Exif Orientation Tag.

Returns

One of the following OrientationType values:

Magick API

Available in ImageMagick 6.0.0.

Notes

See http://jpegclub.org/exif_orientation.html for more information about the Exif Orientation Tag.

page

image.page -> aRectangle
image.page = aRectangle

Description

When compositing, this attribute describes the position of this image with respect to the underlying image. See coalesce, flatten_images, and mosaic.

Arguments

A Rectangle object.

Returns

A Rectangle object.

quality

image.quality -> aFixnum

Description

For JPEG images, returns the Independent JPEG Group quality value. This number is a measurement of the amount of compression used when the image was saved. Lower numbers mean higher compression.

Returns

A number between 0-100.

Notes

For more information, see The JPEG image compression FAQ.

quantum_depth

image.quantum_depth -> anInteger

Description

The image depth to the nearest Quantum (8, 16, or 32). Get-only. Available in ImageMagick 6.0.0.

rendering_intent

image.rendering_intent -> aRenderingIntent
image.rendering_intent = aRenderingIntent

Description

The type of rendering intent.

Arguments

A RenderingIntent constant.

Returns

A RenderingIntent constant.

rows

image.rows -> anInteger

Description

The height of the image in pixels. Get-only.

scene

image.scene -> anInteger

Description

The scene number assigned to the image the last time the image was written to a multi-image image file. Don't confuse this attribute with ImageList's scene attribute, which denotes the image to which Image methods will be sent.

start_loop

image.start_loop -> true or false
image.start_loop = true or false

Description

Indicates the first image in an animation.

tile_info

image.tile_info -> aRectangle
image.tile_info = aRectangle

Description

Describes a tile within an image.  For example, if your image is 640x480 you may only want 320x256 with an offset of +128+64. It is used for raw formats such as RGB and CMYK as well as for TIFF.

This attribute is deprecated in ImageMagick 5.5.6 and later. Use extract_info instead.

Arguments

A Rectangle object.

Returns

A Rectangle object.

total_colors

image.total_colors -> anInteger

Description

The number of colors in the image after quantization. Set by quantize [ImageList][Image] if the verbose argument is true. Get-only.

units

image.units -> aResolutionType
image.units = aResolutionType

Description

Units of image resolution.

Arguments

A ResolutionType constant.

Returns

A ResolutionType constant.

See also

x_resolution, y_resolution

x_resolution

image.x_resolution -> aFloat
image.x_resolution = aFloat

Description

Horizontal resolution of the image.

See also

units

y_resolution

image.y_resolution -> aFloat
image.y_resolution = aFloat

Description

Vertical resolution of the image.

See also

units