Some Image
and ImageList
methods,
such as read
and write
, accept an
"optional arguments" block in which you can set attributes that
modify the method's output. These attributes belong to the
Image::Info
class. The Image::Info
class exists only to accept optional arguments for those
Image
and ImageList
methods.
This page explains the methods defined in the
Image::Info
class. Generally, each
Image
or ImageList
method that uses
the Image::Info
class to get optional arguments
will only accept some of the attributes listed on this page,
that is, only those attributes that are meaningful for the
particular method. Any other attributes that you set are
ignored. Also, some attributes are only used by a subset of the
image formats. See the ×Magick documentation for more
information.
Remember, you do not ever need to create an
Image::Info
object. The object is created for you
before the optional arguments block is entered and destroyed
after the block is exited.
All the attributes in the Image::Info
class are
read/write. For simplicity, and because usually you only set
these attributes, this page only describes the setter version
of each attribute method.
self[format, key] = value -> self
Define a format-specific option. An alternative to define, below. Use this method to set options for reading or writing certain image formats. ImageMagick and GraphicsMagick support different options, and the list of supported options changes from release to release. For a list of the valid image formats, keys, and values, refer to the documentation for the -define option for the specific release of the library you're using.
to_s
. Use
nil
to set the key to a null value.self
self["tiff", "bits-per-sample"] = 2
SetImageOption (ImageMagick 6.0.0), AddDefinitions (GraphicsMagick 1.1)
self[format, key] -> value
Returns the value of the specified option for the specified format.
The value of the option. Always a string.
self["tiff", "bits-per-sample"] » 2
GetImageOption (ImageMagick 6.0.0), AccessDefinitions (GraphicsMagick 1.1)
self.define(format, key[, value])
Define a format-specific option. See []=, above.
to_s
. If
omitted, the key is simply defined to an null value.self
self.define("tiff", "bits-per-sample", 2)
SetImageOption (ImageMagick 6.0.0), AddDefinitions (GraphicsMagick 1.1)
self.undefine(format, key)
Delete an option definition set by []=
or define. This is not the same as
setting the option to a null value. The undefine
method removes the option name from the list of options for the
specified format.
self
self.undefine("tiff", "bits-per-sample")
self.antialias= true
or false
Control antialiasing of rendered
Postscript and Postscript or TrueType fonts. The default
is true
.
self.background_color= aPixel or aPixel
Set the image background color. The default is "white".
A color name or a aPixel.
self.border_color= aString or aPixel
Set the image border color. The default is "#dfdfdf".
A color name or a aPixel.
self.colorspace= aColorspaceType
self.compression= aCompressionType
Specify the type of compression used when writing the image. Only some image formats support compression. For those that do, only some compression types are supported. If you specify an compression type that is not supported, the default compression type (usually NoCompression) is used instead.
Some compression types support varying levels of
compression. See the quality
attribute.
The following table shows the image formats that support compression. For each format, the right-hand column shows the supported compression types. The default compression type is shown in bold.
Format | Compression Types |
---|---|
BMP | NoCompression, RLECompression |
DIB | NoCompression, RLECompression |
FPX | NoCompression, JPEGCompression |
GIF | LZWCompression (see Notes, below) |
JNG | NoCompression, JPEGCompression |
JP2 | JPEGCompression, LosslessJPEGCompression |
JPG | JPEGCompression, LosslessJPEGCompression |
MIFF | NoCompression, RLECompression |
MNG | NoCompression, JPEGCompression |
PALM | NoCompression, FaxCompression, RLECompression |
PDB | NoCompression, RLECompression |
NoCompression, JPEGCompression, LZWCompression, ZipCompression | |
PICT | NoCompression, JPEGCompression |
PNG | NoCompression, ZIPCompression |
PS | NoCompression, RLECompression |
PS2 | RLECompression, FaxCompression, JPEGCompression, LZWCompression, NoCompression |
PS3 | FaxCompression, JPEGCompression, LZWCompression, NoCompression, RLECompression, ZipCompression |
TIFF | NoCompression, FaxCompression, Group4Compression, JPEGCompression, LZWCompression, RLECompression, ZipCompression |
self.density= aString or aGeometry
Specify the vertical and horizontal resolution in pixels. The default density is "72.0x72.0". This attribute can be used when writing JBIG, PCL, PS, PS2, and PS3 format images.
This attribute can also be used to specify the width and height of HISTOGRRAM format images. For HISTOGRAM, the default is 256x200.
The argument can be either a string in the form "XxY" where
"X" is the horizontal resolution and "Y" is the vertical
resolution, or a Geometry
object where width
is the horizontal resolution
and height
is the vertical resolution.
self.depth= aNumber
Specify the image depth.
Either 8, 16, or 32. You can specify 16 and 32 only when ×Magick was compiled with a QuantumDepth that allows these depth values.
Use depth
to specify the depth of CMYK, GRAY,
RGB, RGBA, MAP, and XC format images. See also size
.
self.dither= true
or false
This attribute can be used when writing GIF images.
Apply Floyd/Steinberg error diffusion to the image. The basic strategy of dithering is to trade intensity resolution for spatial resolution by averaging the intensities of several neighboring pixels. Images which suffer from severe contouring when reducing colors can be improved with this option.
self.extract= aString or aGeometry
Specify a portion of an image to be extracted when the image is constituted. This attribute can be used to identify a subset of an image that is otherwise too large to keep in memory.
Either a geometry string or a Geometry object. For example:
self.extract = "200x200+100+100"
.
This attribute replaces the tile attribute, which is deprecated in ImageMagick 5.5.6 and later.
self.filename= aString
See capture.
self.font= aString
Set the text rendering font.
self.format= aString
self.fuzz= aNumeric or aString
Set the level of "fuzziness" for comparing pixels. By
default the pixels must be identical to be considered equal.
The larger the fuzz
value the more difference is
tolerated. See Image#fuzz.
The argument may be a 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.
self.image_type= anImageType
The image type classification. For example, GrayscaleType. Don't confuse this attribute with the format such as "GIF" or "JPG".
An ImageType constant.
self.interlace= anInterlaceType
[S]pecify 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. The default is NoInterlace.
self.matte_color= aString or aPixel
Set the image transparent color. The default is "#bdbdbd".
A color name or a aPixel.
self.monochrome= true
or false
Transform the image to black and white on input. Only the EPT, PDF, and PS formats respect this attribute.
self.number_scenes= anInteger
Used in conjunction with scene to specify the range of frames to be extracted when constituting a multi-frame image.
This attribute replaces the subrange
attribute, which is deprecated in ImageMagick 5.5.6 and later.
If number_scenes
is used with a version of
ImageMagick prior to 5.5.6, it is a synonym for the
subrange
attribute.
self.page= aString or aGeometry
Set the equivalent size of the Postscript page. The default is "612x792>".
A geometry string or a Geometry object.
self.quality= anInteger
Set the compression level to use with the
JPEGCompression
and ZipCompression
types. The value may range from 0 to 100, with 100 representing
the least compression. The default is 75. See Compressing image
files.
self.scene= anInteger
Used in conjunction with number_scenes to specify the range of frames to be extracted when constituting a multi-frame image.
This attribute replaces the subimage
attribute, which is deprecated in ImageMagick 5.5.6 and later.
If scene
is used with a version of ImageMagick
prior to 5.5.6, it is a synonym for the subimage
attribute.
self.server_name= aString
Set the X11 display to obtain fonts from.
self.size= aString or aGeometry
Set the width and height of the image when reading a built-in image format that does not have an inherent size, or when reading an image from a multi-resolution file format such as Photo CD, JBIG, or JPEG.
Use size
to specify the width and height of
images in the CMYK, DIB, EMF, GRAY, RGB, RGBA, UYVY, YUV, or XC
formats, the width and height of some builtin formats, or the
subimage size of PTIF-format images.
A geometry string or a Geometry object.
self.subimage= anInteger
Specify a base image of an image sequence in a multi-frame image.
This attribute is deprecated in ImageMagick 5.5.6 and later. Use the scene attribute instead.
self.subrange= anInteger
Specify the number of images relative to the base image. See subimage.
This attribute is deprecated in ImageMagick 5.5.6 and later. Use the number_scenes attribute instead.
self.tile= aString or aGeometry
Specify a portion of an image to be extracted when the image
is constituted. The argument is a geometry string. For example:
self.tile = "200x200+100+100"
. This attribute can
be used to identify a subset of an image that is otherwise too
large to keep in memory.
A geometry string or a Geometry object.
This attribute is deprecated in ImageMagick 5.5.6 and later. Use the extract attribute instead.
self.units= aResolutionType
self.view= aString
FlashPix viewing parameters.