Class: Magick::Image
- Inherits:
-
Object
- Object
- Magick::Image
- Includes:
- Comparable
- Defined in:
- lib/rmagick_internal.rb,
ext/RMagick/rmmain.c
Overview
Ruby-level Magick::Image methods
Defined Under Namespace
Classes: DrawOptions, Info, PolaroidOptions, View
Class Method Summary collapse
-
._load(str) ⇒ Magic::Image
Implement marshalling.
-
.capture(*args) ⇒ Magick::Image
Reads an image from an X window.
-
.constitute(width_arg, height_arg, map_arg, pixels_arg) ⇒ Magick::Image
Creates an Image from the supplied pixel data.
-
.from_blob(blob_arg) ⇒ Array<Magick::Image>
Convert direct to memory image formats from string data.
-
.ping(file_arg) ⇒ Array<Magick::Image>
Returns all the properties of an image or image sequence except for the pixels.
-
.read(file_arg) ⇒ Array<Magick::Image>
Call ReadImage.
-
.read_inline(content) ⇒ Array<Magick::Image>
Read a Base64-encoded image.
Instance Method Summary collapse
-
#<=>(other) ⇒ -1, ...
Compare two images.
-
#[](key_arg) ⇒ String
Returns the value of the image property identified by key.
-
#[]=(key_arg, attr_arg) ⇒ Magick::Image
Sets the value of an image property.
-
#_dump(depth) ⇒ String
Implement marshalling.
-
#adaptive_blur(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Adaptively blurs the image by blurring more intensely near image edges and less intensely far from edges.
-
#adaptive_blur_channel(*args) ⇒ Magick::Image
The same as #adaptive_blur except only the specified channels are blurred.
-
#adaptive_resize(*args) ⇒ Magick::Image
Resizes the image with data dependent triangulation.
-
#adaptive_sharpen(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Adaptively sharpens the image by sharpening more intensely near image edges and less intensely far from edges.
-
#adaptive_sharpen_channel(*args) ⇒ Magick::Image
The same as #adaptive_sharpen except only the specified channels are sharpened.
-
#adaptive_threshold(width = 3, height = 3, offset = 0) ⇒ Magick::Image
Selects an individual threshold for each pixel based on the range of intensity values in its local neighborhood.
-
#add_compose_mask(mask) ⇒ Object
Associates a mask with an image that will be used as the destination image in a #composite operation.
-
#add_noise(noise) ⇒ Magick::Image
Adds random noise to the image.
-
#add_noise_channel(*args) ⇒ Magick::Image
Adds random noise to the specified channel or channels in the image.
-
#add_profile(name) ⇒ Magick::Image
Adds an ICC (a.k.a. ICM), IPTC, or generic profile.
-
#affine_transform(affine) ⇒ Magick::Image
Transform an image as dictated by the affine matrix argument.
-
#alpha(*args) ⇒ Object
Get/Set alpha channel.
-
#alpha? ⇒ Boolean
Determine whether the image’s alpha channel is activated.
-
#annotate(draw, width, height, x, y, text, &block) ⇒ Object
Provide an alternate version of Draw#annotate, for folks who want to find it in this class.
-
#auto_gamma_channel(*args) ⇒ Magick::Image
“Automagically” adjust the gamma level of an image.
-
#auto_level_channel(*args) ⇒ Magick::Image
“Automagically” adjust the color levels of an image.
-
#auto_orient ⇒ Magick::Image
Rotates or flips the image based on the image’s EXIF orientation tag.
-
#auto_orient! ⇒ Magick::Image?
Rotates or flips the image based on the image’s EXIF orientation tag.
-
#background_color ⇒ String
Return the name of the background color as a String.
-
#background_color=(color) ⇒ Magick::Pixel, String
Set the the background color to the specified color spec.
-
#base_columns ⇒ Numeric
Return the number of rows (before transformations).
-
#base_filename ⇒ String
Return the image filename (before transformations).
-
#base_rows ⇒ Numeric
Return the number of rows (before transformations).
-
#bias ⇒ Float
Get image bias (used when convolving an image).
-
#bias=(pct) ⇒ Float, String
Set image bias (used when convolving an image).
-
#bilevel_channel(*args) ⇒ Magick::Image
Changes the value of individual pixels based on the intensity of each pixel channel.
-
#black_point_compensation ⇒ Boolean
Return current black point compensation attribute.
-
#black_point_compensation=(arg) ⇒ Boolean
Set black point compensation attribute.
-
#black_threshold(*args) ⇒ Numeric
Forces all pixels below the threshold into black while leaving all pixels above the threshold unchanged.
-
#blend(overlay, src_percent, dst_percent, gravity = Magick::NorthWestGravity, x_offset = 0, y_offset = 0) ⇒ Magick::Image
Adds the overlay image to the target image according to src_percent and dst_percent.
-
#blue_shift(factor = 1.5) ⇒ Magick::Image
Simulate a scene at nighttime in the moonlight.
-
#blur_channel(*args) ⇒ Magick::Image
Blurs the specified channel.
-
#blur_image(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Blur the image.
-
#border(width, height, color) ⇒ Magick::Image
Surrounds the image with a border of the specified width, height, and named color.
-
#border!(width, height, color) ⇒ Object
Surrounds the image with a border of the specified width, height, and named color.
-
#border_color ⇒ String
Return the name of the border color as a String.
-
#border_color=(color) ⇒ Magick::Pixel, String
Set the the border color.
-
#bounding_box ⇒ Magick::Rectangle
Returns the bounding box of an image canvas.
-
#change_geometry(geom_arg) {|column, row, image| ... } ⇒ Object
This method supports resizing a method by specifying constraints.
-
#change_geometry!(geom_arg) {|column, row, image| ... } ⇒ Object
This method supports resizing a method by specifying constraints.
-
#changed? ⇒ Boolean
Return true if any pixel in the image has been altered since the image was constituted.
-
#channel(channel_arg) ⇒ Magick::Image
Extract a channel from the image.
-
#channel_compare(*args) ⇒ Array
Compare one or more channels in two images and returns the specified distortion metric and a comparison image.
-
#channel_depth(*args) ⇒ Numeric
Returns the maximum depth for the specified channel or channels.
- #channel_entropy(*args) ⇒ Object
-
#channel_extrema(*args) ⇒ Array<Numeric>
Returns the minimum and maximum intensity values for the specified channel or channels.
-
#channel_mean(*args) ⇒ Array<Float>
Returns the mean and standard deviation values for the specified channel or channels.
-
#charcoal(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Return a new image that is a copy of the input image with the edges highlighted.
-
#check_destroyed ⇒ nil
Raises DestroyedImageError if the image has been destroyed.
-
#chop(x, y, width, height) ⇒ Magick::Image
Remove a region of an image and collapses the image to occupy the removed portion.
-
#chromaticity ⇒ Magick::Chromaticity
Return the red, green, blue, and white-point chromaticity values as a Chromaticity.
-
#chromaticity=(chroma) ⇒ Magick::Chromaticity
Set the red, green, blue, and white-point chromaticity values from a Chromaticity.
-
#class_type ⇒ Magick::ClassType
Return the image’s storage class (a.k.a. storage type, class type).
-
#class_type=(new_class_type) ⇒ Magick::ClassType
Change the image’s storage class.
-
#clone ⇒ Magick::Image
Same as #dup except the frozen state of the original is propagated to the new copy.
-
#clut_channel(*args) ⇒ Magick::Image
Replace the channel values in the target image with a lookup of its replacement value in an LUT gradient image.
-
#color_fill_to_border(x, y, fill) ⇒ Object
Set all pixels that are neighbors of x,y and are not the border color to the fill color.
-
#color_flood_fill(target_color, fill_color, xv, yv, method) ⇒ Magick::Image
Change the color value of any pixel that matches target_color and is an immediate neighbor.
-
#color_floodfill(x, y, fill) ⇒ Object
Set all pixels that have the same color as the pixel at x,y and are neighbors to the fill color.
-
#color_histogram ⇒ Hash
Computes the number of times each unique color appears in the image.
-
#color_point(x, y, fill) ⇒ Object
Set the color at x,y.
-
#color_profile ⇒ String?
Return the ICC color profile as a String.
-
#color_profile=(profile) ⇒ String
Set the ICC color profile.
-
#color_reset!(fill) ⇒ Object
Set all pixels to the fill color.
-
#colorize(*args) ⇒ Magick::Image
Blend the fill color specified by “target” with each pixel in the image.
-
#colormap(*args) ⇒ String
Return the color in the colormap at the specified index.
-
#colors ⇒ Numeric
Get the number of colors in the colormap.
-
#colorspace ⇒ Magick::ColorspaceType
Return the Image pixel interpretation.
-
#colorspace=(colorspace) ⇒ Magick::ColorspaceType
Set the image’s colorspace.
-
#columns ⇒ Numeric
Get image columns.
-
#compare_channel(*args) ⇒ Array
Compare one or more channels in two images and returns the specified distortion metric and a comparison image.
-
#compose ⇒ Magick::CompositeOperator
Return the composite operator attribute.
-
#compose=(compose_arg) ⇒ Magick::CompositeOperator
Set the composite operator attribute.
-
#composite(*args) ⇒ Magick::Image
Composites src onto dest using the specified composite operator.
-
#composite!(*args) ⇒ Magick::Image
Composites src onto dest using the specified composite operator.
-
#composite_affine(source, affine_matrix) ⇒ Magick::Image
Composite the source over the destination image as dictated by the affine transform.
-
#composite_channel(*args) ⇒ Magick::Image
Composite the source over the destination image channel as dictated by the affine transform.
-
#composite_channel!(*args) ⇒ Magick::Image
Composite the source over the destination image channel as dictated by the affine transform.
-
#composite_mathematics(*args) ⇒ Magick::Image
Merge the source and destination images according to the formula a*Sc*Dc + b*Sc + c*Dc + d where Sc is the source pixel and Dc is the destination pixel.
-
#composite_tiled(*args) ⇒ Magick::Image
Composites multiple copies of the source image across and down the image, producing the same results as ImageMagick’s composite command with the -tile option.
-
#composite_tiled!(*args) ⇒ Magick::Image
Composites multiple copies of the source image across and down the image, producing the same results as ImageMagick’s composite command with the -tile option.
-
#compress_colormap! ⇒ Magick::Image
Removes duplicate or unused entries in the colormap.
-
#compression ⇒ Magick::CompressionType
Get the compression attribute.
-
#compression=(compression) ⇒ Magick::CompressionType
Set the compression attribute.
-
#contrast(sharpen = false) ⇒ Magick::Image
Enhance the intensity differences between the lighter and darker elements of the image.
-
#contrast_stretch_channel(*args) ⇒ Magick::Image
This method is a simple image enhancement technique that attempts to improve the contrast in an image by ‘stretching’ the range of intensity values it contains to span a desired range of values.
-
#convolve(order_arg, kernel_arg) ⇒ Magick::Image
Apply a custom convolution kernel to the image.
-
#convolve_channel(*args) ⇒ Magick::Image
Applies a custom convolution kernel to the specified channel or channels in the image.
-
#copy ⇒ Magick::Image
Alias for #dup.
-
#crop(*args) ⇒ Magick::Image
Extract a region of the image defined by width, height, x, y.
-
#crop!(*args) ⇒ Magick::Image
Extract a region of the image defined by width, height, x, y.
-
#cur_image ⇒ Object
Used by ImageList methods - see ImageList#cur_image.
-
#cycle_colormap(amount) ⇒ Magick::Image
Displaces the colormap by a given number of positions.
-
#decipher(passphrase) ⇒ Magick::Image
Decipher an enciphered image.
-
#define(artifact, value) ⇒ String
Associates makes a copy of the given string arguments and inserts it into the artifact tree.
-
#delay ⇒ Numeric
Get the Number of ticks which must expire before displaying the next image in an animated sequence.
-
#delay=(val) ⇒ Numeric
Set the Number of ticks which must expire before displaying the next image in an animated sequence.
-
#delete_compose_mask ⇒ Magick::Image
Delete the image composite mask.
-
#delete_profile(name) ⇒ Magick::Image
Deletes the specified profile.
-
#density ⇒ String
Get the vertical and horizontal resolution in pixels of the image.
-
#density=(density_arg) ⇒ String, Magick::Geometry
Set the vertical and horizontal resolution in pixels of the image.
-
#depth ⇒ Numeric
Return the image depth (8, 16 or 32).
-
#deskew(threshold = 0.40, auto_crop_width = nil) ⇒ Magick::Image
Straightens an image.
-
#despeckle ⇒ Magick::Image
Reduce the speckle noise in an image while preserving the edges of the original image.
-
#destroy! ⇒ Magick::Image
Free all the memory associated with an image.
-
#destroyed? ⇒ Boolean
Return true if the image has been destroyed, false otherwise.
-
#difference(other) ⇒ Array<Float>
Compares two images and computes statistics about their difference.
-
#directory ⇒ String
Get image directory.
-
#dispatch(x, y, columns, rows, map, float = false) ⇒ Array<Numeric>
Extract pixel data from the image and returns it as an array of pixels.
-
#displace(displacement_map, x_amp, y_amp = x_amp, gravity = Magick::NorthWestGravity, x_offset = 0, y_offset = 0) ⇒ Magick::Image
Uses displacement_map to move color from img to the output image.
-
#display ⇒ Magick::Image
(also: #__display__)
Display the image to an X window screen.
-
#dispose ⇒ Magick::DisposeType
Return the dispose attribute as a DisposeType enum.
-
#dispose=(dispose) ⇒ Magick::DisposeType
Set the dispose attribute.
-
#dissolve(overlay, src_percent, dst_percent = -1.0, gravity = Magick::NorthWestGravity, x_offset = 0, y_offset = 0) ⇒ Magick::Image
Composites the overlay image into the target image.
-
#distort(*args) ⇒ Magick::Image
Distort an image using the specified distortion type and its required arguments.
-
#distortion_channel(*args) ⇒ Float
Compares one or more image channels of an image to a reconstructed image and returns the specified distortion metric.
-
#dup ⇒ Magick::Image
Duplicates a image.
-
#each_iptc_dataset ⇒ Object
Iterate over IPTC record number:dataset tags, yield for each non-nil dataset.
-
#each_pixel ⇒ Object
Thanks to Russell Norris!.
-
#each_profile {|name, val| ... } ⇒ Object
Calls block once for each profile in the image, passing the profile name and value as parameters.
-
#edge(radius = 0.0) ⇒ Magick::Image
Find edges in an image.
-
#emboss(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Adds a 3-dimensional effect.
-
#encipher(passphrase) ⇒ Magick::Image
Encipher an image.
-
#endian ⇒ Magick::EndianType
Return endian option for images that support it.
-
#endian=(type) ⇒ Magick::EndianType
Set endian option for images that support it.
-
#enhance ⇒ Magick::Image
Apply a digital filter that improves the quality of a noisy image.
-
#equalize ⇒ Magick::Image
Apply a histogram equalization to the image.
-
#equalize_channel(*args) ⇒ Magick::Image
Applies a histogram equalization to the image.
-
#erase! ⇒ Magick::Image
Reset the image to the background color.
-
#excerpt(x, y, width, height) ⇒ Magick::Image
This method is very similar to crop.
-
#excerpt!(x, y, width, height) ⇒ Magick::Image
In-place form of #excerpt.
-
#export_pixels(x = 0, y = 0, cols = self.columns, rows = self.rows, map = "RGB") ⇒ Array<Numeric>
Extracts the pixel data from the specified rectangle and returns it as an array of Integer values.
-
#export_pixels_to_str(x = 0, y = 0, cols = self.columns, rows = self.rows, map = "RGB", type = Magick::CharPixel) ⇒ String
Extracts the pixel data from the specified rectangle and returns it as a string.
-
#extent(width, height, x = 0, y = 0) ⇒ Magick::Image
If width or height is greater than the target image’s width or height, extends the width and height of the target image to the specified values.
-
#extract_info ⇒ Magick::Rectangle
The extract_info attribute reader.
-
#extract_info=(rect) ⇒ Magick::Rectangle
Set the extract_info attribute.
-
#filename ⇒ String
Get image filename.
-
#filesize ⇒ Numeric
Return the image file size.
-
#filter ⇒ Magick::FilterType
Get filter type.
-
#filter=(filter) ⇒ Magick::FilterType
Set filter type.
-
#find_similar_region(target, x = 0, y = 0) ⇒ Array<Numeric>?
This interesting method searches for a rectangle in the image that is similar to the target.
-
#flip ⇒ Magick::Image
Create a vertical mirror image by reflecting the pixels around the central x-axis.
-
#flip! ⇒ Magick::Image
Create a vertical mirror image by reflecting the pixels around the central x-axis.
-
#flop ⇒ Magick::Image
Create a horizonal mirror image by reflecting the pixels around the central y-axis.
-
#flop! ⇒ Magick::Image
Create a horizonal mirror image by reflecting the pixels around the central y-axis.
-
#format ⇒ String?
Return the image encoding format.
-
#format=(magick) ⇒ String
Set the image encoding format.
-
#frame(width = self.columns+25*2, height = self.rows+25*2, x = 25, y = 25, inner_bevel = 6, outer_bevel = 6, color = self.matte_color) ⇒ Magick::Image
Add a simulated three-dimensional border around the image.
-
#function_channel(*args) ⇒ Magick::Image
Set the function on a channel.
-
#fuzz ⇒ Float
Get the number of algorithms search for a target color.
-
#fuzz=(fuzz) ⇒ String, Float
Set the number of algorithms search for a target color.
-
#fx(*args) ⇒ Magick::Image
Apply fx on the image.
-
#gamma ⇒ Float
Get the gamma level of the image.
-
#gamma=(val) ⇒ Float
Set the gamma level of the image.
-
#gamma_channel(*args) ⇒ Magick::Image
Apply gamma to a channel.
-
#gamma_correct(red_gamma, green_gamma = red_gamma, blue_gamma = green_gamma) ⇒ Magick::Image
gamma-correct an image.
-
#gaussian_blur(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Blur the image.
-
#gaussian_blur_channel(*args) ⇒ Magick::Image
Blur the image on a channel.
-
#geometry ⇒ String
Get the preferred size of the image when encoding.
-
#geometry=(geometry) ⇒ String
Set the preferred size of the image when encoding.
-
#get_exif_by_entry(*entry) ⇒ Object
Retrieve EXIF data by entry or all.
-
#get_exif_by_number(*tag) ⇒ Object
Retrieve EXIF data by tag number or all tag/value pairs.
-
#get_iptc_dataset(ds) ⇒ Object
Retrieve IPTC information by record number:dataset tag constant defined in Magick::IPTC, above.
-
#get_pixels(x_arg, y_arg, cols_arg, rows_arg) ⇒ Array<Magick::Pixel>
Gets the pixels from the specified rectangle within the image.
-
#gravity ⇒ Magick::GravityType
Get the direction that the image gravitates within the composite.
-
#gravity=(gravity) ⇒ Magick::GravityType
Set the direction that the image gravitates within the composite.
-
#gray? ⇒ Boolean
Return true if all the pixels in the image have the same red, green, and blue intensities.
-
#grey? ⇒ Boolean
Return true if all the pixels in the image have the same red, green, and blue intensities.
-
#histogram? ⇒ Boolean
Return true if has 1024 unique colors or less.
-
#image_type ⇒ Magick::ImageType
Get the image type classification.
-
#image_type=(image_type) ⇒ Magick::ImageType
Set the image type classification.
-
#implode(amount = 0.50) ⇒ Magick::Image
Implode the image by the specified percentage.
-
#store_pixels(x, y, columns, rows, map, pixels, type = Magick::CharPixel) ⇒ Magick::Image
Store image pixel data from an array.
-
#initialize(cols, rows, fill = nil) ⇒ Magick::Image
constructor
Initialize a new Image object If the fill argument is omitted, fill with background color.
-
#initialize_copy(orig) ⇒ Magick::Image
Initialize copy, clone, dup.
-
#inspect ⇒ String
Override Object#inspect - return a string description of the image.
-
#interlace ⇒ Magick::InterlaceType
Get the type of interlacing scheme (default NoInterlace).
-
#interlace=(interlace) ⇒ Magick::InterlaceType
Set the type of interlacing scheme.
-
#iptc_profile ⇒ String?
Return the IPTC profile as a String.
-
#iptc_profile=(profile) ⇒ String
Set the IPTC profile.
-
#iterations ⇒ Object
These are undocumented methods.
-
#iterations=(val) ⇒ Object
do not document! Only used by Image#iterations=.
-
#level(black_point = 0.0, white_point = nil, gamma = nil) ⇒ Object
(Thanks to Al Evans for the suggestion.).
-
#level2(black_point = 0.0, white_point = Magick::QuantumRange, gamma = 1.0) ⇒ Magick::Image
Adjusts the levels of an image by scaling the colors falling between specified white and black points to the full available quantum range.
-
#level_channel(aChannelType, black = 0.0, white = 1.0, gamma = Magick::QuantumRange) ⇒ Magick::Image
Similar to #level2 but applies to a single channel only.
-
#level_colors(*args) ⇒ Magick::Image
When invert is true, black and white will be mapped to the black_color and white_color colors, compressing all other colors linearly.
-
#levelize_channel(*args) ⇒ Magick::Image
Maps black and white to the specified points.
-
#linear_stretch(black_point, white_point = pixels-black_point) ⇒ Magick::Image
Linear with saturation stretch.
-
#liquid_rescale(columns, rows, delta_x = 0.0, rigidity = 0.0) ⇒ Magick::Image
Rescale image with seam carving.
-
#magnify ⇒ Magick::Image
Scale an image proportionally to twice its size.
-
#magnify! ⇒ Magick::Image
Scale an image proportionally to twice its size.
-
#marshal_dump ⇒ Array<String>
Support Marshal.dump.
-
#marshal_load(ary) ⇒ Object
Support Marshal.load.
-
#mask(*args) ⇒ Magick::Image
Get/Sets an image clip mask created from the specified mask image.
-
#matte_color ⇒ String
Return the matte color.
-
#matte_color=(color) ⇒ Magick::Pixel, String
Set the matte color.
-
#matte_fill_to_border(x, y) ⇒ Object
Make transparent any neighbor pixel that is not the border color.
-
#Image ⇒ Magick::Image
Makes transparent all the pixels that are the same color as the pixel at x, y, and are neighbors.
-
#matte_floodfill(x, y) ⇒ Object
Make transparent any pixel that matches the color of the pixel at (x,y) and is a neighbor.
-
#matte_point(x, y) ⇒ Object
Make the pixel at (x,y) transparent.
-
#matte_replace(x, y) ⇒ Object
Make transparent all pixels that are the same color as the pixel at (x, y).
-
#matte_reset! ⇒ Object
Make all pixels transparent.
-
#mean_error_per_pixel ⇒ Float
Get the mean error per pixel computed when a image is color reduced.
-
#median_filter(radius = 0.0) ⇒ Magick::Image
Apply a digital filter that improves the quality of a noisy image.
-
#mime_type ⇒ String?
Return the officially registered (or de facto) MIME media-type corresponding to the image format.
-
#minify ⇒ Magick::Image
Scale an image proportionally to half its size.
-
#minify! ⇒ Magick::Image
Scale an image proportionally to half its size.
-
#modulate(brightness = 1.0, saturation = 1.0, hue = 1.0) ⇒ Magick::Image
Changes the brightness, saturation, and hue.
-
#monitor=(monitor) ⇒ Proc
deprecated
Deprecated.
Magick::Image#monitor= is deprecated. This method will be removed in RMagick 5.0.
-
#monochrome? ⇒ Boolean
Return true if all the pixels in the image have the same red, green, and blue intensities and the intensity is either 0 or QuantumRange.
-
#montage ⇒ String
Tile size and offset within an image montage.
-
#morphology(method_v, iterations, kernel_v) ⇒ Magick::Image
Apply a user supplied kernel to the image according to the given mophology method.
-
#morphology_channel(channel_v, method_v, iterations, kernel_v) ⇒ Magick::Image
Apply a user supplied kernel to the image channel according to the given mophology method.
-
#motion_blur(radius = 0.0, sigma = 1.0, angle = 0.0) ⇒ Magick::Image
Simulate motion blur.
-
#negate(grayscale = false) ⇒ Magick::Image
Negate the colors in the reference image.
-
#negate_channel(*args) ⇒ Magick::Image
Negate the colors on a particular channel.
-
#normalize ⇒ Magick::Image
Enhance the contrast of a color image by adjusting the pixels color to span the entire range of colors available.
-
#normalize_channel(channel = Magick::AllChannels) ⇒ Magick::Image
Enhances the contrast of a color image by adjusting the pixel color to span the entire range of colors available.
-
#normalized_maximum_error ⇒ Float
Get The normalized maximum error per pixel computed when an image is color reduced.
-
#normalized_mean_error ⇒ Float
Get the normalized mean error per pixel computed when an image is color reduced.
-
#number_colors ⇒ Numeric
Return the number of unique colors in the image.
-
#offset ⇒ Number
Get the number of bytes to skip over when reading raw image.
-
#offset=(val) ⇒ Number
Set the number of bytes to skip over when reading raw image.
-
#oil_paint(radius = 3.0) ⇒ Magick::Image
Apply a special effect filter that simulates an oil painting.
-
#opaque(target, fill) ⇒ Magick::Image
Change any pixel that matches target with the color defined by fill.
-
#opaque? ⇒ Boolean
Returns true if all of the pixels in the receiver have an opacity value of OpaqueOpacity.
-
#opaque_channel(*args) ⇒ Magick::Image
Changes all pixels having the target color to the fill color.
-
#ordered_dither(threshold_map = '2x2') ⇒ Magick::Image
Dithers the image to a predefined pattern.
-
#orientation ⇒ Magick::OrientationType
Get the value of the Exif Orientation Tag.
-
#orientation=(orientation) ⇒ Magick::OrientationType
Set the orientation attribute.
-
#page ⇒ Magick::Rectang
The page attribute getter.
-
#page=(rect) ⇒ Magick::Rectang
The page attribute setter.
-
#paint_transparent(target, invert, fuzz, alpha: Magick::TransparentAlpha) ⇒ Magick::Image
Changes the opacity value of all the pixels that match color to the value specified by opacity.
-
#palette? ⇒ Boolean
Return true if the image is PseudoClass and has 256 unique colors or less.
-
#pixel_color(*args) ⇒ Object
Get/set the color of the pixel at x, y.
-
#pixel_interpolation_method ⇒ Magick::PixelInterpolateMethod
Get the “interpolate” field.
-
#pixel_interpolation_method=(method) ⇒ Magick::PixelInterpolateMethod
Set the “interpolate” field.
-
#polaroid(*args) ⇒ Magick::Image
Produce an image that looks like a Polaroid instant picture.
-
#posterize(levels = 4, dither = false) ⇒ Object
Reduces the image to a limited number of colors for a “poster” effect.
-
#preview(preview) ⇒ Magick::Image
Creates an image that contains 9 small versions of the receiver image.
-
#profile!(name, profile) ⇒ Magick::Image
Set the image profile.
-
#properties ⇒ Object
If called with an associated block, properties runs the block once for each property defined for the image.
-
#quality ⇒ Numeric
Get image quality.
-
#quantize(number_colors = 256, colorspace = Magick::RGBColorspace, dither = true, tree_depth = 0, measure_error = false) ⇒ Magick::Image
Analyzes the colors within a reference image and chooses a fixed number of colors to represent the image.
-
#quantum_depth ⇒ Numeric
Return the image depth to the nearest Quantum (8, 16, or 32).
-
#quantum_operator(*args) ⇒ Magick::Image
Performs the requested integer arithmetic operation on the selected channel of the image.
-
#radial_blur(angle_obj) ⇒ Magick::Image
Applies a radial blur to the image.
-
#radial_blur_channel(*args) ⇒ Magick::Image
Applies a radial blur to the selected image channels.
-
#raise(width = 6, height = 6, raised = true) ⇒ Magick::Image
Create a simulated three-dimensional button-like effect by lightening and darkening the edges of the image.
-
#random_threshold_channel(*args) ⇒ Magick::Image
Changes the value of individual pixels based on the intensity of each pixel compared to a random threshold.
-
#recolor(color_matrix) ⇒ Magick::Image
Use this method to translate, scale, shear, or rotate image colors.
-
#reduce_noise(radius) ⇒ Magick::Image
Smooth the contours of an image while still preserving edge information.
-
#remap(remap_image, dither_method = Magick::RiemersmaDitherMethod) ⇒ Object
(also: #affinity)
Reduce the number of colors in img to the colors used by remap_image.
-
#rendering_intent ⇒ Magick::RenderingIntent
Get the type of rendering intent.
-
#rendering_intent=(ri) ⇒ Magick::RenderingIntent
Set the type of rendering intent..
-
#resample(x_resolution = 72.0, y_resolution = 72.0, filter = self.filter, blur = self.blur) ⇒ Magick
Resample image to specified horizontal resolution, vertical resolution, filter and blur factor.
-
#resample!(x_resolution = 72.0, y_resolution = 72.0, filter = self.filter, blur = self.blur) ⇒ Magick
Resample image to specified horizontal resolution, vertical resolution, filter and blur factor.
-
#resize(*args) ⇒ Magick::Image
Scale an image to the desired dimensions using the specified filter and blur factor.
-
#resize!(*args) ⇒ Magick::Image
Scale an image to the desired dimensions using the specified filter and blur factor.
-
#resize_to_fill(ncols, nrows = nil, gravity = CenterGravity) ⇒ Object
(also: #crop_resized)
Force an image to exact dimensions without changing the aspect ratio.
- #resize_to_fill!(ncols, nrows = nil, gravity = CenterGravity) ⇒ Object (also: #crop_resized!)
-
#resize_to_fit(cols, rows = nil) ⇒ Object
Convenience method to resize retaining the aspect ratio.
- #resize_to_fit!(cols, rows = nil) ⇒ Object
-
#roll(x_offset, y_offset) ⇒ Magick::Image
Offset an image as defined by x_offset and y_offset.
-
#rotate(*args) ⇒ Magick::Image
Rotate the receiver by the specified angle.
-
#rotate!(*args) ⇒ Magick::Image
Rotate the image.
-
#rows ⇒ Numeric
Return image rows.
-
#sample(*args) ⇒ Magick::Image
Scale an image to the desired dimensions with pixel sampling.
-
#sample!(*args) ⇒ Magick::Image
Scale an image to the desired dimensions with pixel sampling.
-
#scale(*args) ⇒ Magick::Image
Change the size of an image to the given dimensions.
-
#scale!(*args) ⇒ Magick::Image
Change the size of an image to the given dimensions.
-
#scene ⇒ Numeric
Return the scene number assigned to the image the last time the image was written to a multi-image image file.
-
#segment(colorspace = Magick::RGBColorspace, cluster_threshold = 1.0, smoothing_threshold = 1.5, verbose = false) ⇒ Magick::Image
Segments an image by analyzing the histograms of the color components and identifying units that are homogeneous with the fuzzy c-means technique.
-
#selective_blur_channel(*args) ⇒ Magick::Image
Selectively blur pixels within a contrast threshold.
-
#separate(*args) ⇒ Magick::ImageList
Constructs a grayscale image for each channel specified.
-
#sepiatone(threshold = Magick::QuantumRange) ⇒ Magick::Image
Applies a special effect to the image, similar to the effect achieved in a photo darkroom by sepia toning.
-
#set_channel_depth(channel_arg, depth) ⇒ Object
Sets the depth of the image channel.
-
#shade(shading = false, azimuth = 30.0, elevation = 30.0) ⇒ Magick::Image
Shine a distant light on an image to create a three-dimensional effect.
-
#Image ⇒ Magick::Image
Call ShadowImage.
-
#sharpen(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Sharpen an image.
-
#sharpen_channel(*args) ⇒ Magick::Image
Sharpen image on a channel.
-
#shave(width, height) ⇒ Magick::Image
Shave pixels from the image edges, leaving a rectangle of the specified width & height in the center.
-
#shave!(width, height) ⇒ Magick::Image
Shave pixels from the image edges, leaving a rectangle of the specified width & height in the center.
-
#shear(x_shear, y_shear) ⇒ Magick::Image
Shearing slides one edge of an image along the X or Y axis, creating a parallelogram.
-
#sigmoidal_contrast_channel(*args) ⇒ Magick::Image
Adjusts the contrast of an image channel with a non-linear sigmoidal contrast algorithm.
-
#signature ⇒ String?
Compute a message digest from an image pixel stream with an implementation of the NIST SHA-256 Message Digest algorithm.
-
#sketch(radius = 0.0, sigma = 1.0, angle = 0.0) ⇒ Magick::Image
Simulates a pencil sketch.
-
#solarize(threshold = 50.0) ⇒ Object
Apply a special effect to the image, similar to the effect achieved in a photo darkroom by selectively exposing areas of photo sensitive paper to light.
-
#sparse_color(*args) ⇒ Magick::Image
Fills the image with the specified color or colors, starting at the x,y coordinates associated with the color and using the specified interpolation method.
-
#splice(x, y, width, height, color = self.background_color) ⇒ Magick::Image
Splice a solid color into the part of the image specified by the x, y, width, and height arguments.
-
#spread(radius = 3.0) ⇒ Magick::Image
Randomly displace each pixel in a block defined by “radius”.
-
#start_loop ⇒ Boolean
Get the Boolean value that indicates the first image in an animation.
-
#start_loop=(val) ⇒ Boolean
Set the Boolean value that indicates the first image in an animation.
-
#stegano(watermark_image, offset) ⇒ Magick::Image
Hides a digital watermark in the receiver.
-
#stereo(offset_image_arg) ⇒ Magick::Image
Combine two images and produces a single image that is the composite of a left and right image of a stereo pair.
-
#store_pixels(x_arg, y_arg, cols_arg, rows_arg, new_pixels) ⇒ Magick::Image
Replace the pixels in the specified rectangle with the pixels in the pixels array.
-
#strip! ⇒ Magick::Image
Strips an image of all profiles and comments.
-
#swirl(degrees_obj) ⇒ Magick::Image
Swirl the pixels about the center of the image, where degrees indicates the sweep of the arc through which each pixel is moved.
-
#texture_fill_to_border(x, y, texture) ⇒ Object
Replace neighboring pixels to border color with texture pixels.
-
#texture_flood_fill(color_obj, texture_obj, x_obj, y_obj, method_obj) ⇒ Magick::Image
Emulates Magick++‘s floodFillTexture.
-
#texture_floodfill(x, y, texture) ⇒ Object
Replace matching neighboring pixels with texture pixels.
-
#threshold(threshold_obj) ⇒ Magick::Image
Change the value of individual pixels based on the intensity of each pixel compared to threshold.
-
#thumbnail(*args) ⇒ Magick::Image
The thumbnail method is a fast resizing method suitable for use when the size of the resulting image is < 10% of the original.
-
#thumbnail!(*args) ⇒ Magick::Image
The thumbnail method is a fast resizing method suitable for use when the size of the resulting image is < 10% of the original.
-
#ticks_per_second ⇒ Numeric
Get the number of ticks per second.
-
#ticks_per_second=(tps) ⇒ Numeric
Set the number of ticks per second.
-
#tint(tint, red_alpha, green_alpha = red_alpha, blue_alpha = red_alpha, alpha_alpha = 1.0) ⇒ Object
Applies a color vector to each pixel in the image.
-
#to_blob ⇒ String
Return a “blob” (a String) from the image.
-
#to_color(pixel_arg) ⇒ String
Return a color name for the color intensity specified by the Magick::Pixel argument.
-
#total_colors ⇒ Numeric
Alias for #number_colors.
-
#total_ink_density ⇒ Float
Return the total ink density for a CMYK image.
-
#transparent(color, alpha: Magick::TransparentAlpha) ⇒ Magick::Image
Changes the opacity value of all the pixels that match color to the value specified by opacity.
-
#transparent_chroma(low, high, invert, alpha: Magick::TransparentAlpha) ⇒ Magick::Image
Changes the opacity value associated with any pixel between low and high to the value defined by opacity.
-
#transparent_color ⇒ String
Return the name of the transparent color as a String.
-
#transparent_color=(color) ⇒ Magick::Pixel, String
Set the the transparent color to the specified color spec.
-
#transpose ⇒ Magick::Image
Creates a horizontal mirror image by reflecting the pixels around the central y-axis while rotating them by 90 degrees.
-
#transpose! ⇒ Magick::Image
Creates a horizontal mirror image by reflecting the pixels around the central y-axis while rotating them by 90 degrees.
-
#transverse ⇒ Magick::Image
Creates a vertical mirror image by reflecting the pixels around the central x-axis while rotating them by 270 degrees.
-
#transverse! ⇒ Magick::Image
Creates a vertical mirror image by reflecting the pixels around the central x-axis while rotating them by 270 degrees In-place form of #transverse.
-
#trim(reset = false) ⇒ Magick::Image
Removes the edges that are exactly the same color as the corner pixels.
-
#trim!(reset = false) ⇒ Magick::Image
Removes the edges that are exactly the same color as the corner pixels.
-
#undefine(artifact) ⇒ Magick::Image
Removes an artifact from the image and returns its value.
-
#unique_colors ⇒ Magick::Image
Constructs a new image with one pixel for each unique color in the image.
-
#units ⇒ Magick::ResolutionType
Get the units of image resolution.
-
#units=(restype) ⇒ Magick::ResolutionType
Set the units of image resolution.
-
#unsharp_mask(radius = 0.0, sigma = 1.0, amount = 1.0, threshold = 0.05) ⇒ Magick::Image
Sharpen an image.
-
#unsharp_mask_channel(*args) ⇒ Magick::Image
Sharpen an image.
-
#view(x, y, width, height) ⇒ Object
Construct a view.
-
#vignette(horz_radius = self.columns*0.1+0.5, vert_radius = self.rows*0.1+0.5, radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Soften the edges of an image.
-
#virtual_pixel_method ⇒ Magick::VirtualPixelMethod
Get the “virtual pixels” behave.
-
#virtual_pixel_method=(method) ⇒ Magick::VirtualPixelMethod
Specify how “virtual pixels” behave.
-
#watermark(*args) ⇒ Magick::Image
Composites a watermark image on the target image using the Modulate composite operator.
-
#wave(amplitude = 25.0, wavelength = 150.0) ⇒ Magick::Image
Create a “ripple” effect in the image by shifting the pixels vertically along a sine wave whose amplitude and wavelength is specified by the given parameters.
-
#wet_floor(initial = 0.5, rate = 1.0) ⇒ Magick::Image
Creates a “wet floor” reflection.
-
#white_threshold(red, green, blue, alpha: alpha) ⇒ Magick::Image
Forces all pixels above the threshold into white while leaving all pixels below the threshold unchanged.
-
#write(file) ⇒ Magick::Image
Write the image to the file.
-
#x_resolution ⇒ Float
Get the horizontal resolution of the image.
-
#x_resolution=(val) ⇒ Float
Set the horizontal resolution of the image.
-
#y_resolution ⇒ Float
Get the vertical resolution of the image.
-
#y_resolution=(val) ⇒ Float
Set the vertical resolution of the image.
Constructor Details
#initialize(cols, rows, fill = nil) ⇒ Magick::Image
Initialize a new Image object If the fill argument is omitted, fill with background color.
9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 |
# File 'ext/RMagick/rmimage.c', line 9460 VALUE Image_initialize(int argc, VALUE *argv, VALUE self) { VALUE fill = Qnil; Info *info; VALUE info_obj; Image *image; unsigned long cols, rows; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif switch (argc) { case 3: fill = argv[2]; case 2: rows = NUM2ULONG(argv[1]); cols = NUM2ULONG(argv[0]); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc); break; } // Create a new Info object to use when creating this image. info_obj = rm_info_new(); Data_Get_Struct(info_obj, Info, info); image = rm_acquire_image(info); if (!image) { rb_raise(rb_eNoMemError, "not enough memory to continue"); } rm_set_user_artifact(image, info); // NOW store a real image in the image object. UPDATE_DATA_PTR(self, image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); SetImageExtent(image, cols, rows, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else SetImageExtent(image, cols, rows); #endif // If the caller did not supply a fill argument, call SetImageBackgroundColor // to fill the image using the background color. The background color can // be set by it when creating the Info parm block. if (NIL_P(fill)) { #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); SetImageBackgroundColor(image, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else SetImageBackgroundColor(image); #endif } // fillobj.fill(self) else { rb_funcall(fill, rm_ID_fill, 1, self); } RB_GC_GUARD(fill); RB_GC_GUARD(info_obj); return self; } |
Class Method Details
._load(str) ⇒ Magic::Image
Implement marshalling.
8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 |
# File 'ext/RMagick/rmimage.c', line 8472 VALUE Image__load(VALUE class ATTRIBUTE_UNUSED, VALUE str) { Image *image; ImageInfo *info; DumpedImage mi; ExceptionInfo *exception; char *blob; long length; blob = rm_str2cstr(str, &length); // Must be as least as big as the 1st 4 fields in DumpedImage if (length <= (long)(sizeof(DumpedImage)-MaxTextExtent)) { rb_raise(rb_eTypeError, "image is invalid or corrupted (too short)"); } // Retrieve & validate the image format from the header portion mi.id = ((DumpedImage *)blob)->id; if (mi.id != DUMPED_IMAGE_ID) { rb_raise(rb_eTypeError, "image is invalid or corrupted (invalid header)"); } mi.mj = ((DumpedImage *)blob)->mj; mi.mi = ((DumpedImage *)blob)->mi; if ( mi.mj != DUMPED_IMAGE_MAJOR_VERS || mi.mi > DUMPED_IMAGE_MINOR_VERS) { rb_raise(rb_eTypeError, "incompatible image format (can't be read)\n" "\tformat version %d.%d required; %d.%d given", DUMPED_IMAGE_MAJOR_VERS, DUMPED_IMAGE_MINOR_VERS, mi.mj, mi.mi); } mi.len = ((DumpedImage *)blob)->len; // Must be bigger than the header if (length <= (long)(mi.len+sizeof(DumpedImage)-MaxTextExtent)) { rb_raise(rb_eTypeError, "image is invalid or corrupted (too short)"); } info = CloneImageInfo(NULL); memcpy(info->magick, ((DumpedImage *)blob)->magick, mi.len); info->magick[mi.len] = '\0'; exception = AcquireExceptionInfo(); blob += offsetof(DumpedImage, magick) + mi.len; length -= offsetof(DumpedImage, magick) + mi.len; image = BlobToImage(info, blob, (size_t) length, exception); DestroyImageInfo(info); rm_check_exception(exception, image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(image); } |
.capture(silent = false, frame = false, descend = false, screen = false, borders = false) ⇒ Magick::Image .capture(silent = false, frame = false, descend = false, screen = false, borders = false) {|Magick::Image::Info| ... } ⇒ Magick::Image
Reads an image from an X window. Unless you identify a window to capture via the optional arguments block, when capture is invoked the cursor will turn into a cross. Click the cursor on the window to be captured.
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 |
# File 'ext/RMagick/rmimage.c', line 2001 VALUE Image_capture(int argc, VALUE *argv, VALUE self ATTRIBUTE_UNUSED) { Image *new_image; ImageInfo *image_info; VALUE info_obj; XImportInfo ximage_info; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif XGetImportInfo(&ximage_info); switch (argc) { case 5: ximage_info.borders = (MagickBooleanType)RTEST(argv[4]); case 4: ximage_info.screen = (MagickBooleanType)RTEST(argv[3]); case 3: ximage_info.descend = (MagickBooleanType)RTEST(argv[2]); case 2: ximage_info.frame = (MagickBooleanType)RTEST(argv[1]); case 1: ximage_info.silent = (MagickBooleanType)RTEST(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 5)", argc); break; } // Get optional parms. // Set info->filename = "root", window ID number or window name, // or nothing to do an interactive capture // Set info->server_name to the server name // Also info->colorspace, depth, dither, interlace, type info_obj = rm_info_new(); Data_Get_Struct(info_obj, Info, image_info); // If an error occurs, IM will call our error handler and we raise an exception. #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); new_image = XImportImage(image_info, &ximage_info, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else new_image = XImportImage(image_info, &ximage_info); rm_check_image_exception(new_image, DestroyOnError); #endif rm_ensure_result(new_image); rm_set_user_artifact(new_image, image_info); RB_GC_GUARD(info_obj); return rm_image_new(new_image); } |
.constitute(width_arg, height_arg, map_arg, pixels_arg) ⇒ Magick::Image
Creates an Image from the supplied pixel data. The pixel data must be in scanline order, top-to-bottom. The pixel data is an array of either all Fixed or all Float elements. If Fixed, the elements must be in the range [0..QuantumRange]. If Float, the elements must be normalized [0..1]. The “map” argument reflects the expected ordering of the pixel array. It can be any combination or order of R = red, G = green, B = blue, A = alpha, C = cyan, Y = yellow, M = magenta, K = black, or I = intensity (for grayscale).
The pixel array must have width X height X strlen(map) elements.
4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 |
# File 'ext/RMagick/rmimage.c', line 4035 VALUE Image_constitute(VALUE class ATTRIBUTE_UNUSED, VALUE width_arg, VALUE height_arg, VALUE map_arg, VALUE pixels_arg) { Image *new_image; VALUE pixel, pixel0; long width, height, x, npixels, map_l; char *map; volatile union { double *f; Quantum *i; void *v; } pixels; VALUE pixel_class; StorageType stg_type; ExceptionInfo *exception; // rb_Array converts objects that are not Arrays to Arrays if possible, // and raises TypeError if it can't. pixels_arg = rb_Array(pixels_arg); width = NUM2LONG(width_arg); height = NUM2LONG(height_arg); if (width <= 0 || height <= 0) { rb_raise(rb_eArgError, "width and height must be greater than zero"); } map = rm_str2cstr(map_arg, &map_l); npixels = width * height * map_l; if (RARRAY_LEN(pixels_arg) != npixels) { rb_raise(rb_eArgError, "wrong number of array elements (%ld for %ld)", RARRAY_LEN(pixels_arg), npixels); } // Inspect the first element in the pixels array to determine the expected // type of all the elements. Allocate the pixel buffer. pixel0 = rb_ary_entry(pixels_arg, 0); if (rb_obj_is_kind_of(pixel0, rb_cFloat) == Qtrue) { pixels.f = ALLOC_N(double, npixels); stg_type = DoublePixel; pixel_class = rb_cFloat; } else if (rb_obj_is_kind_of(pixel0, rb_cInteger) == Qtrue) { pixels.i = ALLOC_N(Quantum, npixels); stg_type = QuantumPixel; pixel_class = rb_cInteger; } else { rb_raise(rb_eTypeError, "element 0 in pixel array is %s, must be numeric", rb_class2name(CLASS_OF(pixel0))); } // Convert the array elements to the appropriate C type, store in pixel // buffer. for (x = 0; x < npixels; x++) { pixel = rb_ary_entry(pixels_arg, x); if (rb_obj_is_kind_of(pixel, pixel_class) != Qtrue) { xfree(pixels.v); rb_raise(rb_eTypeError, "element %ld in pixel array is %s, expected %s", x, rb_class2name(CLASS_OF(pixel)), rb_class2name(CLASS_OF(pixel0))); } if (pixel_class == rb_cFloat) { pixels.f[x] = (float) NUM2DBL(pixel); if (pixels.f[x] < 0.0 || pixels.f[x] > 1.0) { xfree(pixels.v); rb_raise(rb_eArgError, "element %ld is out of range [0..1]: %f", x, pixels.f[x]); } } else { pixels.i[x] = NUM2QUANTUM(pixel); } } // This is based on ConstituteImage in IM 5.5.7 new_image = rm_acquire_image((ImageInfo *) NULL); if (!new_image) { xfree(pixels.v); rb_raise(rb_eNoMemError, "not enough memory to continue."); } #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); SetImageExtent(new_image, width, height, exception); #else SetImageExtent(new_image, width, height); exception = &new_image->exception; #endif if (rm_should_raise_exception(exception, RetainExceptionRetention)) { xfree(pixels.v); #if defined(IMAGEMAGICK_7) DestroyImage(new_image); rm_raise_exception(exception); #else rm_check_image_exception(new_image, DestroyOnError); #endif } #if defined(IMAGEMAGICK_7) SetImageBackgroundColor(new_image, exception); #else SetImageBackgroundColor(new_image); exception = &new_image->exception; #endif if (rm_should_raise_exception(exception, RetainExceptionRetention)) { xfree(pixels.v); #if defined(IMAGEMAGICK_7) DestroyImage(new_image); rm_raise_exception(exception); #else rm_check_image_exception(new_image, DestroyOnError); #endif } #if defined(IMAGEMAGICK_7) ImportImagePixels(new_image, 0, 0, width, height, map, stg_type, (const void *)pixels.v, exception); xfree(pixels.v); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else ImportImagePixels(new_image, 0, 0, width, height, map, stg_type, (const void *)pixels.v); xfree(pixels.v); rm_check_image_exception(new_image, DestroyOnError); #endif RB_GC_GUARD(pixel); RB_GC_GUARD(pixel0); RB_GC_GUARD(pixel_class); return rm_image_new(new_image); } |
.from_blob(blob) ⇒ Array<Magick::Image> .from_blob(blob) {|Magick::Image::Info| ... } ⇒ Array<Magick::Image>
Convert direct to memory image formats from string data.
6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 |
# File 'ext/RMagick/rmimage.c', line 6898 VALUE Image_from_blob(VALUE class ATTRIBUTE_UNUSED, VALUE blob_arg) { Image *images; Info *info; VALUE info_obj; ExceptionInfo *exception; void *blob; long length; blob = (void *) rm_str2cstr(blob_arg, &length); // Get a new Info object - run the parm block if supplied info_obj = rm_info_new(); Data_Get_Struct(info_obj, Info, info); exception = AcquireExceptionInfo(); images = BlobToImage(info, blob, (size_t)length, exception); rm_check_exception(exception, images, DestroyOnError); DestroyExceptionInfo(exception); rm_ensure_result(images); rm_set_user_artifact(images, info); RB_GC_GUARD(info_obj); return array_from_images(images); } |
.ping(file_arg) ⇒ Array<Magick::Image>
Returns all the properties of an image or image sequence except for the pixels.
10141 10142 10143 10144 10145 |
# File 'ext/RMagick/rmimage.c', line 10141 VALUE Image_ping(VALUE class, VALUE file_arg) { return rd_image(class, file_arg, PingImage); } |
.read(file_arg) ⇒ Array<Magick::Image>
Call ReadImage.
11032 11033 11034 11035 11036 |
# File 'ext/RMagick/rmimage.c', line 11032 VALUE Image_read(VALUE class, VALUE file_arg) { return rd_image(class, file_arg, ReadImage); } |
.read_inline(content) ⇒ Array<Magick::Image>
Read a Base64-encoded image.
11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 |
# File 'ext/RMagick/rmimage.c', line 11234 VALUE Image_read_inline(VALUE self ATTRIBUTE_UNUSED, VALUE content) { VALUE info_obj; Image *images; ImageInfo *info; char *image_data; long x, image_data_l; unsigned char *blob; size_t blob_l; ExceptionInfo *exception; image_data = rm_str2cstr(content, &image_data_l); // Search for a comma. If found, we'll set the start of the // image data just following the comma. Otherwise we'll assume // the image data starts with the first byte. for (x = 0; x < image_data_l; x++) { if (image_data[x] == ',') { break; } } if (x < image_data_l) { image_data += x + 1; } blob = Base64Decode(image_data, &blob_l); if (blob_l == 0) { rb_raise(rb_eArgError, "can't decode image"); } exception = AcquireExceptionInfo(); // Create a new Info structure for this read. About the // only useful attribute that can be set is `format'. info_obj = rm_info_new(); Data_Get_Struct(info_obj, Info, info); images = BlobToImage(info, blob, blob_l, exception); magick_free((void *)blob); rm_check_exception(exception, images, DestroyOnError); DestroyExceptionInfo(exception); rm_set_user_artifact(images, info); RB_GC_GUARD(info_obj); return array_from_images(images); } |
Instance Method Details
#<=>(other) ⇒ -1, ...
Compare two images.
12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 |
# File 'ext/RMagick/rmimage.c', line 12858 VALUE Image_spaceship(VALUE self, VALUE other) { Image *imageA, *imageB; const char *sigA, *sigB; int res; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif imageA = rm_check_destroyed(self); // If the other object isn't a Image object, then they can't be equal. if (!rb_obj_is_kind_of(other, Class_Image)) { return Qnil; } imageB = rm_check_destroyed(other); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); SignatureImage(imageA, exception); CHECK_EXCEPTION(); SignatureImage(imageB, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else SignatureImage(imageA); SignatureImage(imageB); #endif sigA = rm_get_property(imageA, "signature"); sigB = rm_get_property(imageB, "signature"); if (!sigA || !sigB) { rb_raise(Class_ImageMagickError, "can't get image signature"); } res = memcmp(sigA, sigB, 64); res = res > 0 ? 1 : (res < 0 ? -1 : 0); // reduce to 1, -1, 0 return INT2FIX(res); } |
#[](key_arg) ⇒ String
Returns the value of the image property identified by key. An image may have any number of properties.
Each property is identified by a string (or symbol) key. The property value is a string. ImageMagick predefines some properties, including “Label”, “Comment”, “Signature”, and in some cases “EXIF”.
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 |
# File 'ext/RMagick/rmimage.c', line 726 VALUE Image_aref(VALUE self, VALUE key_arg) { Image *image; const char *key; const char *attr; image = rm_check_destroyed(self); switch (TYPE(key_arg)) { case T_NIL: return Qnil; case T_SYMBOL: key = rb_id2name((ID)SYM2ID(key_arg)); break; default: key = StringValueCStr(key_arg); if (*key == '\0') { return Qnil; } break; } if (rm_strcasecmp(key, "EXIF:*") == 0) { return rm_exif_by_entry(image); } else if (rm_strcasecmp(key, "EXIF:!") == 0) { return rm_exif_by_number(image); } attr = rm_get_property(image, key); return attr ? rb_str_new2(attr) : Qnil; } |
#[]=(key_arg, attr_arg) ⇒ Magick::Image
Sets the value of an image property. An image may have any number of properties.
-
Specify attr=nil to remove the key from the list.
-
SetImageProperty normally APPENDS the new value to any existing value. Since this usage is tremendously counter-intuitive, this function always deletes the existing value before setting the new value.
-
There’s no use checking the return value since SetImageProperty returns “False” for many reasons, some legitimate.
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 |
# File 'ext/RMagick/rmimage.c', line 781 VALUE Image_aset(VALUE self, VALUE key_arg, VALUE attr_arg) { Image *image; const char *key; char *attr; unsigned int okay; image = rm_check_frozen(self); attr = attr_arg == Qnil ? NULL : StringValueCStr(attr_arg); switch (TYPE(key_arg)) { case T_NIL: return self; case T_SYMBOL: key = rb_id2name((ID)SYM2ID(key_arg)); break; default: key = StringValueCStr(key_arg); if (*key == '\0') { return self; } break; } // Delete existing value. SetImageProperty returns False if // the attribute doesn't exist - we don't care. rm_set_property(image, key, NULL); // Set new value if (attr) { okay = rm_set_property(image, key, attr); if (!okay) { rb_warning("SetImageProperty failed (probably out of memory)"); } } return self; } |
#_dump(depth) ⇒ String
Implement marshalling.
5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 |
# File 'ext/RMagick/rmimage.c', line 5718 VALUE Image__dump(VALUE self, VALUE depth ATTRIBUTE_UNUSED) { Image *image; ImageInfo *info; void *blob; size_t length; DumpedImage mi; VALUE str; ExceptionInfo *exception; image = rm_check_destroyed(self); info = CloneImageInfo(NULL); if (!info) { rb_raise(rb_eNoMemError, "not enough memory to continue"); } strlcpy(info->magick, image->magick, sizeof(info->magick)); exception = AcquireExceptionInfo(); blob = ImageToBlob(info, image, &length, exception); // Free ImageInfo first - error handling may raise an exception DestroyImageInfo(info); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); if (!blob) { rb_raise(rb_eNoMemError, "not enough memory to continue"); } // Create a header for the blob: ID and version // numbers, followed by the length of the magick // string stored as a byte, followed by the // magick string itself. mi.id = DUMPED_IMAGE_ID; mi.mj = DUMPED_IMAGE_MAJOR_VERS; mi.mi = DUMPED_IMAGE_MINOR_VERS; strlcpy(mi.magick, image->magick, sizeof(mi.magick)); mi.len = (unsigned char) min((size_t)UCHAR_MAX, rm_strnlen_s(mi.magick, sizeof(mi.magick))); // Concatenate the blob onto the header & return the result str = rb_str_new((char *)&mi, (long)(mi.len+offsetof(DumpedImage, magick))); str = rb_str_buf_cat(str, (char *)blob, (long)length); magick_free((void*)blob); RB_GC_GUARD(str); return str; } |
#adaptive_blur(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Adaptively blurs the image by blurring more intensely near image edges and less intensely far from edges. The #adaptive_blur method blurs the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and adaptive_blur selects a suitable radius for you.
214 215 216 217 218 |
# File 'ext/RMagick/rmimage.c', line 214 VALUE Image_adaptive_blur(int argc, VALUE *argv, VALUE self) { return adaptive_method(argc, argv, self, AdaptiveBlurImage); } |
#adaptive_blur_channel(radius = 0.0, sigma = 1.0, channel = Magick::AllChannels) ⇒ Magick::Image #adaptive_blur_channel(radius = 0.0, sigma = 1.0, *channels) ⇒ Magick::Image
The same as #adaptive_blur except only the specified channels are blurred.
237 238 239 240 241 242 243 244 245 |
# File 'ext/RMagick/rmimage.c', line 237 VALUE Image_adaptive_blur_channel(int argc, VALUE *argv, VALUE self) { #if defined(IMAGEMAGICK_7) return adaptive_channel_method(argc, argv, self, AdaptiveBlurImage); #else return adaptive_channel_method(argc, argv, self, AdaptiveBlurImageChannel); #endif } |
#adaptive_resize(scale_val) ⇒ Magick::Image #adaptive_resize(cols, rows) ⇒ Magick::Image
Resizes the image with data dependent triangulation.
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'ext/RMagick/rmimage.c', line 262 VALUE Image_adaptive_resize(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; unsigned long rows, columns; double scale_val, drows, dcols; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 2: rows = NUM2ULONG(argv[1]); columns = NUM2ULONG(argv[0]); break; case 1: scale_val = NUM2DBL(argv[0]); if (scale_val < 0.0) { rb_raise(rb_eArgError, "invalid scale_val value (%g given)", scale_val); } drows = scale_val * image->rows + 0.5; dcols = scale_val * image->columns + 0.5; if (drows > (double)ULONG_MAX || dcols > (double)ULONG_MAX) { rb_raise(rb_eRangeError, "resized image too big"); } rows = (unsigned long) drows; columns = (unsigned long) dcols; break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc); break; } exception = AcquireExceptionInfo(); new_image = AdaptiveResizeImage(image, columns, rows, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#adaptive_sharpen(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Adaptively sharpens the image by sharpening more intensely near image edges and less intensely far from edges.
The #adaptive_sharpen method sharpens the image with a Gaussian operator of the given radius and standard deviation (sigma).
For reasonable results, radius should be larger than sigma. Use a radius of 0 and adaptive_sharpen selects a suitable radius for you.
323 324 325 326 327 |
# File 'ext/RMagick/rmimage.c', line 323 VALUE Image_adaptive_sharpen(int argc, VALUE *argv, VALUE self) { return adaptive_method(argc, argv, self, AdaptiveSharpenImage); } |
#adaptive_sharpen_channel(radius = 0.0, sigma = 1.0, channel = Magick::AllChannels) ⇒ Magick::Image #adaptive_sharpen_channel(radius = 0.0, sigma = 1.0, *channels) ⇒ Magick::Image
The same as #adaptive_sharpen except only the specified channels are sharpened.
346 347 348 349 350 351 352 353 354 |
# File 'ext/RMagick/rmimage.c', line 346 VALUE Image_adaptive_sharpen_channel(int argc, VALUE *argv, VALUE self) { #if defined(IMAGEMAGICK_7) return adaptive_channel_method(argc, argv, self, AdaptiveSharpenImage); #else return adaptive_channel_method(argc, argv, self, AdaptiveSharpenImageChannel); #endif } |
#adaptive_threshold(width = 3, height = 3, offset = 0) ⇒ Magick::Image
Selects an individual threshold for each pixel based on the range of intensity values in its local neighborhood. This allows for thresholding of an image whose global intensity histogram doesn’t contain distinctive peaks.
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'ext/RMagick/rmimage.c', line 369 VALUE Image_adaptive_threshold(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; unsigned long width = 3, height = 3; long offset = 0; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 3: offset = NUM2LONG(argv[2]); case 2: height = NUM2ULONG(argv[1]); case 1: width = NUM2ULONG(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 3)", argc); } exception = AcquireExceptionInfo(); new_image = AdaptiveThresholdImage(image, width, height, offset, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#add_compose_mask(mask) ⇒ Object
Associates a mask with an image that will be used as the destination image in a #composite operation.
The areas of the destination image that are masked by white pixels will be modified by the #composite method, while areas masked by black pixels are unchanged.
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'ext/RMagick/rmimage.c', line 413 VALUE Image_add_compose_mask(VALUE self, VALUE mask) { Image *image, *mask_image = NULL; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; Image *clip_mask = NULL; #endif image = rm_check_frozen(self); mask_image = rm_check_destroyed(mask); if (image->columns != mask_image->columns || image->rows != mask_image->rows) { rb_raise(rb_eArgError, "mask must be the same size as image"); } #if defined(IMAGEMAGICK_7) clip_mask = rm_clone_image(mask_image); exception = AcquireExceptionInfo(); NegateImage(clip_mask, MagickFalse, exception); rm_check_exception(exception, clip_mask, DestroyOnError); SetImageMask(image, CompositePixelMask, clip_mask, exception); DestroyImage(clip_mask); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else // Delete any previously-existing mask image. // Store a clone of the new mask image. SetImageMask(image, mask_image); NegateImage(image->mask, MagickFalse); // Since both Set and GetImageMask clone the mask image I don't see any // way to negate the mask without referencing it directly. Sigh. #endif return self; } |
#add_noise(noise) ⇒ Magick::Image
Adds random noise to the image.
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
# File 'ext/RMagick/rmimage.c', line 459 VALUE Image_add_noise(VALUE self, VALUE noise) { Image *image, *new_image; NoiseType noise_type; ExceptionInfo *exception; image = rm_check_destroyed(self); VALUE_TO_ENUM(noise, noise_type, NoiseType); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) new_image = AddNoiseImage(image, noise_type, 1.0, exception); #else new_image = AddNoiseImage(image, noise_type, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#add_noise_channel(noise_type, channel = Magick::AllChannels) ⇒ Magick::Image #add_noise_channel(noise_type, *channels) ⇒ Magick::Image
Adds random noise to the specified channel or channels in the image.
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 |
# File 'ext/RMagick/rmimage.c', line 495 VALUE Image_add_noise_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; NoiseType noise_type; ExceptionInfo *exception; ChannelType channels; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // There must be 1 remaining argument. if (argc == 0) { rb_raise(rb_eArgError, "missing noise type argument"); } else if (argc > 1) { raise_ChannelType_error(argv[argc-1]); } VALUE_TO_ENUM(argv[0], noise_type, NoiseType); channels &= ~OpacityChannel; exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); new_image = AddNoiseImage(image, noise_type, 1.0, exception); END_CHANNEL_MASK(new_image); #else new_image = AddNoiseImageChannel(image, channels, noise_type, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#add_profile(name) ⇒ Magick::Image
Adds an ICC (a.k.a. ICM), IPTC, or generic profile. If the file contains more than one profile all the profiles are added.
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
# File 'ext/RMagick/rmimage.c', line 541 VALUE Image_add_profile(VALUE self, VALUE name) { // ImageMagick code based on the code for the "-profile" option in mogrify.c Image *image, *profile_image; ImageInfo *info; ExceptionInfo *exception; char *profile_name; char *profile_filename = NULL; const StringInfo *profile; image = rm_check_frozen(self); // ProfileImage issues a warning if something goes wrong. profile_filename = StringValueCStr(name); info = CloneImageInfo(NULL); if (!info) { rb_raise(rb_eNoMemError, "not enough memory to continue"); } profile = GetImageProfile(image, "iptc"); if (profile) { info->profile = (void *)CloneStringInfo(profile); } strlcpy(info->filename, profile_filename, sizeof(info->filename)); exception = AcquireExceptionInfo(); profile_image = ReadImage(info, exception); DestroyImageInfo(info); rm_check_exception(exception, profile_image, DestroyOnError); rm_ensure_result(profile_image); ResetImageProfileIterator(profile_image); profile_name = GetNextImageProfile(profile_image); while (profile_name) { profile = GetImageProfile(profile_image, profile_name); if (profile) { #if defined(IMAGEMAGICK_7) ProfileImage(image, profile_name, GetStringInfoDatum(profile), GetStringInfoLength(profile), exception); if (rm_should_raise_exception(exception, RetainExceptionRetention)) #else ProfileImage(image, profile_name, GetStringInfoDatum(profile), GetStringInfoLength(profile), MagickFalse); if (rm_should_raise_exception(&image->exception, RetainExceptionRetention)) #endif { break; } } profile_name = GetNextImageProfile(profile_image); } DestroyImage(profile_image); #if defined(IMAGEMAGICK_7) CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else DestroyExceptionInfo(exception); rm_check_image_exception(image, RetainOnError); #endif return self; } |
#affine_transform(affine) ⇒ Magick::Image
Transform an image as dictated by the affine matrix argument.
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 |
# File 'ext/RMagick/rmimage.c', line 693 VALUE Image_affine_transform(VALUE self, VALUE affine) { Image *image, *new_image; ExceptionInfo *exception; AffineMatrix matrix; image = rm_check_destroyed(self); // Convert Magick::AffineMatrix to AffineMatrix structure. Export_AffineMatrix(&matrix, affine); exception = AcquireExceptionInfo(); new_image = AffineTransformImage(image, &matrix, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#alpha ⇒ Boolean #alpha(value) ⇒ Magick::AlphaChannelOption
Get/Set alpha channel.
-
Replaces #matte=, #alpha=
-
Originally there was an alpha attribute getter and setter. These are replaced with alpha? and alpha(type). We still define (but don’t document) alpha=. For backward compatibility, if this method is called without an argument, make it act like the old alpha getter and return true if the matte channel is active, false otherwise.
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
# File 'ext/RMagick/rmimage.c', line 631 VALUE Image_alpha(int argc, VALUE *argv, VALUE self) { Image *image; AlphaChannelOption alpha; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif // For backward compatibility, make alpha() act like alpha? if (argc == 0) { return Image_alpha_q(self); } else if (argc > 1) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc); } image = rm_check_frozen(self); VALUE_TO_ENUM(argv[0], alpha, AlphaChannelOption); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); SetImageAlphaChannel(image, alpha, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else SetImageAlphaChannel(image, alpha); rm_check_image_exception(image, RetainOnError); #endif return argv[0]; } |
#alpha? ⇒ Boolean
Determine whether the image’s alpha channel is activated.
675 676 677 678 679 680 681 682 683 684 |
# File 'ext/RMagick/rmimage.c', line 675 VALUE Image_alpha_q(VALUE self) { Image *image = rm_check_destroyed(self); #if defined(IMAGEMAGICK_7) return image->alpha_trait == BlendPixelTrait ? Qtrue : Qfalse; #else return GetImageAlphaChannel(image) ? Qtrue : Qfalse; #endif } |
#annotate(draw, width, height, x, y, text, &block) ⇒ Object
Provide an alternate version of Draw#annotate, for folks who want to find it in this class.
824 825 826 827 828 |
# File 'lib/rmagick_internal.rb', line 824 def annotate(draw, width, height, x, y, text, &block) check_destroyed draw.annotate(self, width, height, x, y, text, &block) self end |
#auto_gamma_channel(channel = Magick::AllChannels) ⇒ Magick::Image #auto_gamma_channel(*channels) ⇒ Magick::Image
“Automagically” adjust the gamma level of an image.
922 923 924 925 926 927 928 929 930 |
# File 'ext/RMagick/rmimage.c', line 922 VALUE Image_auto_gamma_channel(int argc, VALUE *argv, VALUE self) { #if defined(IMAGEMAGICK_7) return auto_channel(argc, argv, self, AutoGammaImage); #else return auto_channel(argc, argv, self, AutoGammaImageChannel); #endif } |
#auto_level_channel(channel = Magick::AllChannels) ⇒ Magick::Image #auto_level_channel(*channels) ⇒ Magick::Image
“Automagically” adjust the color levels of an image.
944 945 946 947 948 949 950 951 952 |
# File 'ext/RMagick/rmimage.c', line 944 VALUE Image_auto_level_channel(int argc, VALUE *argv, VALUE self) { #if defined(IMAGEMAGICK_7) return auto_channel(argc, argv, self, AutoLevelImage); #else return auto_channel(argc, argv, self, AutoLevelImageChannel); #endif } |
#auto_orient ⇒ Magick::Image
Rotates or flips the image based on the image’s EXIF orientation tag.
Note that only some models of modern digital cameras can tag an image with the orientation. If the image does not have an orientation tag, or the image is already properly oriented, then #auto_orient returns an exact copy of the image.
1033 1034 1035 1036 1037 1038 |
# File 'ext/RMagick/rmimage.c', line 1033 VALUE Image_auto_orient(VALUE self) { rm_check_destroyed(self); return auto_orient(False, self); } |
#auto_orient! ⇒ Magick::Image?
Rotates or flips the image based on the image’s EXIF orientation tag. Note that only some models of modern digital cameras can tag an image with the orientation. If the image does not have an orientation tag, or the image is already properly oriented, then #auto_orient! returns nil.
1050 1051 1052 1053 1054 1055 |
# File 'ext/RMagick/rmimage.c', line 1050 VALUE Image_auto_orient_bang(VALUE self) { rm_check_frozen(self); return auto_orient(True, self); } |
#background_color ⇒ String
Return the name of the background color as a String.
1063 1064 1065 1066 1067 1068 |
# File 'ext/RMagick/rmimage.c', line 1063 VALUE Image_background_color(VALUE self) { Image *image = rm_check_destroyed(self); return rm_pixelcolor_to_color_name(image, &image->background_color); } |
#background_color=(color) ⇒ Magick::Pixel, String
Set the the background color to the specified color spec.
1077 1078 1079 1080 1081 1082 1083 |
# File 'ext/RMagick/rmimage.c', line 1077 VALUE Image_background_color_eq(VALUE self, VALUE color) { Image *image = rm_check_frozen(self); Color_to_PixelColor(&image->background_color, color); return color; } |
#base_columns ⇒ Numeric
Return the number of rows (before transformations).
1091 1092 1093 1094 1095 1096 |
# File 'ext/RMagick/rmimage.c', line 1091 VALUE Image_base_columns(VALUE self) { Image *image = rm_check_destroyed(self); return INT2FIX(image->magick_columns); } |
#base_filename ⇒ String
Return the image filename (before transformations).
1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 |
# File 'ext/RMagick/rmimage.c', line 1103 VALUE Image_base_filename(VALUE self) { Image *image = rm_check_destroyed(self); if (*image->magick_filename) { return rb_str_new2(image->magick_filename); } else { return rb_str_new2(image->filename); } } |
#base_rows ⇒ Numeric
Return the number of rows (before transformations).
1122 1123 1124 1125 1126 1127 |
# File 'ext/RMagick/rmimage.c', line 1122 VALUE Image_base_rows(VALUE self) { Image *image = rm_check_destroyed(self); return INT2FIX(image->magick_rows); } |
#bias ⇒ Float
Get image bias (used when convolving an image).
1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 |
# File 'ext/RMagick/rmimage.c', line 1135 VALUE Image_bias(VALUE self) { Image *image; double bias = 0.0; image = rm_check_destroyed(self); #if defined(IMAGEMAGICK_7) { const char *artifact = GetImageArtifact(image, "convolve:bias"); if (artifact != (const char *) NULL) { char *q; bias = InterpretLocaleValue(artifact, &q); if (*q == '%') { bias *= ((double) QuantumRange + 1.0) / 100.0; } } } #else bias = image->bias; #endif return rb_float_new(bias); } |
#bias=(pct) ⇒ Float, String
Set image bias (used when convolving an image).
1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 |
# File 'ext/RMagick/rmimage.c', line 1169 VALUE Image_bias_eq(VALUE self, VALUE pct) { Image *image; double bias; image = rm_check_frozen(self); bias = rm_percentage(pct, 1.0) * QuantumRange; #if defined(IMAGEMAGICK_7) { char artifact[21]; snprintf(artifact, sizeof(artifact), "%.20g", bias); SetImageArtifact(image, "convolve:bias", artifact); } #else image->bias = bias; #endif return pct; } |
#bilevel_channel(threshold, channel = Magick::AllChannels) ⇒ Magick::Image #bilevel_channel(threshold, *channels) ⇒ Magick::Image
Changes the value of individual pixels based on the intensity of each pixel channel. The result is a high-contrast image.
1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 |
# File 'ext/RMagick/rmimage.c', line 1205 VALUE Image_bilevel_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; ChannelType channels; double threshold; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); if (argc > 1) { raise_ChannelType_error(argv[argc-1]); } if (argc == 0) { rb_raise(rb_eArgError, "no threshold specified"); } threshold = NUM2DBL(argv[0]); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(new_image, channels); BilevelImage(new_image, threshold, exception); END_CHANNEL_MASK(new_image); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else BilevelImageChannel(new_image, channels, threshold); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#black_point_compensation ⇒ Boolean
Return current black point compensation attribute.
1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 |
# File 'ext/RMagick/rmimage.c', line 1251 VALUE Image_black_point_compensation(VALUE self) { Image *image; const char *attr; VALUE value; image = rm_check_destroyed(self); attr = rm_get_property(image, BlackPointCompensationKey); if (attr && rm_strcasecmp(attr, "true") == 0) { value = Qtrue; } else { value = Qfalse; } RB_GC_GUARD(value); return value; } |
#black_point_compensation=(arg) ⇒ Boolean
Set black point compensation attribute.
1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 |
# File 'ext/RMagick/rmimage.c', line 1282 VALUE Image_black_point_compensation_eq(VALUE self, VALUE arg) { Image *image; const char *value; image = rm_check_frozen(self); rm_set_property(image, BlackPointCompensationKey, NULL); value = RTEST(arg) ? "true" : "false"; rm_set_property(image, BlackPointCompensationKey, value); return arg; } |
#black_threshold(red) ⇒ Numeric #black_threshold(red, green) ⇒ Numeric #black_threshold(red, green, blue) ⇒ Numeric #black_threshold(red, green, blue, alpha: ) ⇒ Numeric
Forces all pixels below the threshold into black while leaving all pixels above the threshold unchanged.
1322 1323 1324 1325 1326 |
# File 'ext/RMagick/rmimage.c', line 1322 VALUE Image_black_threshold(int argc, VALUE *argv, VALUE self) { return threshold_image(argc, argv, self, BlackThresholdImage); } |
#blend(overlay, src_percent, dst_percent, gravity = Magick::NorthWestGravity, x_offset = 0, y_offset = 0) ⇒ Magick::Image
Adds the overlay image to the target image according to src_percent and dst_percent.
-
The default value for dst_percent is 100%-src_percent
1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 |
# File 'ext/RMagick/rmimage.c', line 1668 VALUE Image_blend(int argc, VALUE *argv, VALUE self) { VALUE ovly; Image *image, *; double src_percent, dst_percent; long x_offset = 0L, y_offset = 0L; image = rm_check_destroyed(self); if (argc < 1) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 to 6)", argc); } ovly = rm_cur_image(argv[0]); = rm_check_destroyed(ovly); if (argc > 3) { get_composite_offsets(argc-3, &argv[3], image, , &x_offset, &y_offset); // There must be 3 arguments left argc = 3; } switch (argc) { case 3: dst_percent = rm_percentage(argv[2], 1.0) * 100.0; src_percent = rm_percentage(argv[1], 1.0) * 100.0; break; case 2: src_percent = rm_percentage(argv[1], 1.0) * 100.0; dst_percent = FMAX(100.0 - src_percent, 0); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 to 6)", argc); break; } RB_GC_GUARD(ovly); return special_composite(image, , src_percent, dst_percent, x_offset, y_offset, BlendCompositeOp); } |
#blue_shift(factor = 1.5) ⇒ Magick::Image
Simulate a scene at nighttime in the moonlight.
1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 |
# File 'ext/RMagick/rmimage.c', line 1724 VALUE Image_blue_shift(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double factor = 1.5; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 1: factor = NUM2DBL(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc); break; } exception = AcquireExceptionInfo(); new_image = BlueShiftImage(image, factor, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#blur_channel(radius = 0.0, sigma = 1.0, channel = Magick::AllChannels) ⇒ Magick::Image #blur_channel(radius = 0.0, sigma = 1.0, *channels) ⇒ Magick::Image
Blurs the specified channel. Convolves the image with a Gaussian operator of the given radius and standard deviation (sigma).
1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 |
# File 'ext/RMagick/rmimage.c', line 1770 VALUE Image_blur_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; ExceptionInfo *exception; ChannelType channels; double radius = 0.0, sigma = 1.0; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // There can be 0, 1, or 2 remaining arguments. switch (argc) { case 2: sigma = NUM2DBL(argv[1]); case 1: radius = NUM2DBL(argv[0]); case 0: break; default: raise_ChannelType_error(argv[argc-1]); } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); new_image = BlurImage(image, radius, sigma, exception); CHANGE_RESULT_CHANNEL_MASK(new_image); END_CHANNEL_MASK(image); #else new_image = BlurImageChannel(image, channels, radius, sigma, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#blur_image(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Blur the image.
1819 1820 1821 1822 1823 |
# File 'ext/RMagick/rmimage.c', line 1819 VALUE Image_blur_image(int argc, VALUE *argv, VALUE self) { return effect_image(self, argc, argv, BlurImage); } |
#border(width, height, color) ⇒ Magick::Image
Surrounds the image with a border of the specified width, height, and named color.
1905 1906 1907 1908 1909 1910 |
# File 'ext/RMagick/rmimage.c', line 1905 VALUE Image_border(VALUE self, VALUE width, VALUE height, VALUE color) { rm_check_destroyed(self); return border(False, self, width, height, color); } |
#border!(width, height, color) ⇒ Object
Surrounds the image with a border of the specified width, height, and named color. In-place form of #border.
1889 1890 1891 1892 1893 1894 |
# File 'ext/RMagick/rmimage.c', line 1889 VALUE Image_border_bang(VALUE self, VALUE width, VALUE height, VALUE color) { rm_check_frozen(self); return border(True, self, width, height, color); } |
#border_color ⇒ String
Return the name of the border color as a String.
1918 1919 1920 1921 1922 1923 |
# File 'ext/RMagick/rmimage.c', line 1918 VALUE Image_border_color(VALUE self) { Image *image = rm_check_destroyed(self); return rm_pixelcolor_to_color_name(image, &image->border_color); } |
#border_color=(color) ⇒ Magick::Pixel, String
Set the the border color.
1932 1933 1934 1935 1936 1937 1938 |
# File 'ext/RMagick/rmimage.c', line 1932 VALUE Image_border_color_eq(VALUE self, VALUE color) { Image *image = rm_check_frozen(self); Color_to_PixelColor(&image->border_color, color); return color; } |
#bounding_box ⇒ Magick::Rectangle
Returns the bounding box of an image canvas.
1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 |
# File 'ext/RMagick/rmimage.c', line 1946 VALUE Image_bounding_box(VALUE self) { Image *image; RectangleInfo box; ExceptionInfo *exception; image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); box = GetImageBoundingBox(image, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); return Import_RectangleInfo(&box); } |
#change_geometry(geom_arg) {|column, row, image| ... } ⇒ Object
#change_geometry! is an alias for #change_geometry.
This method supports resizing a method by specifying constraints. For example, you can specify that the image should be resized such that the aspect ratio should be retained but the resulting image should be no larger than 640 pixels wide and 480 pixels tall.
2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 |
# File 'ext/RMagick/rmimage.c', line 2078 VALUE Image_change_geometry(VALUE self, VALUE geom_arg) { Image *image; RectangleInfo rect; VALUE geom_str; char *geometry; unsigned int flags; VALUE ary; image = rm_check_destroyed(self); geom_str = rb_String(geom_arg); geometry = StringValueCStr(geom_str); memset(&rect, 0, sizeof(rect)); SetGeometry(image, &rect); flags = ParseMetaGeometry(geometry, &rect.x, &rect.y, &rect.width, &rect.height); if (flags == NoValue) { rb_raise(rb_eArgError, "invalid geometry string `%s'", geometry); } ary = rb_ary_new2(3); rb_ary_store(ary, 0, ULONG2NUM(rect.width)); rb_ary_store(ary, 1, ULONG2NUM(rect.height)); rb_ary_store(ary, 2, self); RB_GC_GUARD(geom_str); RB_GC_GUARD(ary); return rb_yield(ary); } |
#change_geometry!(geom_arg) {|column, row, image| ... } ⇒ Object
#change_geometry! is an alias for #change_geometry.
This method supports resizing a method by specifying constraints. For example, you can specify that the image should be resized such that the aspect ratio should be retained but the resulting image should be no larger than 640 pixels wide and 480 pixels tall.
2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 |
# File 'ext/RMagick/rmimage.c', line 2078 VALUE Image_change_geometry(VALUE self, VALUE geom_arg) { Image *image; RectangleInfo rect; VALUE geom_str; char *geometry; unsigned int flags; VALUE ary; image = rm_check_destroyed(self); geom_str = rb_String(geom_arg); geometry = StringValueCStr(geom_str); memset(&rect, 0, sizeof(rect)); SetGeometry(image, &rect); flags = ParseMetaGeometry(geometry, &rect.x, &rect.y, &rect.width, &rect.height); if (flags == NoValue) { rb_raise(rb_eArgError, "invalid geometry string `%s'", geometry); } ary = rb_ary_new2(3); rb_ary_store(ary, 0, ULONG2NUM(rect.width)); rb_ary_store(ary, 1, ULONG2NUM(rect.height)); rb_ary_store(ary, 2, self); RB_GC_GUARD(geom_str); RB_GC_GUARD(ary); return rb_yield(ary); } |
#changed? ⇒ Boolean
Return true if any pixel in the image has been altered since the image was constituted.
2118 2119 2120 2121 2122 2123 2124 |
# File 'ext/RMagick/rmimage.c', line 2118 VALUE Image_changed_q(VALUE self) { Image *image = rm_check_destroyed(self); VALUE okay = IsTaintImage(image) ? Qtrue : Qfalse; return okay; } |
#channel(channel_arg) ⇒ Magick::Image
Extract a channel from the image. A channel is a particular color component of each pixel in the image.
2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 |
# File 'ext/RMagick/rmimage.c', line 2134 VALUE Image_channel(VALUE self, VALUE channel_arg) { Image *image, *new_image; ChannelType channel; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); VALUE_TO_ENUM(channel_arg, channel, ChannelType); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); new_image = SeparateImage(image, channel, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else new_image = rm_clone_image(image); SeparateImageChannel(new_image, channel); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#compare_channel(image, metric, channel = Magick::AllChannels) ⇒ Array #compare_channel(image, metric, channel = Magick::AllChannels) {|Magick::OptionalMethodArguments| ... } ⇒ Array #compare_channel(image, metric, *channels) ⇒ Array #compare_channel(image, metric, *channels) {|Magick::OptionalMethodArguments| ... } ⇒ Array
Compare one or more channels in two images and returns the specified distortion metric and a comparison image.
3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 |
# File 'ext/RMagick/rmimage.c', line 3143 VALUE Image_compare_channel(int argc, VALUE *argv, VALUE self) { Image *image, *r_image, *difference_image; double distortion; VALUE ary, ref; MetricType metric_type; ChannelType channels; ExceptionInfo *exception; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); if (argc > 2) { raise_ChannelType_error(argv[argc-1]); } if (argc != 2) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or more)", argc); } rm_get_optional_arguments(self); ref = rm_cur_image(argv[0]); r_image = rm_check_destroyed(ref); VALUE_TO_ENUM(argv[1], metric_type, MetricType); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); difference_image = CompareImages(image, r_image, metric_type, &distortion, exception); END_CHANNEL_MASK(image); #else difference_image = CompareImageChannels(image, r_image, channels, metric_type, &distortion, exception); #endif rm_check_exception(exception, difference_image, DestroyOnError); DestroyExceptionInfo(exception); ary = rb_ary_new2(2); rb_ary_store(ary, 0, rm_image_new(difference_image)); rb_ary_store(ary, 1, rb_float_new(distortion)); RB_GC_GUARD(ary); RB_GC_GUARD(ref); return ary; } |
#channel_depth(channel = Magick::AllChannels) ⇒ Numeric #channel_depth(*channels) ⇒ Numeric
Returns the maximum depth for the specified channel or channels.
2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 |
# File 'ext/RMagick/rmimage.c', line 2174 VALUE Image_channel_depth(int argc, VALUE *argv, VALUE self) { Image *image; ChannelType channels; unsigned long channel_depth; ExceptionInfo *exception; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // Ensure all arguments consumed. if (argc > 0) { raise_ChannelType_error(argv[argc-1]); } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); channel_depth = GetImageDepth(image, exception); END_CHANNEL_MASK(image); #else channel_depth = GetImageChannelDepth(image, channels, exception); #endif CHECK_EXCEPTION(); DestroyExceptionInfo(exception); return ULONG2NUM(channel_depth); } |
#channel_entropy(*args) ⇒ Object
2364 2365 2366 2367 2368 |
# File 'ext/RMagick/rmimage.c', line 2364 VALUE Image_channel_entropy(int argc ATTRIBUTE_UNUSED, VALUE *argv ATTRIBUTE_UNUSED, VALUE self ATTRIBUTE_UNUSED) { rm_not_implemented(); } |
#channel_extrema(channel = Magick::AllChannels) ⇒ Array<Numeric> #channel_extrema(*channels) ⇒ Array<Numeric>
Returns the minimum and maximum intensity values for the specified channel or channels.
2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 |
# File 'ext/RMagick/rmimage.c', line 2220 VALUE Image_channel_extrema(int argc, VALUE *argv, VALUE self) { Image *image; ChannelType channels; ExceptionInfo *exception; size_t min, max; VALUE ary; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // Ensure all arguments consumed. if (argc > 0) { raise_ChannelType_error(argv[argc-1]); } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); GetImageExtrema(image, &min, &max, exception); END_CHANNEL_MASK(image); #else GetImageChannelExtrema(image, channels, &min, &max, exception); #endif CHECK_EXCEPTION(); DestroyExceptionInfo(exception); ary = rb_ary_new2(2); rb_ary_store(ary, 0, ULONG2NUM(min)); rb_ary_store(ary, 1, ULONG2NUM(max)); RB_GC_GUARD(ary); return ary; } |
#channel_mean(channel = Magick::AllChannels) ⇒ Array<Float> #channel_mean(*channels) ⇒ Array<Float>
Returns the mean and standard deviation values for the specified channel or channels.
2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 |
# File 'ext/RMagick/rmimage.c', line 2273 VALUE Image_channel_mean(int argc, VALUE *argv, VALUE self) { Image *image; ChannelType channels; ExceptionInfo *exception; double mean, stddev; VALUE ary; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // Ensure all arguments consumed. if (argc > 0) { raise_ChannelType_error(argv[argc-1]); } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); GetImageMean(image, &mean, &stddev, exception); END_CHANNEL_MASK(image); #else GetImageChannelMean(image, channels, &mean, &stddev, exception); #endif CHECK_EXCEPTION(); DestroyExceptionInfo(exception); ary = rb_ary_new2(2); rb_ary_store(ary, 0, rb_float_new(mean)); rb_ary_store(ary, 1, rb_float_new(stddev)); RB_GC_GUARD(ary); return ary; } |
#charcoal(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Return a new image that is a copy of the input image with the edges highlighted.
2379 2380 2381 2382 2383 |
# File 'ext/RMagick/rmimage.c', line 2379 VALUE Image_charcoal(int argc, VALUE *argv, VALUE self) { return effect_image(self, argc, argv, CharcoalImage); } |
#check_destroyed ⇒ nil
Raises DestroyedImageError if the image has been destroyed. Returns nil otherwise.
2392 2393 2394 2395 2396 2397 |
# File 'ext/RMagick/rmimage.c', line 2392 VALUE Image_check_destroyed(VALUE self) { rm_check_destroyed(self); return Qnil; } |
#chop(x, y, width, height) ⇒ Magick::Image
Remove a region of an image and collapses the image to occupy the removed portion.
2409 2410 2411 2412 2413 2414 |
# File 'ext/RMagick/rmimage.c', line 2409 VALUE Image_chop(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) { rm_check_destroyed(self); return xform_image(False, self, x, y, width, height, ChopImage); } |
#chromaticity ⇒ Magick::Chromaticity
Return the red, green, blue, and white-point chromaticity values as a Chromaticity.
2422 2423 2424 2425 2426 2427 |
# File 'ext/RMagick/rmimage.c', line 2422 VALUE Image_chromaticity(VALUE self) { Image *image = rm_check_destroyed(self); return ChromaticityInfo_new(&image->chromaticity); } |
#chromaticity=(chroma) ⇒ Magick::Chromaticity
Set the red, green, blue, and white-point chromaticity values from a Chromaticity.
2436 2437 2438 2439 2440 2441 2442 |
# File 'ext/RMagick/rmimage.c', line 2436 VALUE Image_chromaticity_eq(VALUE self, VALUE chroma) { Image *image = rm_check_frozen(self); Export_ChromaticityInfo(&image->chromaticity, chroma); return chroma; } |
#class_type ⇒ Magick::ClassType
Return the image’s storage class (a.k.a. storage type, class type). 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.
13278 13279 13280 13281 13282 13283 |
# File 'ext/RMagick/rmimage.c', line 13278 VALUE Image_class_type(VALUE self) { Image *image = rm_check_destroyed(self); return ClassType_find(image->storage_class); } |
#class_type=(new_class_type) ⇒ Magick::ClassType
Change the image’s storage class.
13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 |
# File 'ext/RMagick/rmimage.c', line 13292 VALUE Image_class_type_eq(VALUE self, VALUE new_class_type) { Image *image; ClassType class_type; QuantizeInfo qinfo; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_frozen(self); VALUE_TO_ENUM(new_class_type, class_type, ClassType); if (class_type == UndefinedClass) { rb_raise(rb_eArgError, "Invalid class type specified."); } #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); #endif if (image->storage_class == PseudoClass && class_type == DirectClass) { #if defined(IMAGEMAGICK_7) SyncImage(image, exception); CHECK_EXCEPTION(); #else SyncImage(image); #endif magick_free(image->colormap); image->colormap = NULL; } else if (image->storage_class == DirectClass && class_type == PseudoClass) { GetQuantizeInfo(&qinfo); qinfo.number_colors = QuantumRange+1; #if defined(IMAGEMAGICK_7) QuantizeImage(&qinfo, image, exception); CHECK_EXCEPTION(); #else QuantizeImage(&qinfo, image); #endif } #if defined(IMAGEMAGICK_7) SetImageStorageClass(image, class_type, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else SetImageStorageClass(image, class_type); #endif return new_class_type; } |
#clone ⇒ Magick::Image
Same as #dup except the frozen state of the original is propagated to the new copy.
2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 |
# File 'ext/RMagick/rmimage.c', line 2451 VALUE Image_clone(VALUE self) { VALUE clone; clone = Image_dup(self); if (OBJ_FROZEN(self)) { OBJ_FREEZE(clone); } RB_GC_GUARD(clone); return clone; } |
#clut_channel(clut_image, channel = Magick::AllChannels) ⇒ Magick::Image #clut_channel(clut_image, *channels) ⇒ Magick::Image
Replace the channel values in the target image with a lookup of its replacement value in an LUT gradient image.
The LUT image should be either a single row or column image of replacement colors. The lookup is controlled by the -interpolate setting, especially for an LUT which is not the full length needed by the IM installed Quality (Q) level. Good settings for this is the default ‘bilinear’ or ‘bicubic’ interpolation setting for a smooth color gradient, or ‘integer’ for a direct unsmoothed lookup of color values.
This method is especially suited to replacing a grayscale image with specific color gradient from the CLUT image.
2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 |
# File 'ext/RMagick/rmimage.c', line 2491 VALUE Image_clut_channel(int argc, VALUE *argv, VALUE self) { Image *image, *clut; ChannelType channels; MagickBooleanType okay; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_frozen(self); // check_destroyed before confirming the arguments if (argc >= 1) { rm_check_destroyed(argv[0]); channels = extract_channels(&argc, argv); if (argc != 1) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or more)", argc); } } else { rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or more)", argc); } Data_Get_Struct(argv[0], Image, clut); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(image, channels); okay = ClutImage(image, clut, image->interpolate, exception); END_CHANNEL_MASK(image); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else okay = ClutImageChannel(image, channels, clut); rm_check_image_exception(image, RetainOnError); rm_check_image_exception(clut, RetainOnError); #endif if (!okay) { rb_raise(rb_eRuntimeError, "ClutImageChannel failed."); } return self; } |
#color_fill_to_border(x, y, fill) ⇒ Object
Set all pixels that are neighbors of x,y and are not the border color to the fill color
846 847 848 |
# File 'lib/rmagick_internal.rb', line 846 def color_fill_to_border(x, y, fill) color_flood_fill(border_color, fill, x, y, Magick::FillToBorderMethod) end |
#color_flood_fill(target_color, fill_color, xv, yv, method) ⇒ Magick::Image
Change the color value of any pixel that matches target_color and is an immediate neighbor.
2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 |
# File 'ext/RMagick/rmimage.c', line 2785 VALUE Image_color_flood_fill(VALUE self, VALUE target_color, VALUE fill_color, VALUE xv, VALUE yv, VALUE method) { Image *image, *new_image; PixelColor target; DrawInfo *draw_info; PixelColor fill; long x, y; int fill_method; MagickPixel target_mpp; MagickBooleanType invert; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); // The target and fill args can be either a color name or // a Magick::Pixel. Color_to_PixelColor(&target, target_color); Color_to_PixelColor(&fill, fill_color); x = NUM2LONG(xv); y = NUM2LONG(yv); if ((unsigned long)x > image->columns || (unsigned long)y > image->rows) { rb_raise(rb_eArgError, "target out of range. %lux%lu given, image is %"RMIuSIZE"x%"RMIuSIZE"", x, y, image->columns, image->rows); } VALUE_TO_ENUM(method, fill_method, PaintMethod); if (!(fill_method == FloodfillMethod || fill_method == FillToBorderMethod)) { rb_raise(rb_eArgError, "paint method must be FloodfillMethod or " "FillToBorderMethod (%d given)", fill_method); } draw_info = CloneDrawInfo(NULL, NULL); if (!draw_info) { rb_raise(rb_eNoMemError, "not enough memory to continue"); } draw_info->fill = fill; new_image = rm_clone_image(image); rm_init_magickpixel(new_image, &target_mpp); if (fill_method == FillToBorderMethod) { invert = MagickTrue; target_mpp.red = (MagickRealType) image->border_color.red; target_mpp.green = (MagickRealType) image->border_color.green; target_mpp.blue = (MagickRealType) image->border_color.blue; } else { invert = MagickFalse; target_mpp.red = (MagickRealType) target.red; target_mpp.green = (MagickRealType) target.green; target_mpp.blue = (MagickRealType) target.blue; } #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); FloodfillPaintImage(new_image, draw_info, &target_mpp, x, y, invert, exception); DestroyDrawInfo(draw_info); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else FloodfillPaintImage(new_image, DefaultChannels, draw_info, &target_mpp, x, y, invert); DestroyDrawInfo(draw_info); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#color_floodfill(x, y, fill) ⇒ Object
Set all pixels that have the same color as the pixel at x,y and are neighbors to the fill color
839 840 841 842 |
# File 'lib/rmagick_internal.rb', line 839 def color_floodfill(x, y, fill) target = pixel_color(x, y) color_flood_fill(target, fill, x, y, Magick::FloodfillMethod) end |
#color_histogram ⇒ Hash
Computes the number of times each unique color appears in the image.
2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 |
# File 'ext/RMagick/rmimage.c', line 2547 VALUE Image_color_histogram(VALUE self) { Image *image, *dc_copy = NULL; VALUE hash, pixel; size_t x, colors; ExceptionInfo *exception; #if defined(IMAGEMAGICK_7) PixelInfo *histogram; #else ColorPacket *histogram; #endif image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); // If image not DirectClass make a DirectClass copy. if (image->storage_class != DirectClass) { dc_copy = rm_clone_image(image); #if defined(IMAGEMAGICK_7) SetImageStorageClass(dc_copy, DirectClass, exception); #else SetImageStorageClass(dc_copy, DirectClass); #endif image = dc_copy; } histogram = GetImageHistogram(image, &colors, exception); if (histogram == NULL) { if (dc_copy) { DestroyImage(dc_copy); } rb_raise(rb_eNoMemError, "not enough memory to continue"); } if (rm_should_raise_exception(exception, DestroyExceptionRetention)) { RelinquishMagickMemory(histogram); if (dc_copy) { DestroyImage(dc_copy); } rm_raise_exception(exception); } hash = rb_hash_new(); for (x = 0; x < colors; x++) { #if defined(IMAGEMAGICK_7) pixel = Pixel_from_PixelColor(&histogram[x]); #else pixel = Pixel_from_PixelColor(&histogram[x].pixel); #endif rb_hash_aset(hash, pixel, ULONG2NUM((unsigned long)histogram[x].count)); } /* Christy evidently didn't agree with Bob's memory management. */ RelinquishMagickMemory(histogram); if (dc_copy) { // Do not trace destruction DestroyImage(dc_copy); } RB_GC_GUARD(hash); RB_GC_GUARD(pixel); return hash; } |
#color_point(x, y, fill) ⇒ Object
Set the color at x,y
831 832 833 834 835 |
# File 'lib/rmagick_internal.rb', line 831 def color_point(x, y, fill) f = copy f.pixel_color(x, y, fill) f end |
#color_profile ⇒ String?
Return the ICC color profile as a String.
-
If there is no profile, returns “”
-
This method has no real use but is retained for compatibility with earlier releases of RMagick, where it had no real use either.
2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 |
# File 'ext/RMagick/rmimage.c', line 2735 VALUE Image_color_profile(VALUE self) { Image *image; const StringInfo *profile; image = rm_check_destroyed(self); profile = GetImageProfile(image, "icc"); if (!profile) { return Qnil; } return rb_str_new((char *)profile->datum, (long)profile->length); } |
#color_profile=(profile) ⇒ String
Set the ICC color profile.
-
Pass nil to remove any existing profile.
-
Removes any existing profile before adding the new one.
2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 |
# File 'ext/RMagick/rmimage.c', line 2762 VALUE Image_color_profile_eq(VALUE self, VALUE profile) { Image_delete_profile(self, rb_str_new2("ICC")); if (profile != Qnil) { set_profile(self, "ICC", profile); } return profile; } |
#color_reset!(fill) ⇒ Object
Set all pixels to the fill color. Very similar to Image#erase! Accepts either String or Pixel arguments
852 853 854 855 856 857 858 859 860 861 862 863 864 |
# File 'lib/rmagick_internal.rb', line 852 def color_reset!(fill) save = background_color # Change the background color _outside_ the begin block # so that if this object is frozen the exeception will be # raised before we have to handle it explicitly. self.background_color = fill begin erase! ensure self.background_color = save end self end |
#colorize(red, green, blue, target) ⇒ Magick::Image #colorize(red, green, blue, matte, target) ⇒ Magick::Image
Blend the fill color specified by “target” with each pixel in the image. Specify the percentage blend for each r, g, b component.
2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 |
# File 'ext/RMagick/rmimage.c', line 2884 VALUE Image_colorize(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double red, green, blue, matte; char opacity[50]; PixelColor target; ExceptionInfo *exception; image = rm_check_destroyed(self); if (argc == 4) { red = floor(100*NUM2DBL(argv[0])+0.5); green = floor(100*NUM2DBL(argv[1])+0.5); blue = floor(100*NUM2DBL(argv[2])+0.5); Color_to_PixelColor(&target, argv[3]); snprintf(opacity, sizeof(opacity), "%f/%f/%f", red, green, blue); } else if (argc == 5) { red = floor(100*NUM2DBL(argv[0])+0.5); green = floor(100*NUM2DBL(argv[1])+0.5); blue = floor(100*NUM2DBL(argv[2])+0.5); matte = floor(100*NUM2DBL(argv[3])+0.5); Color_to_PixelColor(&target, argv[4]); snprintf(opacity, sizeof(opacity), "%f/%f/%f/%f", red, green, blue, matte); } else { rb_raise(rb_eArgError, "wrong number of arguments (%d for 4 or 5)", argc); } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) new_image = ColorizeImage(image, opacity, &target, exception); #else new_image = ColorizeImage(image, opacity, target, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#colormap(index) ⇒ String #colormap(index, new_color) ⇒ String
Return the color in the colormap at the specified index. If a new color is specified, replaces the color at the index with the new color.
2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 |
# File 'ext/RMagick/rmimage.c', line 2947 VALUE Image_colormap(int argc, VALUE *argv, VALUE self) { Image *image; unsigned long idx; PixelColor color, new_color; image = rm_check_destroyed(self); // We can handle either 1 or 2 arguments. Nothing else. if (argc == 0 || argc > 2) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc); } idx = NUM2ULONG(argv[0]); if (idx > QuantumRange) { rb_raise(rb_eIndexError, "index out of range"); } // If this is a simple "get" operation, ensure the image has a colormap. if (argc == 1) { if (!image->colormap) { rb_raise(rb_eIndexError, "image does not contain a colormap"); } // Validate the index if (idx > image->colors-1) { rb_raise(rb_eIndexError, "index out of range"); } return rm_pixelcolor_to_color_name(image, &image->colormap[idx]); } // This is a "set" operation. Things are different. rb_check_frozen(self); // Replace with new color? The arg can be either a color name or // a Magick::Pixel. Color_to_PixelColor(&new_color, argv[1]); // Handle no colormap or current colormap too small. if (!image->colormap || idx > image->colors-1) { PixelColor black; unsigned long i; memset(&black, 0, sizeof(black)); if (!image->colormap) { image->colormap = (PixelColor *)magick_safe_malloc((idx+1), sizeof(PixelColor)); image->colors = 0; } else { image->colormap = (PixelColor *)magick_safe_realloc(image->colormap, (idx+1), sizeof(PixelColor)); } for (i = image->colors; i < idx; i++) { image->colormap[i] = black; } image->colors = idx+1; } // Save the current color so we can return it. Set the new color. color = image->colormap[idx]; image->colormap[idx] = new_color; return rm_pixelcolor_to_color_name(image, &color); } |
#colors ⇒ Numeric
Get the number of colors in the colormap.
3029 3030 3031 3032 3033 |
# File 'ext/RMagick/rmimage.c', line 3029 VALUE Image_colors(VALUE self) { IMPLEMENT_ATTR_READER(Image, colors, ulong); } |
#colorspace ⇒ Magick::ColorspaceType
Return the Image pixel interpretation. If the colorspace is RGB the pixels are red, green, blue. If matte is true, then red, green, blue, and index. If it is CMYK, the pixels are cyan, yellow, magenta, black. Otherwise the colorspace is ignored.
3042 3043 3044 3045 3046 3047 3048 3049 |
# File 'ext/RMagick/rmimage.c', line 3042 VALUE Image_colorspace(VALUE self) { Image *image; image = rm_check_destroyed(self); return ColorspaceType_find(image->colorspace); } |
#colorspace=(colorspace) ⇒ Magick::ColorspaceType
Set the image’s colorspace.
3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 |
# File 'ext/RMagick/rmimage.c', line 3058 VALUE Image_colorspace_eq(VALUE self, VALUE colorspace) { Image *image; ColorspaceType new_cs; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_frozen(self); VALUE_TO_ENUM(colorspace, new_cs, ColorspaceType); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); TransformImageColorspace(image, new_cs, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else TransformImageColorspace(image, new_cs); rm_check_image_exception(image, RetainOnError); #endif return colorspace; } |
#columns ⇒ Numeric
Get image columns.
3089 3090 3091 3092 3093 |
# File 'ext/RMagick/rmimage.c', line 3089 VALUE Image_columns(VALUE self) { IMPLEMENT_ATTR_READER(Image, columns, int); } |
#compare_channel(image, metric, channel = Magick::AllChannels) ⇒ Array #compare_channel(image, metric, channel = Magick::AllChannels) {|Magick::OptionalMethodArguments| ... } ⇒ Array #compare_channel(image, metric, *channels) ⇒ Array #compare_channel(image, metric, *channels) {|Magick::OptionalMethodArguments| ... } ⇒ Array
Compare one or more channels in two images and returns the specified distortion metric and a comparison image.
3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 |
# File 'ext/RMagick/rmimage.c', line 3143 VALUE Image_compare_channel(int argc, VALUE *argv, VALUE self) { Image *image, *r_image, *difference_image; double distortion; VALUE ary, ref; MetricType metric_type; ChannelType channels; ExceptionInfo *exception; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); if (argc > 2) { raise_ChannelType_error(argv[argc-1]); } if (argc != 2) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or more)", argc); } rm_get_optional_arguments(self); ref = rm_cur_image(argv[0]); r_image = rm_check_destroyed(ref); VALUE_TO_ENUM(argv[1], metric_type, MetricType); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); difference_image = CompareImages(image, r_image, metric_type, &distortion, exception); END_CHANNEL_MASK(image); #else difference_image = CompareImageChannels(image, r_image, channels, metric_type, &distortion, exception); #endif rm_check_exception(exception, difference_image, DestroyOnError); DestroyExceptionInfo(exception); ary = rb_ary_new2(2); rb_ary_store(ary, 0, rm_image_new(difference_image)); rb_ary_store(ary, 1, rb_float_new(distortion)); RB_GC_GUARD(ary); RB_GC_GUARD(ref); return ary; } |
#compose ⇒ Magick::CompositeOperator
Return the composite operator attribute.
3200 3201 3202 3203 3204 3205 |
# File 'ext/RMagick/rmimage.c', line 3200 VALUE Image_compose(VALUE self) { Image *image = rm_check_destroyed(self); return CompositeOperator_find(image->compose); } |
#compose=(compose_arg) ⇒ Magick::CompositeOperator
Set the composite operator attribute.
3214 3215 3216 3217 3218 3219 3220 |
# File 'ext/RMagick/rmimage.c', line 3214 VALUE Image_compose_eq(VALUE self, VALUE compose_arg) { Image *image = rm_check_frozen(self); VALUE_TO_ENUM(compose_arg, image->compose, CompositeOperator); return compose_arg; } |
#composite(image, x_off, y_off, composite_op) ⇒ Magick::Image #composite(image, gravity, composite_op) ⇒ Magick::Image #composite(image, gravity, x_off, y_off, composite_op) ⇒ Magick::Image
Composites src onto dest using the specified composite operator.
3483 3484 3485 3486 3487 |
# File 'ext/RMagick/rmimage.c', line 3483 VALUE Image_composite(int argc, VALUE *argv, VALUE self) { return composite(False, argc, argv, self, DefaultChannels); } |
#composite!(image, x_off, y_off, composite_op) ⇒ Magick::Image #composite!(image, gravity, composite_op) ⇒ Magick::Image #composite!(image, gravity, x_off, y_off, composite_op) ⇒ Magick::Image
Composites src onto dest using the specified composite operator. In-place form of #composite.
3443 3444 3445 3446 3447 |
# File 'ext/RMagick/rmimage.c', line 3443 VALUE Image_composite_bang(int argc, VALUE *argv, VALUE self) { return composite(True, argc, argv, self, DefaultChannels); } |
#composite_affine(source, affine_matrix) ⇒ Magick::Image
Composite the source over the destination image as dictated by the affine transform.
3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 |
# File 'ext/RMagick/rmimage.c', line 3497 VALUE Image_composite_affine(VALUE self, VALUE source, VALUE affine_matrix) { Image *image, *composite_image, *new_image; AffineMatrix affine; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); composite_image = rm_check_destroyed(source); Export_AffineMatrix(&affine, affine_matrix); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); DrawAffineImage(new_image, composite_image, &affine, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else DrawAffineImage(new_image, composite_image, &affine); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#composite_channel(image, x_off, y_off, composite_op, channel = Magick::AllChannels) ⇒ Magick::Image #composite_channel(image, x_off, y_off, composite_op, *channels) ⇒ Magick::Image #composite_channel(image, gravity, composite_op, channel = Magick::AllChannels) ⇒ Magick::Image #composite_channel(image, gravity, composite_op, *channels) ⇒ Magick::Image #composite_channel(image, gravity, x_off, y_off, composite_op, channel = Magick::AllChannels) ⇒ Magick::Image #composite_channel(image, gravity, x_off, y_off, composite_op, *channels) ⇒ Magick::Image
Composite the source over the destination image channel as dictated by the affine transform.
3631 3632 3633 3634 3635 |
# File 'ext/RMagick/rmimage.c', line 3631 VALUE Image_composite_channel(int argc, VALUE *argv, VALUE self) { return composite_channel(False, argc, argv, self); } |
#composite_channel!(image, x_off, y_off, composite_op, channel = Magick::AllChannels) ⇒ Magick::Image #composite_channel!(image, x_off, y_off, composite_op, *channels) ⇒ Magick::Image #composite_channel!(image, gravity, composite_op, channel = Magick::AllChannels) ⇒ Magick::Image #composite_channel!(image, gravity, composite_op, *channels) ⇒ Magick::Image #composite_channel!(image, gravity, x_off, y_off, composite_op, channel = Magick::AllChannels) ⇒ Magick::Image #composite_channel!(image, gravity, x_off, y_off, composite_op, *channels) ⇒ Magick::Image
Composite the source over the destination image channel as dictated by the affine transform. In-place form of #composite_channel.
3706 3707 3708 3709 3710 |
# File 'ext/RMagick/rmimage.c', line 3706 VALUE Image_composite_channel_bang(int argc, VALUE *argv, VALUE self) { return composite_channel(True, argc, argv, self); } |
#composite_mathematics(image, a, b, c, d, gravity) ⇒ Magick::Image #composite_mathematics(image, a, b, c, d, x_off, y_off) ⇒ Magick::Image #composite_mathematics(image, a, b, c, d, gravity, x_off, y_off) ⇒ Magick::Image
Merge the source and destination images according to the formula
a*Sc*Dc + b*Sc + c*Dc + d
where Sc is the source pixel and Dc is the destination pixel.
3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 |
# File 'ext/RMagick/rmimage.c', line 3754 VALUE Image_composite_mathematics(int argc, VALUE *argv, VALUE self) { Image *composite_image; VALUE args[5]; signed long x_off = 0L; signed long y_off = 0L; GravityType gravity = NorthWestGravity; char compose_args[200]; rm_check_destroyed(self); switch (argc) { case 8: VALUE_TO_ENUM(argv[5], gravity, GravityType); x_off = NUM2LONG(argv[6]); y_off = NUM2LONG(argv[7]); break; case 7: x_off = NUM2LONG(argv[5]); y_off = NUM2LONG(argv[6]); break; case 6: VALUE_TO_ENUM(argv[5], gravity, GravityType); break; default: rb_raise(rb_eArgError, "wrong number of arguments (got %d, expected 6 to 8)", argc); break; } composite_image = rm_check_destroyed(rm_cur_image(argv[0])); snprintf(compose_args, sizeof(compose_args), "%-.16g,%-.16g,%-.16g,%-.16g", NUM2DBL(argv[1]), NUM2DBL(argv[2]), NUM2DBL(argv[3]), NUM2DBL(argv[4])); SetImageArtifact(composite_image, "compose:args", compose_args); // Call composite(False, gravity, x_off, y_off, MathematicsCompositeOp, DefaultChannels) args[0] = argv[0]; args[1] = GravityType_find(gravity); args[2] = LONG2FIX(x_off); args[3] = LONG2FIX(y_off); args[4] = CompositeOperator_find(MathematicsCompositeOp); return composite(False, 5, args, self, DefaultChannels); } |
#composite_tiled(src, composite_op = Magick::OverCompositeOp, channel = Magick::AllChannels) ⇒ Magick::Image #composite_tiled(src, composite_op = Magick::OverCompositeOp, *channels) ⇒ Magick::Image
Composites multiple copies of the source image across and down the image, producing the same results as ImageMagick’s composite command with the -tile option.
3919 3920 3921 3922 3923 |
# File 'ext/RMagick/rmimage.c', line 3919 VALUE Image_composite_tiled(int argc, VALUE *argv, VALUE self) { return composite_tiled(False, argc, argv, self); } |
#composite_tiled!(src, composite_op = Magick::OverCompositeOp, channel = Magick::AllChannels) ⇒ Magick::Image #composite_tiled!(src, composite_op = Magick::OverCompositeOp, *channels) ⇒ Magick::Image
Composites multiple copies of the source image across and down the image, producing the same results as ImageMagick’s composite command with the -tile option. In-place form of #composite_tiled.
3946 3947 3948 3949 3950 |
# File 'ext/RMagick/rmimage.c', line 3946 VALUE Image_composite_tiled_bang(int argc, VALUE *argv, VALUE self) { return composite_tiled(True, argc, argv, self); } |
#compress_colormap! ⇒ Magick::Image
Removes duplicate or unused entries in the colormap. Only PseudoClass images have a colormap. If the image is DirectClass then compress_colormap! converts it to PseudoClass.
3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 |
# File 'ext/RMagick/rmimage.c', line 3986 VALUE Image_compress_colormap_bang(VALUE self) { Image *image; MagickBooleanType okay; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_frozen(self); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); okay = CompressImageColormap(image, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else okay = CompressImageColormap(image); rm_check_image_exception(image, RetainOnError); #endif if (!okay) { rb_warning("CompressImageColormap failed (probably DirectClass image)"); } return self; } |
#compression ⇒ Magick::CompressionType
Get the compression attribute.
3958 3959 3960 3961 3962 3963 |
# File 'ext/RMagick/rmimage.c', line 3958 VALUE Image_compression(VALUE self) { Image *image = rm_check_destroyed(self); return CompressionType_find(image->compression); } |
#compression=(compression) ⇒ Magick::CompressionType
Set the compression attribute.
3971 3972 3973 3974 3975 3976 3977 |
# File 'ext/RMagick/rmimage.c', line 3971 VALUE Image_compression_eq(VALUE self, VALUE compression) { Image *image = rm_check_frozen(self); VALUE_TO_ENUM(compression, image->compression, CompressionType); return compression; } |
#contrast(sharpen = false) ⇒ Magick::Image
Enhance the intensity differences between the lighter and darker elements of the image.
4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 |
# File 'ext/RMagick/rmimage.c', line 4194 VALUE Image_contrast(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; unsigned int sharpen = 0; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); if (argc > 1) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc); } else if (argc == 1) { sharpen = RTEST(argv[0]); } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); ContrastImage(new_image, sharpen, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else ContrastImage(new_image, sharpen); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#contrast_stretch_channel(black_point, white_point = pixels-black_point, channel = Magick::AllChannels) ⇒ Magick::Image #contrast_stretch_channel(black_point, white_point = pixels-black_point, *channels) ⇒ Magick::Image
This method is a simple image enhancement technique that attempts to improve the contrast in an image by ‘stretching’ the range of intensity values it contains to span a desired range of values. It differs from the more sophisticated histogram equalization in that it can only apply a linear scaling function to the image pixel values.
4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 |
# File 'ext/RMagick/rmimage.c', line 4317 VALUE Image_contrast_stretch_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; ChannelType channels; double black_point, white_point; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); if (argc > 2) { raise_ChannelType_error(argv[argc-1]); } get_black_white_point(image, argc, argv, &black_point, &white_point); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(new_image, channels); ContrastStretchImage(new_image, black_point, white_point, exception); END_CHANNEL_MASK(new_image); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else ContrastStretchImageChannel(new_image, channels, black_point, white_point); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#convolve(order_arg, kernel_arg) ⇒ Magick::Image
Apply a custom convolution kernel to the image.
4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 |
# File 'ext/RMagick/rmimage.c', line 4488 VALUE Image_convolve(VALUE self, VALUE order_arg, VALUE kernel_arg) { Image *image, *new_image; int order; ExceptionInfo *exception; #if defined(IMAGEMAGICK_7) KernelInfo *kernel; #else double *kernel; unsigned int x; #endif image = rm_check_destroyed(self); order = NUM2INT(order_arg); if (order <= 0) { rb_raise(rb_eArgError, "order must be non-zero and positive"); } kernel_arg = rb_Array(kernel_arg); rm_check_ary_len(kernel_arg, (long)(order*order)); #if defined(IMAGEMAGICK_7) kernel = convolve_create_kernel_info(order, kernel_arg); #else // Convert the kernel array argument to an array of doubles kernel = (double *)ALLOC_N(double, order*order); for (x = 0; x < (unsigned)(order * order); x++) { VALUE element = rb_ary_entry(kernel_arg, (long)x); if (rm_check_num2dbl(element)) { kernel[x] = NUM2DBL(element); } else { xfree((void *)kernel); rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element))); } } #endif exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) new_image = ConvolveImage(image, kernel, exception); DestroyKernelInfo(kernel); #else new_image = ConvolveImage(image, order, kernel, exception); xfree((void *)kernel); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#convolve_channel(order, kernel, channel = Magick::AllChannels) ⇒ Magick::Image #convolve_channel(order, kernel, *channels) ⇒ Magick::Image
Applies a custom convolution kernel to the specified channel or channels in the image.
4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 |
# File 'ext/RMagick/rmimage.c', line 4566 VALUE Image_convolve_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; VALUE ary; int order; ChannelType channels; ExceptionInfo *exception; #if defined(IMAGEMAGICK_7) KernelInfo *kernel; #else double *kernel; unsigned int x; #endif image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // There are 2 required arguments. if (argc > 2) { raise_ChannelType_error(argv[argc-1]); } if (argc != 2) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or more)", argc); } order = NUM2INT(argv[0]); if (order <= 0) { rb_raise(rb_eArgError, "order must be non-zero and positive"); } ary = rb_Array(argv[1]); rm_check_ary_len(ary, (long)(order*order)); #if defined(IMAGEMAGICK_7) kernel = convolve_create_kernel_info(order, ary); #else kernel = ALLOC_N(double, (long)(order*order)); // Convert the kernel array argument to an array of doubles for (x = 0; x < (unsigned)(order * order); x++) { VALUE element = rb_ary_entry(ary, (long)x); if (rm_check_num2dbl(element)) { kernel[x] = NUM2DBL(element); } else { xfree((void *)kernel); rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element))); } } #endif exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); new_image = ConvolveImage(image, kernel, exception); CHANGE_RESULT_CHANNEL_MASK(new_image); END_CHANNEL_MASK(image); DestroyKernelInfo(kernel); #else new_image = ConvolveImageChannel(image, channels, order, kernel, exception); xfree((void *)kernel); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); RB_GC_GUARD(ary); return rm_image_new(new_image); } |
#copy ⇒ Magick::Image
Alias for #dup.
4653 4654 4655 4656 4657 |
# File 'ext/RMagick/rmimage.c', line 4653 VALUE Image_copy(VALUE self) { return rb_funcall(self, rm_ID_dup, 0); } |
#crop(x, y, width, height, reset = false) ⇒ Magick::Image #crop(gravity, width, height, reset = false) ⇒ Magick::Image #crop(gravity, x, y, width, height, reset = false) ⇒ Magick::Image
Extract a region of the image defined by width, height, x, y.
4708 4709 4710 4711 4712 4713 |
# File 'ext/RMagick/rmimage.c', line 4708 VALUE Image_crop(int argc, VALUE *argv, VALUE self) { rm_check_destroyed(self); return cropper(False, argc, argv, self); } |
#crop!(reset = false, x, y, width, height) ⇒ Magick::Image #crop!(reset = false, gravity, width, height) ⇒ Magick::Image #crop!(reset = false, gravity, x, y, width, height) ⇒ Magick::Image
Extract a region of the image defined by width, height, x, y. In-place form of #crop.
4744 4745 4746 4747 4748 4749 |
# File 'ext/RMagick/rmimage.c', line 4744 VALUE Image_crop_bang(int argc, VALUE *argv, VALUE self) { rm_check_frozen(self); return cropper(True, argc, argv, self); } |
#cur_image ⇒ Object
Used by ImageList methods - see ImageList#cur_image
867 868 869 |
# File 'lib/rmagick_internal.rb', line 867 def cur_image self end |
#cycle_colormap(amount) ⇒ Magick::Image
Displaces the colormap by a given number of positions. If you cycle the colormap a number of times you can produce a psychedelic effect.
The returned image is always a PseudoClass image, regardless of the type of the original image.
4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 |
# File 'ext/RMagick/rmimage.c', line 4761 VALUE Image_cycle_colormap(VALUE self, VALUE amount) { Image *image, *new_image; int amt; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif amt = NUM2INT(amount); image = rm_check_destroyed(self); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); CycleColormapImage(new_image, amt, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else CycleColormapImage(new_image, amt); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#decipher(passphrase) ⇒ Magick::Image
Decipher an enciphered image.
4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 |
# File 'ext/RMagick/rmimage.c', line 4902 VALUE Image_decipher(VALUE self, VALUE passphrase) { Image *image, *new_image; char *pf; ExceptionInfo *exception; MagickBooleanType okay; image = rm_check_destroyed(self); pf = StringValueCStr(passphrase); // ensure passphrase is a string exception = AcquireExceptionInfo(); new_image = rm_clone_image(image); okay = DecipherImage(new_image, pf, exception); rm_check_exception(exception, new_image, DestroyOnError); if (!okay) { DestroyImage(new_image); rb_raise(rb_eRuntimeError, "DecipherImage failed for unknown reason."); } DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#define(artifact, value) ⇒ String
Associates makes a copy of the given string arguments and inserts it into the artifact tree.
-
Normally a script should never call this method. Any calls to SetImageArtifact will be part of the methods in which they’re needed, or be called via the OptionalMethodArguments class.
-
If value is nil, the artifact will be removed
4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 |
# File 'ext/RMagick/rmimage.c', line 4943 VALUE Image_define(VALUE self, VALUE artifact, VALUE value) { Image *image; char *key, *val; MagickBooleanType status; image = rm_check_frozen(self); artifact = rb_String(artifact); key = StringValueCStr(artifact); if (value == Qnil) { DeleteImageArtifact(image, key); } else { value = rb_String(value); val = StringValueCStr(value); status = SetImageArtifact(image, key, val); if (!status) { rb_raise(rb_eNoMemError, "not enough memory to continue"); } } return value; } |
#delay ⇒ Numeric
Get the Number of ticks which must expire before displaying the next image in an animated sequence. The default number of ticks is 0. By default there are 100 ticks per second but this number can be changed via the ticks_per_second attribute.
4980 4981 4982 4983 4984 |
# File 'ext/RMagick/rmimage.c', line 4980 VALUE Image_delay(VALUE self) { IMPLEMENT_ATTR_READER(Image, delay, ulong); } |
#delay=(val) ⇒ Numeric
Set the Number of ticks which must expire before displaying the next image in an animated sequence.
4993 4994 4995 4996 4997 |
# File 'ext/RMagick/rmimage.c', line 4993 VALUE Image_delay_eq(VALUE self, VALUE val) { IMPLEMENT_ATTR_WRITER(Image, delay, ulong); } |
#delete_compose_mask ⇒ Magick::Image
Delete the image composite mask.
5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 |
# File 'ext/RMagick/rmimage.c', line 5006 VALUE Image_delete_compose_mask(VALUE self) { Image *image; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_frozen(self); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); SetImageMask(image, CompositePixelMask, NULL, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else SetImageMask(image, NULL); rm_check_image_exception(image, RetainOnError); #endif return self; } |
#delete_profile(name) ⇒ Magick::Image
Deletes the specified profile.
5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 |
# File 'ext/RMagick/rmimage.c', line 5038 VALUE Image_delete_profile(VALUE self, VALUE name) { Image *image = rm_check_frozen(self); #if defined(IMAGEMAGICK_7) ExceptionInfo *exception = AcquireExceptionInfo(); ProfileImage(image, StringValueCStr(name), NULL, 0, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else ProfileImage(image, StringValueCStr(name), NULL, 0, MagickTrue); #endif return self; } |
#density ⇒ String
Get the vertical and horizontal resolution in pixels of the image. The default is “72x72”.
4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 |
# File 'ext/RMagick/rmimage.c', line 4796 VALUE Image_density(VALUE self) { Image *image; char density[128]; image = rm_check_destroyed(self); #if defined(IMAGEMAGICK_7) snprintf(density, sizeof(density), "%gx%g", image->resolution.x, image->resolution.y); #else snprintf(density, sizeof(density), "%gx%g", image->x_resolution, image->y_resolution); #endif return rb_str_new2(density); } |
#density=(density_arg) ⇒ String, Magick::Geometry
Set the vertical and horizontal resolution in pixels of the image.
-
The density is a string of the form “XresxYres” or simply “Xres”.
-
If the y resolution is not specified, set it equal to the x resolution.
-
This is equivalent to PerlMagick’s handling of density.
-
The density can also be a Geometry object. The width attribute is used for the x resolution. The height attribute is used for the y resolution. If the height attribute is missing, the width attribute is used for both.
4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 |
# File 'ext/RMagick/rmimage.c', line 4827 VALUE Image_density_eq(VALUE self, VALUE density_arg) { Image *image; char *density; VALUE x_val, y_val; int count; double x_res, y_res; image = rm_check_frozen(self); // Get the Class ID for the Geometry class. if (!Class_Geometry) { Class_Geometry = rb_const_get(Module_Magick, rm_ID_Geometry); } // Geometry object. Width and height attributes are always positive. if (CLASS_OF(density_arg) == Class_Geometry) { x_val = rb_funcall(density_arg, rm_ID_width, 0); x_res = NUM2DBL(x_val); y_val = rb_funcall(density_arg, rm_ID_height, 0); y_res = NUM2DBL(y_val); if (x_res == 0.0) { rb_raise(rb_eArgError, "invalid x resolution: %f", x_res); } #if defined(IMAGEMAGICK_7) image->resolution.y = y_res != 0.0 ? y_res : x_res; image->resolution.x = x_res; #else image->y_resolution = y_res != 0.0 ? y_res : x_res; image->x_resolution = x_res; #endif } // Convert the argument to a string else { density = StringValueCStr(density_arg); if (!IsGeometry(density)) { rb_raise(rb_eArgError, "invalid density geometry %s", density); } #if defined(IMAGEMAGICK_7) count = sscanf(density, "%lfx%lf", &image->resolution.x, &image->resolution.y); #else count = sscanf(density, "%lfx%lf", &image->x_resolution, &image->y_resolution); #endif if (count < 2) { #if defined(IMAGEMAGICK_7) image->resolution.y = image->resolution.x; #else image->y_resolution = image->x_resolution; #endif } } RB_GC_GUARD(x_val); RB_GC_GUARD(y_val); return density_arg; } |
#depth ⇒ Numeric
Return the image depth (8, 16 or 32).
-
If all pixels have lower-order bytes equal to higher-order bytes, the depth will be reported as 8 even if the depth field in the Image structure says 16.
5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 |
# File 'ext/RMagick/rmimage.c', line 5064 VALUE Image_depth(VALUE self) { Image *image; unsigned long depth = 0; ExceptionInfo *exception; image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); depth = GetImageDepth(image, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); return INT2FIX(depth); } |
#deskew(threshold = 0.40, auto_crop_width = nil) ⇒ Magick::Image
Straightens an image. A threshold of 40% works for most images.
5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 |
# File 'ext/RMagick/rmimage.c', line 5093 VALUE Image_deskew(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double threshold = 40.0 * QuantumRange / 100.0; unsigned long width; char auto_crop_width[20]; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 2: width = NUM2ULONG(argv[1]); memset(auto_crop_width, 0, sizeof(auto_crop_width)); snprintf(auto_crop_width, sizeof(auto_crop_width), "%lu", width); SetImageArtifact(image, "deskew:auto-crop", auto_crop_width); case 1: threshold = rm_percentage(argv[0], 1.0) * QuantumRange; case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc); break; } exception = AcquireExceptionInfo(); new_image = DeskewImage(image, threshold, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#despeckle ⇒ Magick::Image
Reduce the speckle noise in an image while preserving the edges of the original image.
5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 |
# File 'ext/RMagick/rmimage.c', line 5134 VALUE Image_despeckle(VALUE self) { Image *image, *new_image; ExceptionInfo *exception; image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); new_image = DespeckleImage(image, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#destroy! ⇒ Magick::Image
Free all the memory associated with an image.
5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 |
# File 'ext/RMagick/rmimage.c', line 5156 VALUE Image_destroy_bang(VALUE self) { Image *image; rb_check_frozen(self); Data_Get_Struct(self, Image, image); rm_image_destroy(image); DATA_PTR(self) = NULL; return self; } |
#destroyed? ⇒ Boolean
Return true if the image has been destroyed, false otherwise.
5174 5175 5176 5177 5178 5179 5180 5181 |
# File 'ext/RMagick/rmimage.c', line 5174 VALUE Image_destroyed_q(VALUE self) { Image *image; Data_Get_Struct(self, Image, image); return image ? Qfalse : Qtrue; } |
#difference(other) ⇒ Array<Float>
Compares two images and computes statistics about their difference.
5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 |
# File 'ext/RMagick/rmimage.c', line 5201 VALUE Image_difference(VALUE self, VALUE other) { Image *image; Image *image2; VALUE mean, nmean, nmax; #if defined(IMAGEMAGICK_7) double distortion; ExceptionInfo *exception; #endif image = rm_check_destroyed(self); other = rm_cur_image(other); image2 = rm_check_destroyed(other); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); GetImageDistortion(image, image2, MeanErrorPerPixelErrorMetric, &distortion, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else IsImagesEqual(image, image2); rm_check_image_exception(image, RetainOnError); #endif mean = rb_float_new(image->error.mean_error_per_pixel); nmean = rb_float_new(image->error.normalized_mean_error); nmax = rb_float_new(image->error.normalized_maximum_error); RB_GC_GUARD(mean); RB_GC_GUARD(nmean); RB_GC_GUARD(nmax); return rb_ary_new3(3, mean, nmean, nmax); } |
#directory ⇒ String
Get image directory.
5243 5244 5245 5246 5247 |
# File 'ext/RMagick/rmimage.c', line 5243 VALUE Image_directory(VALUE self) { IMPLEMENT_ATTR_READER(Image, directory, str); } |
#dispatch(x, y, columns, rows, map, float = false) ⇒ Array<Numeric>
Extract pixel data from the image and returns it as an array of pixels. The “x”, “y”, “width” and “height” parameters specify the rectangle to be extracted. The “map” parameter reflects the expected ordering of the pixel array. It can be any combination or order of R = red, G = green, B = blue, A = alpha, C = cyan, Y = yellow, M = magenta, K = black, or I = intensity (for grayscale). If the “float” parameter is specified and true, the pixel data is returned as floating-point numbers in the range [0..1]. By default the pixel data is returned as integers in the range [0..QuantumRange].
5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 |
# File 'ext/RMagick/rmimage.c', line 5327 VALUE Image_dispatch(int argc, VALUE *argv, VALUE self) { Image *image; long x, y; unsigned long columns, rows, n, npixels; VALUE pixels_ary; StorageType stg_type = QuantumPixel; char *map; long mapL; MagickBooleanType okay; ExceptionInfo *exception; volatile union { Quantum *i; double *f; void *v; } pixels; rm_check_destroyed(self); if (argc < 5 || argc > 6) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 5 or 6)", argc); } x = NUM2LONG(argv[0]); y = NUM2LONG(argv[1]); columns = NUM2ULONG(argv[2]); rows = NUM2ULONG(argv[3]); map = rm_str2cstr(argv[4], &mapL); if (argc == 6) { stg_type = RTEST(argv[5]) ? DoublePixel : QuantumPixel; } // Compute the size of the pixel array and allocate the memory. npixels = columns * rows * mapL; pixels.v = stg_type == QuantumPixel ? (void *) ALLOC_N(Quantum, npixels) : (void *) ALLOC_N(double, npixels); // Create the Ruby array for the pixels. Return this even if ExportImagePixels fails. pixels_ary = rb_ary_new(); Data_Get_Struct(self, Image, image); exception = AcquireExceptionInfo(); okay = ExportImagePixels(image, x, y, columns, rows, map, stg_type, (void *)pixels.v, exception); if (!okay) { goto exit; } CHECK_EXCEPTION(); DestroyExceptionInfo(exception); // Convert the pixel data to the appropriate Ruby type if (stg_type == QuantumPixel) { for (n = 0; n < npixels; n++) { rb_ary_push(pixels_ary, QUANTUM2NUM(pixels.i[n])); } } else { for (n = 0; n < npixels; n++) { rb_ary_push(pixels_ary, rb_float_new(pixels.f[n])); } } exit: xfree((void *)pixels.v); RB_GC_GUARD(pixels_ary); return pixels_ary; } |
#displace(displacement_map, x_amp, y_amp = x_amp, gravity = Magick::NorthWestGravity, x_offset = 0, y_offset = 0) ⇒ Magick::Image
Uses displacement_map to move color from img to the output image. This method corresponds to the -displace option of ImageMagick’s composite command.
5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 |
# File 'ext/RMagick/rmimage.c', line 5265 VALUE Image_displace(int argc, VALUE *argv, VALUE self) { Image *image, *displacement_map; VALUE dmap; double x_amplitude = 0.0, y_amplitude = 0.0; long x_offset = 0L, y_offset = 0L; image = rm_check_destroyed(self); if (argc < 2) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 to 6)", argc); } dmap = rm_cur_image(argv[0]); displacement_map = rm_check_destroyed(dmap); if (argc > 3) { get_composite_offsets(argc-3, &argv[3], image, displacement_map, &x_offset, &y_offset); // There must be 3 arguments left argc = 3; } switch (argc) { case 3: y_amplitude = NUM2DBL(argv[2]); x_amplitude = NUM2DBL(argv[1]); break; case 2: x_amplitude = NUM2DBL(argv[1]); y_amplitude = x_amplitude; break; } RB_GC_GUARD(dmap); return special_composite(image, displacement_map, x_amplitude, y_amplitude, x_offset, y_offset, DisplaceCompositeOp); } |
#display ⇒ Magick::Image Also known as: __display__
Display the image to an X window screen.
5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 |
# File 'ext/RMagick/rmimage.c', line 5415 VALUE Image_display(VALUE self) { Image *image; Info *info; VALUE info_obj; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); if (image->rows == 0 || image->columns == 0) { rb_raise(rb_eArgError, "invalid image geometry (%"RMIuSIZE"x%"RMIuSIZE")", image->rows, image->columns); } info_obj = rm_info_new(); Data_Get_Struct(info_obj, Info, info); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); DisplayImages(info, image, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else DisplayImages(info, image); rm_check_image_exception(image, RetainOnError); #endif RB_GC_GUARD(info_obj); return self; } |
#dispose ⇒ Magick::DisposeType
Return the dispose attribute as a DisposeType enum.
5456 5457 5458 5459 5460 5461 |
# File 'ext/RMagick/rmimage.c', line 5456 VALUE Image_dispose(VALUE self) { Image *image = rm_check_destroyed(self); return DisposeType_find(image->dispose); } |
#dispose=(dispose) ⇒ Magick::DisposeType
Set the dispose attribute.
5470 5471 5472 5473 5474 5475 5476 |
# File 'ext/RMagick/rmimage.c', line 5470 VALUE Image_dispose_eq(VALUE self, VALUE dispose) { Image *image = rm_check_frozen(self); VALUE_TO_ENUM(dispose, image->dispose, DisposeType); return dispose; } |
#dissolve(overlay, src_percent, dst_percent = -1.0, gravity = Magick::NorthWestGravity, x_offset = 0, y_offset = 0) ⇒ Magick::Image
Composites the overlay image into the target image. The opacity of img is multiplied by dst_percentage and opacity of overlay is multiplied by src_percentage.
This method corresponds to the -dissolve option of ImageMagick’s composite command.
5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 |
# File 'ext/RMagick/rmimage.c', line 5502 VALUE Image_dissolve(int argc, VALUE *argv, VALUE self) { Image *image, *; double src_percent, dst_percent = -1.0; long x_offset = 0L, y_offset = 0L; VALUE composite_image, ovly; image = rm_check_destroyed(self); if (argc < 1) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 to 6)", argc); } ovly = rm_cur_image(argv[0]); = rm_check_destroyed(ovly); if (argc > 3) { get_composite_offsets(argc-3, &argv[3], image, , &x_offset, &y_offset); // There must be 3 arguments left argc = 3; } switch (argc) { case 3: dst_percent = rm_percentage(argv[2], 1.0) * 100.0; case 2: src_percent = rm_percentage(argv[1], 1.0) * 100.0; break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 to 6)", argc); break; } composite_image = special_composite(image, , src_percent, dst_percent, x_offset, y_offset, DissolveCompositeOp); RB_GC_GUARD(composite_image); RB_GC_GUARD(ovly); return composite_image; } |
#distort(type, points, bestfit = false) ⇒ Magick::Image #distort(type, points, bestfit = false) {|Magick::OptionalMethodArguments| ... } ⇒ Magick::Image
Distort an image using the specified distortion type and its required arguments. This method is equivalent to ImageMagick’s -distort option.
5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 |
# File 'ext/RMagick/rmimage.c', line 5590 VALUE Image_distort(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; VALUE pts; unsigned long n, npoints; DistortMethod distortion_method; double *points; MagickBooleanType bestfit = MagickFalse; ExceptionInfo *exception; image = rm_check_destroyed(self); rm_get_optional_arguments(self); switch (argc) { case 3: bestfit = RTEST(argv[2]); case 2: // Ensure pts is an array pts = rb_Array(argv[1]); VALUE_TO_ENUM(argv[0], distortion_method, DistortMethod); break; default: rb_raise(rb_eArgError, "wrong number of arguments (expected 2 or 3, got %d)", argc); break; } npoints = RARRAY_LEN(pts); points = ALLOC_N(double, npoints); for (n = 0; n < npoints; n++) { VALUE element = rb_ary_entry(pts, n); if (rm_check_num2dbl(element)) { points[n] = NUM2DBL(element); } else { xfree(points); rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element))); } } exception = AcquireExceptionInfo(); new_image = DistortImage(image, distortion_method, npoints, points, bestfit, exception); xfree(points); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); RB_GC_GUARD(pts); return rm_image_new(new_image); } |
#distortion_channel(reconstructed_image, metric, channel = Magick::AllChannels) ⇒ Float #distortion_channel(reconstructed_image, metric, *channels) ⇒ Float
Compares one or more image channels of an image to a reconstructed image and returns the specified distortion metric.
5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 |
# File 'ext/RMagick/rmimage.c', line 5665 VALUE Image_distortion_channel(int argc, VALUE *argv, VALUE self) { Image *image, *reconstruct; ChannelType channels; ExceptionInfo *exception; MetricType metric; VALUE rec; double distortion; #if defined(IMAGEMAGICK_7) Image *difference_image; #endif image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); if (argc > 2) { raise_ChannelType_error(argv[argc-1]); } if (argc < 2) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or more)", argc); } rec = rm_cur_image(argv[0]); reconstruct = rm_check_destroyed(rec); VALUE_TO_ENUM(argv[1], metric, MetricType); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); difference_image = CompareImages(image, reconstruct, metric, &distortion, exception); END_CHANNEL_MASK(image); DestroyImage(difference_image); #else GetImageChannelDistortion(image, reconstruct, channels, metric, &distortion, exception); #endif CHECK_EXCEPTION(); DestroyExceptionInfo(exception); RB_GC_GUARD(rec); return rb_float_new(distortion); } |
#dup ⇒ Magick::Image
Duplicates a image.
5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 |
# File 'ext/RMagick/rmimage.c', line 5779 VALUE Image_dup(VALUE self) { VALUE dup; rm_check_destroyed(self); dup = Data_Wrap_Struct(CLASS_OF(self), NULL, rm_image_destroy, NULL); RB_GC_GUARD(dup); return rb_funcall(dup, rm_ID_initialize_copy, 1, self); } |
#each_iptc_dataset ⇒ Object
Iterate over IPTC record number:dataset tags, yield for each non-nil dataset
927 928 929 930 931 932 933 934 935 936 |
# File 'lib/rmagick_internal.rb', line 927 def each_iptc_dataset Magick::IPTC.constants.each do |record| rec = Magick::IPTC.const_get(record) rec.constants.each do |dataset| data_field = get_iptc_dataset(rec.const_get(dataset)) yield(dataset, data_field) unless data_field.nil? end end nil end |
#each_pixel ⇒ Object
Thanks to Russell Norris!
872 873 874 875 876 877 |
# File 'lib/rmagick_internal.rb', line 872 def each_pixel get_pixels(0, 0, columns, rows).each_with_index do |p, n| yield(p, n % columns, n / columns) end self end |
#each_profile {|name, val| ... } ⇒ Object
Calls block once for each profile in the image, passing the profile name and value as parameters.
5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 |
# File 'ext/RMagick/rmimage.c', line 5800 VALUE Image_each_profile(VALUE self) { Image *image; VALUE ary; VALUE val = Qnil; char *name; const StringInfo *profile; image = rm_check_destroyed(self); ResetImageProfileIterator(image); ary = rb_ary_new2(2); name = GetNextImageProfile(image); while (name) { rb_ary_store(ary, 0, rb_str_new2(name)); profile = GetImageProfile(image, name); if (!profile) { rb_ary_store(ary, 1, Qnil); } else { rb_ary_store(ary, 1, rb_str_new((char *)profile->datum, (long)profile->length)); } val = rb_yield(ary); name = GetNextImageProfile(image); } RB_GC_GUARD(ary); RB_GC_GUARD(val); return val; } |
#edge(radius = 0.0) ⇒ Magick::Image
Find edges in an image. “radius” defines the radius of the convolution filter.
5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 |
# File 'ext/RMagick/rmimage.c', line 5846 VALUE Image_edge(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double radius = 0.0; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 1: radius = NUM2DBL(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc); break; } exception = AcquireExceptionInfo(); new_image = EdgeImage(image, radius, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#emboss(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Adds a 3-dimensional effect.
5930 5931 5932 5933 5934 |
# File 'ext/RMagick/rmimage.c', line 5930 VALUE Image_emboss(int argc, VALUE *argv, VALUE self) { return effect_image(self, argc, argv, EmbossImage); } |
#encipher(passphrase) ⇒ Magick::Image
Encipher an image.
5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 |
# File 'ext/RMagick/rmimage.c', line 5945 VALUE Image_encipher(VALUE self, VALUE passphrase) { Image *image, *new_image; char *pf; ExceptionInfo *exception; MagickBooleanType okay; image = rm_check_destroyed(self); pf = StringValueCStr(passphrase); // ensure passphrase is a string exception = AcquireExceptionInfo(); new_image = rm_clone_image(image); okay = EncipherImage(new_image, pf, exception); rm_check_exception(exception, new_image, DestroyOnError); if (!okay) { DestroyImage(new_image); rb_raise(rb_eRuntimeError, "EncipherImage failed for unknown reason."); } DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#endian ⇒ Magick::EndianType
Return endian option for images that support it.
5979 5980 5981 5982 5983 5984 |
# File 'ext/RMagick/rmimage.c', line 5979 VALUE Image_endian(VALUE self) { Image *image = rm_check_destroyed(self); return EndianType_find(image->endian); } |
#endian=(type) ⇒ Magick::EndianType
Set endian option for images that support it.
5993 5994 5995 5996 5997 5998 5999 |
# File 'ext/RMagick/rmimage.c', line 5993 VALUE Image_endian_eq(VALUE self, VALUE type) { Image *image = rm_check_frozen(self); VALUE_TO_ENUM(type, image->endian, EndianType); return type; } |
#enhance ⇒ Magick::Image
Apply a digital filter that improves the quality of a noisy image.
6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 |
# File 'ext/RMagick/rmimage.c', line 6006 VALUE Image_enhance(VALUE self) { Image *image, *new_image; ExceptionInfo *exception; image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); new_image = EnhanceImage(image, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#equalize ⇒ Magick::Image
Apply a histogram equalization to the image.
6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 |
# File 'ext/RMagick/rmimage.c', line 6028 VALUE Image_equalize(VALUE self) { Image *image, *new_image; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); EqualizeImage(new_image, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else EqualizeImage(new_image); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#equalize_channel(channel = Magick::AllChannels) ⇒ Magick::Image #equalize_channel(*channels) ⇒ Magick::Image
Applies a histogram equalization to the image. Only the specified channels are equalized.
6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 |
# File 'ext/RMagick/rmimage.c', line 6064 VALUE Image_equalize_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif ChannelType channels; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); if (argc > 0) { raise_ChannelType_error(argv[argc-1]); } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(new_image, channels); EqualizeImage(new_image, exception); END_CHANNEL_MASK(new_image); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else EqualizeImageChannel(new_image, channels); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#erase! ⇒ Magick::Image
Reset the image to the background color.
6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 |
# File 'ext/RMagick/rmimage.c', line 6104 VALUE Image_erase_bang(VALUE self) { Image *image; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_frozen(self); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); SetImageBackgroundColor(image, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else SetImageBackgroundColor(image); rm_check_image_exception(image, RetainOnError); #endif return self; } |
#excerpt(x, y, width, height) ⇒ Magick::Image
This method is very similar to crop. It extracts the rectangle specified by its arguments from the image and returns it as a new image. However, excerpt does not respect the virtual page offset and does not update the page offset and is more efficient than cropping.
6196 6197 6198 6199 6200 6201 |
# File 'ext/RMagick/rmimage.c', line 6196 VALUE Image_excerpt(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) { rm_check_destroyed(self); return excerpt(False, self, x, y, width, height); } |
#excerpt!(x, y, width, height) ⇒ Magick::Image
In-place form of #excerpt.
This method is very similar to crop. It extracts the rectangle specified by its arguments from the image and returns it as a new image. However, excerpt does not respect the virtual page offset and does not update the page offset and is more efficient than cropping.
6221 6222 6223 6224 6225 6226 |
# File 'ext/RMagick/rmimage.c', line 6221 VALUE Image_excerpt_bang(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) { rm_check_frozen(self); return excerpt(True, self, x, y, width, height); } |
#export_pixels(x = 0, y = 0, cols = self.columns, rows = self.rows, map = "RGB") ⇒ Array<Numeric>
Extracts the pixel data from the specified rectangle and returns it as an array of Integer values. The array returned by #export_pixels is suitable for use as an argument to #import_pixels.
6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 |
# File 'ext/RMagick/rmimage.c', line 6246 VALUE Image_export_pixels(int argc, VALUE *argv, VALUE self) { Image *image; long x_off = 0L, y_off = 0L; unsigned long cols, rows; long n, npixels; unsigned int okay; const char *map = "RGB"; Quantum *pixels; VALUE ary; ExceptionInfo *exception; image = rm_check_destroyed(self); cols = image->columns; rows = image->rows; switch (argc) { case 5: map = StringValueCStr(argv[4]); case 4: rows = NUM2ULONG(argv[3]); case 3: cols = NUM2ULONG(argv[2]); case 2: y_off = NUM2LONG(argv[1]); case 1: x_off = NUM2LONG(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 5)", argc); break; } if ( x_off < 0 || (unsigned long)x_off > image->columns || y_off < 0 || (unsigned long)y_off > image->rows || cols == 0 || rows == 0) { rb_raise(rb_eArgError, "invalid extract geometry"); } npixels = (long)(cols * rows * strlen(map)); pixels = ALLOC_N(Quantum, npixels); if (!pixels) // app recovered from exception { return rb_ary_new2(0L); } exception = AcquireExceptionInfo(); okay = ExportImagePixels(image, x_off, y_off, cols, rows, map, QuantumPixel, (void *)pixels, exception); if (!okay) { xfree((void *)pixels); CHECK_EXCEPTION(); // Should never get here... rm_magick_error("ExportImagePixels failed with no explanation."); } DestroyExceptionInfo(exception); ary = rb_ary_new2(npixels); for (n = 0; n < npixels; n++) { rb_ary_push(ary, QUANTUM2NUM(pixels[n])); } xfree((void *)pixels); RB_GC_GUARD(ary); return ary; } |
#export_pixels_to_str(x = 0, y = 0, cols = self.columns, rows = self.rows, map = "RGB", type = Magick::CharPixel) ⇒ String
Extracts the pixel data from the specified rectangle and returns it as a string.
6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 |
# File 'ext/RMagick/rmimage.c', line 6409 VALUE Image_export_pixels_to_str(int argc, VALUE *argv, VALUE self) { Image *image; long x_off = 0L, y_off = 0L; unsigned long cols, rows; unsigned long npixels; size_t sz; unsigned int okay; const char *map = "RGB"; StorageType type = CharPixel; VALUE string; ExceptionInfo *exception; image = rm_check_destroyed(self); cols = image->columns; rows = image->rows; switch (argc) { case 6: VALUE_TO_ENUM(argv[5], type, StorageType); case 5: map = StringValueCStr(argv[4]); case 4: rows = NUM2ULONG(argv[3]); case 3: cols = NUM2ULONG(argv[2]); case 2: y_off = NUM2LONG(argv[1]); case 1: x_off = NUM2LONG(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 to 6)", argc); break; } if ( x_off < 0 || (unsigned long)x_off > image->columns || y_off < 0 || (unsigned long)y_off > image->rows || cols == 0 || rows == 0) { rb_raise(rb_eArgError, "invalid extract geometry"); } npixels = cols * rows * strlen(map); switch (type) { case CharPixel: sz = sizeof(unsigned char); break; case ShortPixel: sz = sizeof(unsigned short); break; case DoublePixel: sz = sizeof(double); break; case FloatPixel: sz = sizeof(float); break; case LongPixel: sz = sizeof(unsigned long); break; case QuantumPixel: sz = sizeof(Quantum); break; case UndefinedPixel: default: rb_raise(rb_eArgError, "undefined storage type"); break; } // Allocate a string long enough to hold the exported pixel data. // Get a pointer to the buffer. string = rb_str_new2(""); rb_str_resize(string, (long)(sz * npixels)); exception = AcquireExceptionInfo(); okay = ExportImagePixels(image, x_off, y_off, cols, rows, map, type, (void *)RSTRING_PTR(string), exception); if (!okay) { // Let GC have the string buffer. rb_str_resize(string, 0); CHECK_EXCEPTION(); // Should never get here... rm_magick_error("ExportImagePixels failed with no explanation."); } DestroyExceptionInfo(exception); RB_GC_GUARD(string); return string; } |
#extent(width, height, x = 0, y = 0) ⇒ Magick::Image
If width or height is greater than the target image’s width or height, extends the width and height of the target image to the specified values. The new pixels are set to the background color. If width or height is less than the target image’s width or height, crops the target image.
6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 |
# File 'ext/RMagick/rmimage.c', line 6339 VALUE Image_extent(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; RectangleInfo geometry; long height, width; ExceptionInfo *exception; rm_check_destroyed(self); if (argc < 2 || argc > 4) { rb_raise(rb_eArgError, "wrong number of arguments (expected 2 to 4, got %d)", argc); } geometry.y = geometry.x = 0L; switch (argc) { case 4: geometry.y = NUM2LONG(argv[3]); case 3: geometry.x = NUM2LONG(argv[2]); default: geometry.height = height = NUM2LONG(argv[1]); geometry.width = width = NUM2LONG(argv[0]); break; } // Use the signed versions of these two values to test for < 0 if (height <= 0L || width <= 0L) { if (geometry.x == 0 && geometry.y == 0) { rb_raise(rb_eArgError, "invalid extent geometry %ldx%ld", width, height); } else { rb_raise(rb_eArgError, "invalid extent geometry %ldx%ld+%"RMIdSIZE"+%"RMIdSIZE"", width, height, geometry.x, geometry.y); } } Data_Get_Struct(self, Image, image); exception = AcquireExceptionInfo(); new_image = ExtentImage(image, &geometry, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#extract_info ⇒ Magick::Rectangle
The extract_info attribute reader.
6514 6515 6516 6517 6518 6519 |
# File 'ext/RMagick/rmimage.c', line 6514 VALUE Image_extract_info(VALUE self) { Image *image = rm_check_destroyed(self); return Import_RectangleInfo(&image->extract_info); } |
#extract_info=(rect) ⇒ Magick::Rectangle
Set the extract_info attribute.
6528 6529 6530 6531 6532 6533 6534 |
# File 'ext/RMagick/rmimage.c', line 6528 VALUE Image_extract_info_eq(VALUE self, VALUE rect) { Image *image = rm_check_frozen(self); Export_RectangleInfo(&image->extract_info, rect); return rect; } |
#filename ⇒ String
Get image filename.
6542 6543 6544 6545 6546 |
# File 'ext/RMagick/rmimage.c', line 6542 VALUE Image_filename(VALUE self) { IMPLEMENT_ATTR_READER(Image, filename, str); } |
#filesize ⇒ Numeric
Return the image file size.
6554 6555 6556 6557 6558 |
# File 'ext/RMagick/rmimage.c', line 6554 VALUE Image_filesize(VALUE self) { Image *image = rm_check_destroyed(self); return INT2FIX(GetBlobSize(image)); } |
#filter ⇒ Magick::FilterType
Get filter type.
6566 6567 6568 6569 6570 6571 |
# File 'ext/RMagick/rmimage.c', line 6566 VALUE Image_filter(VALUE self) { Image *image = rm_check_destroyed(self); return FilterType_find(image->filter); } |
#filter=(filter) ⇒ Magick::FilterType
Set filter type.
6580 6581 6582 6583 6584 6585 6586 |
# File 'ext/RMagick/rmimage.c', line 6580 VALUE Image_filter_eq(VALUE self, VALUE filter) { Image *image = rm_check_frozen(self); VALUE_TO_ENUM(filter, image->filter, FilterType); return filter; } |
#find_similar_region(target, x = 0, y = 0) ⇒ Array<Numeric>?
This interesting method searches for a rectangle in the image that is similar to the target. For the rectangle to be similar each pixel in the rectangle must match the corresponding pixel in the target image within the range specified by the fuzz attributes of the image and the target image.
6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 |
# File 'ext/RMagick/rmimage.c', line 6605 VALUE Image_find_similar_region(int argc, VALUE *argv, VALUE self) { Image *image, *target; VALUE region, targ; ssize_t x = 0L, y = 0L; ExceptionInfo *exception; unsigned int okay; image = rm_check_destroyed(self); switch (argc) { case 3: y = NUM2LONG(argv[2]); case 2: x = NUM2LONG(argv[1]); case 1: targ = rm_cur_image(argv[0]); target = rm_check_destroyed(targ); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 to 3)", argc); break; } exception = AcquireExceptionInfo(); okay = IsEquivalentImage(image, target, &x, &y, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); if (!okay) { return Qnil; } region = rb_ary_new2(2); rb_ary_store(region, 0L, LONG2NUM(x)); rb_ary_store(region, 1L, LONG2NUM(y)); RB_GC_GUARD(region); RB_GC_GUARD(targ); return region; } |
#flip ⇒ Magick::Image
Create a vertical mirror image by reflecting the pixels around the central x-axis.
6699 6700 6701 6702 6703 6704 |
# File 'ext/RMagick/rmimage.c', line 6699 VALUE Image_flip(VALUE self) { rm_check_destroyed(self); return flipflop(False, self, FlipImage); } |
#flip! ⇒ Magick::Image
Create a vertical mirror image by reflecting the pixels around the central x-axis. In-place form of #flip.
6716 6717 6718 6719 6720 6721 |
# File 'ext/RMagick/rmimage.c', line 6716 VALUE Image_flip_bang(VALUE self) { rm_check_frozen(self); return flipflop(True, self, FlipImage); } |
#flop ⇒ Magick::Image
Create a horizonal mirror image by reflecting the pixels around the central y-axis.
6732 6733 6734 6735 6736 6737 |
# File 'ext/RMagick/rmimage.c', line 6732 VALUE Image_flop(VALUE self) { rm_check_destroyed(self); return flipflop(False, self, FlopImage); } |
#flop! ⇒ Magick::Image
Create a horizonal mirror image by reflecting the pixels around the central y-axis. In-place form of #flop.
6749 6750 6751 6752 6753 6754 |
# File 'ext/RMagick/rmimage.c', line 6749 VALUE Image_flop_bang(VALUE self) { rm_check_frozen(self); return flipflop(True, self, FlopImage); } |
#format ⇒ String?
Return the image encoding format. For example, “GIF” or “PNG”.
6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 |
# File 'ext/RMagick/rmimage.c', line 6762 VALUE Image_format(VALUE self) { Image *image; const MagickInfo *magick_info; ExceptionInfo *exception; image = rm_check_destroyed(self); if (*image->magick) { // Deliberately ignore the exception info! exception = AcquireExceptionInfo(); magick_info = GetMagickInfo(image->magick, exception); DestroyExceptionInfo(exception); return magick_info ? rb_str_new2(magick_info->name) : Qnil; } return Qnil; } |
#format=(magick) ⇒ String
Set the image encoding format. For example, “GIF” or “PNG”.
6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 |
# File 'ext/RMagick/rmimage.c', line 6790 VALUE Image_format_eq(VALUE self, VALUE magick) { Image *image; const MagickInfo *m; char *mgk; ExceptionInfo *exception; image = rm_check_frozen(self); mgk = StringValueCStr(magick); exception = AcquireExceptionInfo(); m = GetMagickInfo(mgk, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); if (!m) { rb_raise(rb_eArgError, "unknown format: %s", mgk); } strlcpy(image->magick, m->name, sizeof(image->magick)); return magick; } |
#frame(width = self.columns+25*2, height = self.rows+25*2, x = 25, y = 25, inner_bevel = 6, outer_bevel = 6, color = self.matte_color) ⇒ Magick::Image
Add a simulated three-dimensional border around the image.
6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 |
# File 'ext/RMagick/rmimage.c', line 6832 VALUE Image_frame(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; ExceptionInfo *exception; FrameInfo frame_info; image = rm_check_destroyed(self); frame_info.width = image->columns + 50; frame_info.height = image->rows + 50; frame_info.x = 25; frame_info.y = 25; frame_info.inner_bevel = 6; frame_info.outer_bevel = 6; switch (argc) { case 7: Color_to_PixelColor(&image->matte_color, argv[6]); case 6: frame_info.outer_bevel = NUM2LONG(argv[5]); case 5: frame_info.inner_bevel = NUM2LONG(argv[4]); case 4: frame_info.y = NUM2LONG(argv[3]); case 3: frame_info.x = NUM2LONG(argv[2]); case 2: frame_info.height = image->rows + 2*NUM2LONG(argv[1]); case 1: frame_info.width = image->columns + 2*NUM2LONG(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 7)", argc); break; } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) new_image = FrameImage(image, &frame_info, image->compose, exception); #else new_image = FrameImage(image, &frame_info, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#function_channel(function, *args, channel = Magick::AllChannels) ⇒ Magick::Image #function_channel(function, *args, *channels) ⇒ Magick::Image
Set the function on a channel.
6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 |
# File 'ext/RMagick/rmimage.c', line 6950 VALUE Image_function_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; MagickFunction function; unsigned long n, nparms; double *parms; ChannelType channels; ExceptionInfo *exception; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // The number of parameters depends on the function. if (argc == 0) { rb_raise(rb_eArgError, "no function specified"); } VALUE_TO_ENUM(argv[0], function, MagickFunction); argc -= 1; argv += 1; switch (function) { case PolynomialFunction: if (argc == 0) { rb_raise(rb_eArgError, "PolynomialFunction requires at least one argument."); } break; case SinusoidFunction: case ArcsinFunction: case ArctanFunction: if (argc < 1 || argc > 4) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 to 4)", argc); } break; default: rb_raise(rb_eArgError, "undefined function"); break; } nparms = argc; parms = ALLOC_N(double, nparms); for (n = 0; n < nparms; n++) { VALUE element = argv[n]; if (rm_check_num2dbl(element)) { parms[n] = NUM2DBL(element); } else { xfree(parms); rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element))); } } exception = AcquireExceptionInfo(); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(new_image, channels); FunctionImage(new_image, function, nparms, parms, exception); END_CHANNEL_MASK(new_image); #else FunctionImageChannel(new_image, channels, function, nparms, parms, exception); #endif xfree(parms); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#fuzz ⇒ Float
Get the 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.
7036 7037 7038 7039 7040 |
# File 'ext/RMagick/rmimage.c', line 7036 VALUE Image_fuzz(VALUE self) { IMPLEMENT_ATTR_READER(Image, fuzz, dbl); } |
#fuzz=(fuzz) ⇒ String, Float
Set the number of algorithms search for a target color.
7051 7052 7053 7054 7055 7056 7057 |
# File 'ext/RMagick/rmimage.c', line 7051 VALUE Image_fuzz_eq(VALUE self, VALUE fuzz) { Image *image = rm_check_frozen(self); image->fuzz = rm_fuzz_to_dbl(fuzz); return fuzz; } |
#fx(expression, channel = Magick::AllChannels) ⇒ Magick::Image #fx(expression, *channels) ⇒ Magick::Image
Apply fx on the image.
7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 |
# File 'ext/RMagick/rmimage.c', line 7073 VALUE Image_fx(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; char *expression; ChannelType channels; ExceptionInfo *exception; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // There must be exactly 1 remaining argument. if (argc == 0) { rb_raise(rb_eArgError, "wrong number of arguments (0 for 1 or more)"); } else if (argc > 1) { raise_ChannelType_error(argv[argc-1]); } expression = StringValueCStr(argv[0]); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); new_image = FxImage(image, expression, exception); CHANGE_RESULT_CHANNEL_MASK(new_image); END_CHANNEL_MASK(image); #else new_image = FxImageChannel(image, channels, expression, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#gamma ⇒ Float
Get the gamma level of the image.
7116 7117 7118 7119 7120 |
# File 'ext/RMagick/rmimage.c', line 7116 VALUE Image_gamma(VALUE self) { IMPLEMENT_ATTR_READER(Image, gamma, dbl); } |
#gamma=(val) ⇒ Float
Set the gamma level of the image.
7128 7129 7130 7131 7132 |
# File 'ext/RMagick/rmimage.c', line 7128 VALUE Image_gamma_eq(VALUE self, VALUE val) { IMPLEMENT_ATTR_WRITER(Image, gamma, dbl); } |
#gamma_channel(gamma, channel = Magick::AllChannels) ⇒ Magick::Image #gamma_channel(gamma, *channels) ⇒ Magick::Image
Apply gamma to a channel.
7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 |
# File 'ext/RMagick/rmimage.c', line 7150 VALUE Image_gamma_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; ChannelType channels; double gamma; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // There must be exactly one remaining argument. if (argc == 0) { rb_raise(rb_eArgError, "missing gamma argument"); } else if (argc > 1) { raise_ChannelType_error(argv[argc-1]); } gamma = NUM2DBL(argv[0]); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(new_image, channels); GammaImage(new_image, gamma, exception); END_CHANNEL_MASK(new_image); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else GammaImageChannel(new_image, channels, gamma); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#gamma_correct(red_gamma, green_gamma = red_gamma, blue_gamma = green_gamma) ⇒ Magick::Image
gamma-correct an image.
7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 |
# File 'ext/RMagick/rmimage.c', line 7198 VALUE Image_gamma_correct(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double red_gamma, green_gamma, blue_gamma; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); switch (argc) { case 1: red_gamma = NUM2DBL(argv[0]); green_gamma = blue_gamma = red_gamma; break; case 2: red_gamma = NUM2DBL(argv[0]); green_gamma = NUM2DBL(argv[1]); blue_gamma = green_gamma; break; case 3: case 4: red_gamma = NUM2DBL(argv[0]); green_gamma = NUM2DBL(argv[1]); blue_gamma = NUM2DBL(argv[2]); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 to 3)", argc); break; } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); #endif if ((red_gamma == green_gamma) && (green_gamma == blue_gamma)) { #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(new_image, (ChannelType) (RedChannel | GreenChannel | BlueChannel)); GammaImage(new_image, red_gamma, exception); END_CHANNEL_MASK(new_image); #else GammaImageChannel(new_image, (ChannelType) (RedChannel | GreenChannel | BlueChannel), red_gamma); #endif } else { #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(new_image, RedChannel); GammaImage(new_image, red_gamma, exception); END_CHANNEL_MASK(new_image); BEGIN_CHANNEL_MASK(new_image, GreenChannel); GammaImage(new_image, green_gamma, exception); END_CHANNEL_MASK(new_image); BEGIN_CHANNEL_MASK(new_image, BlueChannel); GammaImage(new_image, blue_gamma, exception); END_CHANNEL_MASK(new_image); #else GammaImageChannel(new_image, RedChannel, red_gamma); GammaImageChannel(new_image, GreenChannel, green_gamma); GammaImageChannel(new_image, BlueChannel, blue_gamma); #endif } #if defined(IMAGEMAGICK_7) CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#gaussian_blur(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Blur the image.
7286 7287 7288 7289 7290 |
# File 'ext/RMagick/rmimage.c', line 7286 VALUE Image_gaussian_blur(int argc, VALUE *argv, VALUE self) { return effect_image(self, argc, argv, GaussianBlurImage); } |
#gaussian_blur_channel(radius = 0.0, sigma = 1.0, channel = Magick::AllChannels) ⇒ Magick::Image #gaussian_blur_channel(radius = 0.0, sigma = 1.0, *channels) ⇒ Magick::Image
Blur the image on a channel.
7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 |
# File 'ext/RMagick/rmimage.c', line 7308 VALUE Image_gaussian_blur_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; ChannelType channels; ExceptionInfo *exception; double radius = 0.0, sigma = 1.0; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // There can be 0, 1, or 2 remaining arguments. switch (argc) { case 2: sigma = NUM2DBL(argv[1]); /* Fall thru */ case 1: radius = NUM2DBL(argv[0]); /* Fall thru */ case 0: break; default: raise_ChannelType_error(argv[argc-1]); } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); new_image = GaussianBlurImage(image, radius, sigma, exception); CHANGE_RESULT_CHANNEL_MASK(new_image); END_CHANNEL_MASK(image); rm_check_exception(exception, new_image, DestroyOnError); #else new_image = GaussianBlurImageChannel(image, channels, radius, sigma, exception); rm_check_exception(exception, new_image, DestroyOnError); #endif DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#geometry ⇒ String
Get the preferred size of the image when encoding.
7358 7359 7360 7361 7362 |
# File 'ext/RMagick/rmimage.c', line 7358 VALUE Image_geometry(VALUE self) { IMPLEMENT_ATTR_READER(Image, geometry, str); } |
#geometry=(geometry) ⇒ String
Set the preferred size of the image when encoding.
7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 |
# File 'ext/RMagick/rmimage.c', line 7372 VALUE Image_geometry_eq(VALUE self, VALUE geometry) { Image *image; VALUE geom_str; char *geom; image = rm_check_frozen(self); if (geometry == Qnil) { magick_free(image->geometry); image->geometry = NULL; return self; } geom_str = rb_String(geometry); geom = StringValueCStr(geom_str); if (!IsGeometry(geom)) { rb_raise(rb_eTypeError, "invalid geometry: %s", geom); } magick_clone_string(&image->geometry, geom); RB_GC_GUARD(geom_str); return geometry; } |
#get_exif_by_entry(*entry) ⇒ Object
Retrieve EXIF data by entry or all. If one or more entry names specified, return the values associated with the entries. If no entries specified, return all entries and values. The return value is an array of [name,value] arrays.
883 884 885 886 887 888 889 890 891 892 893 894 895 896 |
# File 'lib/rmagick_internal.rb', line 883 def get_exif_by_entry(*entry) ary = [] if entry.length.zero? exif_data = self['EXIF:*'] exif_data.split("\n").each { |exif| ary.push(exif.split('=')) } if exif_data else get_exif_by_entry # ensure properties is populated with exif data entry.each do |name| rval = self["EXIF:#{name}"] ary.push([name, rval]) end end ary end |
#get_exif_by_number(*tag) ⇒ Object
Retrieve EXIF data by tag number or all tag/value pairs. The return value is a hash.
899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 |
# File 'lib/rmagick_internal.rb', line 899 def get_exif_by_number(*tag) hash = {} if tag.length.zero? exif_data = self['EXIF:!'] if exif_data exif_data.split("\n").each do |exif| tag, value = exif.split('=') tag = tag[1, 4].hex hash[tag] = value end end else get_exif_by_number # ensure properties is populated with exif data tag.each do |num| rval = self[sprintf('#%04X', num.to_i)] hash[num] = rval == 'unknown' ? nil : rval end end hash end |
#get_iptc_dataset(ds) ⇒ Object
Retrieve IPTC information by record number:dataset tag constant defined in Magick::IPTC, above.
922 923 924 |
# File 'lib/rmagick_internal.rb', line 922 def get_iptc_dataset(ds) self['IPTC:' + ds] end |
#get_pixels(x_arg, y_arg, cols_arg, rows_arg) ⇒ Array<Magick::Pixel>
Gets the pixels from the specified rectangle within the image.
7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 |
# File 'ext/RMagick/rmimage.c', line 7414 VALUE Image_get_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg, VALUE rows_arg) { Image *image; ExceptionInfo *exception; long x, y; unsigned long columns, rows; long size, n; VALUE pixel_ary; #if defined(IMAGEMAGICK_7) const Quantum *pixels; #else const PixelPacket *pixels; const IndexPacket *indexes; #endif image = rm_check_destroyed(self); x = NUM2LONG(x_arg); y = NUM2LONG(y_arg); columns = NUM2ULONG(cols_arg); rows = NUM2ULONG(rows_arg); if ((x+columns) > image->columns || (y+rows) > image->rows) { rb_raise(rb_eRangeError, "geometry (%lux%lu%+ld%+ld) exceeds image bounds", columns, rows, x, y); } // Cast AcquireImagePixels to get rid of the const qualifier. We're not going // to change the pixels but I don't want to make "pixels" const. exception = AcquireExceptionInfo(); pixels = GetVirtualPixels(image, x, y, columns, rows, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); // If the function failed, return a 0-length array. if (!pixels) { return rb_ary_new(); } // Allocate an array big enough to contain the PixelPackets. size = (long)(columns * rows); pixel_ary = rb_ary_new2(size); #if defined(IMAGEMAGICK_6) indexes = GetVirtualIndexQueue(image); #endif // Convert the PixelPackets to Magick::Pixel objects for (n = 0; n < size; n++) { #if defined(IMAGEMAGICK_7) PixelPacket color; memset(&color, 0, sizeof(color)); color.red = GetPixelRed(image, pixels); color.green = GetPixelGreen(image, pixels); color.blue = GetPixelBlue(image, pixels); color.alpha = GetPixelAlpha(image, pixels); color.black = GetPixelBlack(image, pixels); rb_ary_store(pixel_ary, n, Pixel_from_PixelPacket(&color)); pixels += GetPixelChannels(image); #else MagickPixel mpp; mpp.red = GetPixelRed(pixels); mpp.green = GetPixelGreen(pixels); mpp.blue = GetPixelBlue(pixels); mpp.opacity = GetPixelOpacity(pixels); if (indexes) { mpp.index = GetPixelIndex(indexes + n); } rb_ary_store(pixel_ary, n, Pixel_from_MagickPixel(&mpp)); pixels++; #endif } return pixel_ary; } |
#gravity ⇒ Magick::GravityType
Get the direction that the image gravitates within the composite.
14461 14462 14463 14464 14465 |
# File 'ext/RMagick/rmimage.c', line 14461 VALUE Image_gravity(VALUE self) { Image *image = rm_check_destroyed(self); return GravityType_find(image->gravity); } |
#gravity=(gravity) ⇒ Magick::GravityType
Set the direction that the image gravitates within the composite.
14474 14475 14476 14477 14478 14479 |
# File 'ext/RMagick/rmimage.c', line 14474 VALUE Image_gravity_eq(VALUE self, VALUE gravity) { Image *image = rm_check_frozen(self); VALUE_TO_ENUM(gravity, image->gravity, GravityType); return gravity; } |
#gray? ⇒ Boolean
Return true if all the pixels in the image have the same red, green, and blue intensities.
7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 |
# File 'ext/RMagick/rmimage.c', line 7553 VALUE Image_gray_q(VALUE self) { #if defined(HAVE_SETIMAGEGRAY) return has_attribute(self, (MagickBooleanType (*)(const Image *, ExceptionInfo *))SetImageGray); #else #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9) return has_attribute(self, IsGrayImage); #else // For ImageMagick 6.7 Image *image; ColorspaceType colorspace; VALUE ret; image = rm_check_destroyed(self); colorspace = image->colorspace; if (image->colorspace == sRGBColorspace || image->colorspace == TransparentColorspace) { // Workaround // If image colorspace has non-RGBColorspace, IsGrayImage() always return false. image->colorspace = RGBColorspace; } ret = has_attribute(self, IsGrayImage); image->colorspace = colorspace; return ret; #endif #endif } |
#grey? ⇒ Boolean
Return true if all the pixels in the image have the same red, green, and blue intensities.
7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 |
# File 'ext/RMagick/rmimage.c', line 7553 VALUE Image_gray_q(VALUE self) { #if defined(HAVE_SETIMAGEGRAY) return has_attribute(self, (MagickBooleanType (*)(const Image *, ExceptionInfo *))SetImageGray); #else #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9) return has_attribute(self, IsGrayImage); #else // For ImageMagick 6.7 Image *image; ColorspaceType colorspace; VALUE ret; image = rm_check_destroyed(self); colorspace = image->colorspace; if (image->colorspace == sRGBColorspace || image->colorspace == TransparentColorspace) { // Workaround // If image colorspace has non-RGBColorspace, IsGrayImage() always return false. image->colorspace = RGBColorspace; } ret = has_attribute(self, IsGrayImage); image->colorspace = colorspace; return ret; #endif #endif } |
#histogram? ⇒ Boolean
Return true if has 1024 unique colors or less.
7588 7589 7590 7591 7592 |
# File 'ext/RMagick/rmimage.c', line 7588 VALUE Image_histogram_q(VALUE self) { return has_attribute(self, IsHistogramImage); } |
#image_type ⇒ Magick::ImageType
Get the image type classification. For example, GrayscaleType. Don’t confuse this attribute with the format, that is “GIF” or “JPG”.
14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 |
# File 'ext/RMagick/rmimage.c', line 14489 VALUE Image_image_type(VALUE self) { Image *image; ImageType type; #if defined(IMAGEMAGICK_6) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); #if defined(IMAGEMAGICK_7) type = GetImageType(image); #else exception = AcquireExceptionInfo(); type = GetImageType(image, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #endif return ImageType_find(type); } |
#image_type=(image_type) ⇒ Magick::ImageType
Set the image type classification.
14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 |
# File 'ext/RMagick/rmimage.c', line 14518 VALUE Image_image_type_eq(VALUE self, VALUE image_type) { Image *image; ImageType type; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_frozen(self); VALUE_TO_ENUM(image_type, type, ImageType); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); SetImageType(image, type, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else SetImageType(image, type); #endif return image_type; } |
#implode(amount = 0.50) ⇒ Magick::Image
Implode the image by the specified percentage.
7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 |
# File 'ext/RMagick/rmimage.c', line 7601 VALUE Image_implode(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double amount = 0.50; ExceptionInfo *exception; switch (argc) { case 1: amount = NUM2DBL(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc); } image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) new_image = ImplodeImage(image, amount, image->interpolate, exception); #else new_image = ImplodeImage(image, amount, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#store_pixels(x, y, columns, rows, map, pixels, type = Magick::CharPixel) ⇒ Magick::Image
Store image pixel data from an array.
7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 |
# File 'ext/RMagick/rmimage.c', line 7650 VALUE Image_import_pixels(int argc, VALUE *argv, VALUE self) { Image *image; long x_off, y_off; unsigned long cols, rows; unsigned long n, npixels; long buffer_l; char *map; VALUE pixel_arg, pixel_ary; StorageType stg_type = CharPixel; size_t type_sz, map_l; Quantum *pixels = NULL; double *fpixels = NULL; void *buffer; unsigned int okay; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_frozen(self); switch (argc) { case 7: VALUE_TO_ENUM(argv[6], stg_type, StorageType); case 6: x_off = NUM2LONG(argv[0]); y_off = NUM2LONG(argv[1]); cols = NUM2ULONG(argv[2]); rows = NUM2ULONG(argv[3]); map = StringValueCStr(argv[4]); pixel_arg = argv[5]; break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 6 or 7)", argc); break; } if (x_off < 0 || y_off < 0 || cols <= 0 || rows <= 0) { rb_raise(rb_eArgError, "invalid import geometry"); } map_l = rm_strnlen_s(map, MaxTextExtent); npixels = cols * rows * map_l; // Assume that any object that responds to :to_str is a string buffer containing // binary pixel data. if (rb_respond_to(pixel_arg, rb_intern("to_str"))) { buffer = (void *)rm_str2cstr(pixel_arg, &buffer_l); switch (stg_type) { case CharPixel: type_sz = 1; break; case ShortPixel: type_sz = sizeof(unsigned short); break; case LongPixel: type_sz = sizeof(unsigned long); break; case DoublePixel: type_sz = sizeof(double); break; case FloatPixel: type_sz = sizeof(float); break; case QuantumPixel: type_sz = sizeof(Quantum); break; default: rb_raise(rb_eArgError, "unsupported storage type %s", StorageType_name(stg_type)); break; } if (buffer_l % type_sz != 0) { rb_raise(rb_eArgError, "pixel buffer must be an exact multiple of the storage type size"); } if ((buffer_l / type_sz) % map_l != 0) { rb_raise(rb_eArgError, "pixel buffer must contain an exact multiple of the map length"); } if ((unsigned long)(buffer_l / type_sz) < npixels) { rb_raise(rb_eArgError, "pixel buffer too small (need %lu channel values, got %"RMIuSIZE")", npixels, buffer_l/type_sz); } } // Otherwise convert the argument to an array and convert the array elements // to binary pixel data. else { // rb_Array converts an object that is not an array to an array if possible, // and raises TypeError if it can't. It usually is possible. pixel_ary = rb_Array(pixel_arg); if (RARRAY_LEN(pixel_ary) % map_l != 0) { rb_raise(rb_eArgError, "pixel array must contain an exact multiple of the map length"); } if ((unsigned long)RARRAY_LEN(pixel_ary) < npixels) { rb_raise(rb_eArgError, "pixel array too small (need %lu elements, got %ld)", npixels, RARRAY_LEN(pixel_ary)); } if (stg_type == DoublePixel || stg_type == FloatPixel) { fpixels = ALLOC_N(double, npixels); for (n = 0; n < npixels; n++) { VALUE element = rb_ary_entry(pixel_ary, n); if (rm_check_num2dbl(element)) { fpixels[n] = NUM2DBL(element); } else { xfree(fpixels); rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element))); } } buffer = (void *) fpixels; stg_type = DoublePixel; } else { pixels = ALLOC_N(Quantum, npixels); for (n = 0; n < npixels; n++) { VALUE element = rb_ary_entry(pixel_ary, n); if (rm_check_num2dbl(element)) { pixels[n] = NUM2DBL(element); } else { xfree(pixels); rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element))); } } buffer = (void *) pixels; stg_type = QuantumPixel; } } #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); okay = ImportImagePixels(image, x_off, y_off, cols, rows, map, stg_type, buffer, exception); #else okay = ImportImagePixels(image, x_off, y_off, cols, rows, map, stg_type, buffer); #endif // Free pixel array before checking for errors. if (pixels) { xfree((void *)pixels); } if (fpixels) { xfree((void *)fpixels); } if (!okay) { #if defined(IMAGEMAGICK_7) CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else rm_check_image_exception(image, RetainOnError); #endif // Shouldn't get here... rm_magick_error("ImportImagePixels failed with no explanation."); } #if defined(IMAGEMAGICK_7) DestroyExceptionInfo(exception); #endif RB_GC_GUARD(pixel_arg); RB_GC_GUARD(pixel_ary); return self; } |
#initialize_copy(orig) ⇒ Magick::Image
Initialize copy, clone, dup.
4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 |
# File 'ext/RMagick/rmimage.c', line 4668 VALUE Image_init_copy(VALUE copy, VALUE orig) { Image *image, *new_image; image = rm_check_destroyed(orig); new_image = rm_clone_image(image); UPDATE_DATA_PTR(copy, new_image); return copy; } |
#inspect ⇒ String
Override Object#inspect - return a string description of the image.
7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 |
# File 'ext/RMagick/rmimage.c', line 7986 VALUE Image_inspect(VALUE self) { Image *image; char buffer[MaxTextExtent]; // image description buffer Data_Get_Struct(self, Image, image); if (!image) { return rb_str_new2("#<Magick::Image: (destroyed)>"); } build_inspect_string(image, buffer, sizeof(buffer)); return rb_str_new2(buffer); } |
#interlace ⇒ Magick::InterlaceType
Get 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).
8012 8013 8014 8015 8016 8017 |
# File 'ext/RMagick/rmimage.c', line 8012 VALUE Image_interlace(VALUE self) { Image *image = rm_check_destroyed(self); return InterlaceType_find(image->interlace); } |
#interlace=(interlace) ⇒ Magick::InterlaceType
Set the type of interlacing scheme.
8026 8027 8028 8029 8030 8031 8032 |
# File 'ext/RMagick/rmimage.c', line 8026 VALUE Image_interlace_eq(VALUE self, VALUE interlace) { Image *image = rm_check_frozen(self); VALUE_TO_ENUM(interlace, image->interlace, InterlaceType); return interlace; } |
#iptc_profile ⇒ String?
Return the IPTC profile as a String.
8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 |
# File 'ext/RMagick/rmimage.c', line 8040 VALUE Image_iptc_profile(VALUE self) { Image *image; const StringInfo *profile; image = rm_check_destroyed(self); profile = GetImageProfile(image, "iptc"); if (!profile) { return Qnil; } return rb_str_new((char *)profile->datum, (long)profile->length); } |
#iptc_profile=(profile) ⇒ String
Set the IPTC profile. The argument is a string.
8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 |
# File 'ext/RMagick/rmimage.c', line 8065 VALUE Image_iptc_profile_eq(VALUE self, VALUE profile) { Image_delete_profile(self, rb_str_new2("iptc")); if (profile != Qnil) { set_profile(self, "iptc", profile); } return profile; } |
#iterations ⇒ Object
These are undocumented methods. The writer is called only by Image#iterations=. The reader is only used by the unit tests!
8082 8083 8084 8085 8086 |
# File 'ext/RMagick/rmimage.c', line 8082 VALUE Image_iterations(VALUE self) { IMPLEMENT_ATTR_READER(Image, iterations, int); } |
#iterations=(val) ⇒ Object
do not document! Only used by Image#iterations=
8087 8088 8089 8090 8091 |
# File 'ext/RMagick/rmimage.c', line 8087 VALUE Image_iterations_eq(VALUE self, VALUE val) { IMPLEMENT_ATTR_WRITER(Image, iterations, int); } |
#level(black_point = 0.0, white_point = nil, gamma = nil) ⇒ Object
(Thanks to Al Evans for the suggestion.)
951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 |
# File 'lib/rmagick_internal.rb', line 951 def level(black_point = 0.0, white_point = nil, gamma = nil) black_point = Float(black_point) white_point ||= Magick::QuantumRange - black_point white_point = Float(white_point) gamma_arg = gamma gamma ||= 1.0 gamma = Float(gamma) if gamma.abs > 10.0 || white_point.abs <= 10.0 || white_point.abs < gamma.abs gamma, white_point = white_point, gamma white_point = Magick::QuantumRange - black_point unless gamma_arg end level2(black_point, white_point, gamma) end |
#level2(black_point = 0.0, white_point = Magick::QuantumRange, gamma = 1.0) ⇒ Magick::Image
Adjusts the levels of an image by scaling the colors falling between specified white and black points to the full available quantum range.
8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 |
# File 'ext/RMagick/rmimage.c', line 8103 VALUE Image_level2(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double black_point = 0.0, gamma_val = 1.0, white_point = (double)QuantumRange; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #else char level[50]; #endif image = rm_check_destroyed(self); switch (argc) { case 0: // take all the defaults break; case 1: black_point = NUM2DBL(argv[0]); white_point = QuantumRange - black_point; break; case 2: black_point = NUM2DBL(argv[0]); white_point = NUM2DBL(argv[1]); break; case 3: black_point = NUM2DBL(argv[0]); white_point = NUM2DBL(argv[1]); gamma_val = NUM2DBL(argv[2]); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 3)", argc); break; } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); LevelImage(new_image, black_point, white_point, gamma_val, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else snprintf(level, sizeof(level), "%gx%g+%g", black_point, white_point, gamma_val); LevelImage(new_image, level); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#level_channel(aChannelType, black = 0.0, white = 1.0, gamma = Magick::QuantumRange) ⇒ Magick::Image
Similar to #level2 but applies to a single channel only.
8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 |
# File 'ext/RMagick/rmimage.c', line 8165 VALUE Image_level_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double black_point = 0.0, gamma_val = 1.0, white_point = (double)QuantumRange; ChannelType channel; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); switch (argc) { case 1: // take all the defaults break; case 2: black_point = NUM2DBL(argv[1]); white_point = QuantumRange - black_point; break; case 3: black_point = NUM2DBL(argv[1]); white_point = NUM2DBL(argv[2]); break; case 4: black_point = NUM2DBL(argv[1]); white_point = NUM2DBL(argv[2]); gamma_val = NUM2DBL(argv[3]); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 to 4)", argc); break; } VALUE_TO_ENUM(argv[0], channel, ChannelType); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(new_image, channel); LevelImage(new_image, black_point, white_point, gamma_val, exception); END_CHANNEL_MASK(new_image); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else LevelImageChannel(new_image, channel, black_point, white_point, gamma_val); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#level_colors(black_color = "black", white_color = "white", invert = true, channel = Magick::AllChannels) ⇒ Magick::Image #level_colors(black_color = "black", white_color = "white", invert = true, *channels) ⇒ Magick::Image
When invert is true, black and white will be mapped to the black_color and white_color colors, compressing all other colors linearly. When invert is false, black and white will be mapped to the black_color and white_color colors, stretching all other colors linearly.
8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 |
# File 'ext/RMagick/rmimage.c', line 8237 VALUE Image_level_colors(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; MagickPixel black_color, white_color; ChannelType channels; MagickBooleanType invert = MagickTrue; MagickBooleanType status; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); rm_init_magickpixel(image, &white_color); rm_init_magickpixel(image, &black_color); switch (argc) { case 3: invert = RTEST(argv[2]); case 2: Color_to_MagickPixel(image, &white_color, argv[1]); Color_to_MagickPixel(image, &black_color, argv[0]); break; case 1: rm_set_magickpixel(&white_color, "white"); Color_to_MagickPixel(image, &black_color, argv[0]); break; case 0: rm_set_magickpixel(&white_color, "white"); rm_set_magickpixel(&black_color, "black"); break; default: raise_ChannelType_error(argv[argc-1]); break; } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(new_image, channels); status = LevelImageColors(new_image, &black_color, &white_color, invert, exception); END_CHANNEL_MASK(new_image); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else status = LevelColorsImageChannel(new_image, channels, &black_color, &white_color, invert); rm_check_image_exception(new_image, DestroyOnError); #endif if (!status) { rb_raise(rb_eRuntimeError, "LevelImageColors failed for unknown reason."); } return rm_image_new(new_image); } |
#levelize_channel(black_point, white_point = Magick::QuantumRange-black_point, gamma = 1.0, channel = Magick::AllChannels) ⇒ Magick::Image #levelize_channel(black_point, white_point = Magick::QuantumRange-black_point, gamma = 1.0, *channels) ⇒ Magick::Image
Maps black and white to the specified points. The reverse of #level_channel.
8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 |
# File 'ext/RMagick/rmimage.c', line 8320 VALUE Image_levelize_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; ChannelType channels; double black_point, white_point; double gamma = 1.0; MagickBooleanType status; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); if (argc > 3) { raise_ChannelType_error(argv[argc-1]); } switch (argc) { case 3: gamma = NUM2DBL(argv[2]); case 2: white_point = NUM2DBL(argv[1]); black_point = NUM2DBL(argv[0]); break; case 1: black_point = NUM2DBL(argv[0]); white_point = QuantumRange - black_point; break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or more)", argc); break; } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(new_image, channels); status = LevelizeImage(new_image, black_point, white_point, gamma, exception); END_CHANNEL_MASK(new_image); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else status = LevelizeImageChannel(new_image, channels, black_point, white_point, gamma); rm_check_image_exception(new_image, DestroyOnError); #endif if (!status) { rb_raise(rb_eRuntimeError, "LevelizeImageChannel failed for unknown reason."); } return rm_image_new(new_image); } |
#linear_stretch(black_point, white_point = pixels-black_point) ⇒ Magick::Image
Linear with saturation stretch.
8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 |
# File 'ext/RMagick/rmimage.c', line 8392 VALUE Image_linear_stretch(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double black_point, white_point; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); get_black_white_point(image, argc, argv, &black_point, &white_point); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); LinearStretchImage(new_image, black_point, white_point, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else LinearStretchImage(new_image, black_point, white_point); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#liquid_rescale(columns, rows, delta_x = 0.0, rigidity = 0.0) ⇒ Magick::Image
Rescale image with seam carving.
8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 |
# File 'ext/RMagick/rmimage.c', line 8430 VALUE Image_liquid_rescale(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; unsigned long cols, rows; double delta_x = 0.0; double rigidity = 0.0; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 4: rigidity = NUM2DBL(argv[3]); case 3: delta_x = NUM2DBL(argv[2]); case 2: rows = NUM2ULONG(argv[1]); cols = NUM2ULONG(argv[0]); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 to 4)", argc); break; } exception = AcquireExceptionInfo(); new_image = LiquidRescaleImage(image, cols, rows, delta_x, rigidity, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#magnify ⇒ Magick::Image
Scale an image proportionally to twice its size.
8578 8579 8580 8581 8582 8583 |
# File 'ext/RMagick/rmimage.c', line 8578 VALUE Image_magnify(VALUE self) { rm_check_destroyed(self); return magnify(False, self, MagnifyImage); } |
#magnify! ⇒ Magick::Image
Scale an image proportionally to twice its size. In-place form of #magnify.
8593 8594 8595 8596 8597 8598 |
# File 'ext/RMagick/rmimage.c', line 8593 VALUE Image_magnify_bang(VALUE self) { rm_check_frozen(self); return magnify(True, self, MagnifyImage); } |
#marshal_dump ⇒ Array<String>
Support Marshal.dump.
8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 |
# File 'ext/RMagick/rmimage.c', line 8607 VALUE Image_marshal_dump(VALUE self) { Image *image; Info *info; unsigned char *blob; size_t length; VALUE ary; ExceptionInfo *exception; image = rm_check_destroyed(self); info = CloneImageInfo(NULL); if (!info) { rb_raise(rb_eNoMemError, "not enough memory to initialize Info object"); } ary = rb_ary_new2(2); rb_ary_store(ary, 0, rb_str_new2(image->filename)); exception = AcquireExceptionInfo(); blob = ImageToBlob(info, image, &length, exception); // Destroy info before raising an exception DestroyImageInfo(info); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); rb_ary_store(ary, 1, rb_str_new((char *)blob, (long)length)); magick_free((void*)blob); return ary; } |
#marshal_load(ary) ⇒ Object
Support Marshal.load.
8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 |
# File 'ext/RMagick/rmimage.c', line 8649 VALUE Image_marshal_load(VALUE self, VALUE ary) { VALUE blob, filename; Info *info; Image *image; ExceptionInfo *exception; info = CloneImageInfo(NULL); if (!info) { rb_raise(rb_eNoMemError, "not enough memory to initialize Info object"); } filename = rb_ary_shift(ary); blob = rb_ary_shift(ary); filename = StringValue(filename); blob = StringValue(blob); exception = AcquireExceptionInfo(); if (filename != Qnil) { strlcpy(info->filename, RSTRING_PTR(filename), sizeof(info->filename)); } image = BlobToImage(info, RSTRING_PTR(blob), RSTRING_LEN(blob), exception); // Destroy info before raising an exception DestroyImageInfo(info); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); UPDATE_DATA_PTR(self, image); return self; } |
#mask ⇒ Magick::Image #mask(image) ⇒ Magick::Image
Get/Sets an image clip mask created from the specified mask image. The mask image must have the same dimensions as the image being masked. If not, the mask image is resized to match. If the mask image has an alpha channel the opacity of each pixel is used to define the mask. Otherwise, the intensity (gray level) of each pixel is used.
In general, if the mask image does not have an alpha channel, a white pixel in the mask prevents changes to the corresponding pixel in the image being masked, while a black pixel allows changes. A pixel that is neither black nor white will allow partial changes depending on its intensity.
8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 |
# File 'ext/RMagick/rmimage.c', line 8870 VALUE Image_mask(int argc, VALUE *argv, VALUE self) { VALUE mask; Image *image; image = rm_check_destroyed(self); if (argc == 0) { return get_image_mask(image); } if (argc > 1) { rb_raise(rb_eArgError, "wrong number of arguments (expected 0 or 1, got %d)", argc); } rb_check_frozen(self); mask = argv[0]; return set_image_mask(image, mask); } |
#matte_color ⇒ String
Return the matte color.
8897 8898 8899 8900 8901 8902 |
# File 'ext/RMagick/rmimage.c', line 8897 VALUE Image_matte_color(VALUE self) { Image *image = rm_check_destroyed(self); return rm_pixelcolor_to_color_name(image, &image->matte_color); } |
#matte_color=(color) ⇒ Magick::Pixel, String
Set the matte color.
8910 8911 8912 8913 8914 8915 8916 |
# File 'ext/RMagick/rmimage.c', line 8910 VALUE Image_matte_color_eq(VALUE self, VALUE color) { Image *image = rm_check_frozen(self); Color_to_PixelColor(&image->matte_color, color); return color; } |
#matte_fill_to_border(x, y) ⇒ Object
Make transparent any neighbor pixel that is not the border color.
1002 1003 1004 1005 1006 |
# File 'lib/rmagick_internal.rb', line 1002 def matte_fill_to_border(x, y) f = copy f.alpha(OpaqueAlphaChannel) unless f.alpha? f.matte_flood_fill(border_color, x, y, FillToBorderMethod, alpha: TransparentAlpha) end |
#Image ⇒ Magick::Image
Makes transparent all the pixels that are the same color as the pixel at x, y, and are neighbors.
8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 |
# File 'ext/RMagick/rmimage.c', line 8930 VALUE Image_matte_flood_fill(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; PixelColor target; Quantum alpha; long x, y; PaintMethod method; DrawInfo *draw_info; MagickPixel target_mpp; MagickBooleanType invert; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); if (argc != 5) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 5)", argc); } alpha = get_named_alpha_value(argv[4]); Color_to_PixelColor(&target, argv[0]); VALUE_TO_ENUM(argv[3], method, PaintMethod); if (!(method == FloodfillMethod || method == FillToBorderMethod)) { rb_raise(rb_eArgError, "paint method_obj must be FloodfillMethod or " "FillToBorderMethod (%d given)", method); } x = NUM2LONG(argv[1]); y = NUM2LONG(argv[2]); if ((unsigned long)x > image->columns || (unsigned long)y > image->rows) { rb_raise(rb_eArgError, "target out of range. %ldx%ld given, image is %"RMIuSIZE"x%"RMIuSIZE"", x, y, image->columns, image->rows); } new_image = rm_clone_image(image); // FloodfillPaintImage looks for the opacity in the DrawInfo.fill field. draw_info = CloneDrawInfo(NULL, NULL); if (!draw_info) { rb_raise(rb_eNoMemError, "not enough memory to continue"); } #if defined(IMAGEMAGICK_7) rm_set_pixelinfo_alpha(&draw_info->fill, alpha); #else draw_info->fill.opacity = QuantumRange - alpha; #endif if (method == FillToBorderMethod) { invert = MagickTrue; target_mpp.red = (MagickRealType) image->border_color.red; target_mpp.green = (MagickRealType) image->border_color.green; target_mpp.blue = (MagickRealType) image->border_color.blue; #if defined(IMAGEMAGICK_7) rm_set_pixelinfo_alpha(&target_mpp, (MagickRealType) image->border_color.alpha); #else target_mpp.opacity = (MagickRealType) image->border_color.opacity; #endif } else { invert = MagickFalse; target_mpp.red = (MagickRealType) target.red; target_mpp.green = (MagickRealType) target.green; target_mpp.blue = (MagickRealType) target.blue; #if defined(IMAGEMAGICK_7) rm_set_pixelinfo_alpha(&target_mpp, (MagickRealType) target.alpha); #else target_mpp.opacity = (MagickRealType) target.opacity; #endif } #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(new_image, OpacityChannel); FloodfillPaintImage(new_image, draw_info, &target_mpp, x, y, invert, exception); END_CHANNEL_MASK(new_image); DestroyDrawInfo(draw_info); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else FloodfillPaintImage(new_image, OpacityChannel, draw_info, &target_mpp, x, y, invert); DestroyDrawInfo(draw_info); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#matte_floodfill(x, y) ⇒ Object
Make transparent any pixel that matches the color of the pixel at (x,y) and is a neighbor.
994 995 996 997 998 999 |
# File 'lib/rmagick_internal.rb', line 994 def matte_floodfill(x, y) f = copy f.alpha(OpaqueAlphaChannel) unless f.alpha? target = f.pixel_color(x, y) f.matte_flood_fill(target, x, y, FloodfillMethod, alpha: TransparentAlpha) end |
#matte_point(x, y) ⇒ Object
Make the pixel at (x,y) transparent.
974 975 976 977 978 979 980 981 |
# File 'lib/rmagick_internal.rb', line 974 def matte_point(x, y) f = copy f.alpha(OpaqueAlphaChannel) unless f.alpha? pixel = f.pixel_color(x, y) pixel.alpha = TransparentAlpha f.pixel_color(x, y, pixel) f end |
#matte_replace(x, y) ⇒ Object
Make transparent all pixels that are the same color as the pixel at (x, y).
985 986 987 988 989 990 |
# File 'lib/rmagick_internal.rb', line 985 def matte_replace(x, y) f = copy f.alpha(OpaqueAlphaChannel) unless f.alpha? target = f.pixel_color(x, y) f.transparent(target) end |
#matte_reset! ⇒ Object
Make all pixels transparent.
1009 1010 1011 1012 |
# File 'lib/rmagick_internal.rb', line 1009 def matte_reset! alpha(TransparentAlphaChannel) self end |
#mean_error_per_pixel ⇒ Float
Get the mean error per pixel computed when a image is color reduced.
9069 9070 9071 9072 9073 |
# File 'ext/RMagick/rmimage.c', line 9069 VALUE Image_mean_error_per_pixel(VALUE self) { IMPLEMENT_ATTR_READERF(Image, mean_error_per_pixel, error.mean_error_per_pixel, dbl); } |
#median_filter(radius = 0.0) ⇒ Magick::Image
Apply a digital filter that improves the quality of a noisy image. Each pixel is replaced by the median in a set of neighboring pixels as defined by radius.
9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 |
# File 'ext/RMagick/rmimage.c', line 9036 VALUE Image_median_filter(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double radius = 0.0; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 1: radius = NUM2DBL(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc); break; } exception = AcquireExceptionInfo(); new_image = StatisticImage(image, MedianStatistic, (size_t)radius, (size_t)radius, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#mime_type ⇒ String?
Return the officially registered (or de facto) MIME media-type corresponding to the image format.
9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 |
# File 'ext/RMagick/rmimage.c', line 9081 VALUE Image_mime_type(VALUE self) { Image *image; char *type; VALUE mime_type; image = rm_check_destroyed(self); type = MagickToMime(image->magick); if (!type) { return Qnil; } mime_type = rb_str_new2(type); // The returned string must be deallocated by the user. magick_free(type); RB_GC_GUARD(mime_type); return mime_type; } |
#minify ⇒ Magick::Image
Scale an image proportionally to half its size.
9111 9112 9113 9114 9115 9116 |
# File 'ext/RMagick/rmimage.c', line 9111 VALUE Image_minify(VALUE self) { rm_check_destroyed(self); return magnify(False, self, MinifyImage); } |
#minify! ⇒ Magick::Image
Scale an image proportionally to half its size. In-place form of #minify.
9125 9126 9127 9128 9129 9130 |
# File 'ext/RMagick/rmimage.c', line 9125 VALUE Image_minify_bang(VALUE self) { rm_check_frozen(self); return magnify(True, self, MinifyImage); } |
#modulate(brightness = 1.0, saturation = 1.0, hue = 1.0) ⇒ Magick::Image
Changes the brightness, saturation, and hue.
9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 |
# File 'ext/RMagick/rmimage.c', line 9142 VALUE Image_modulate(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double pct_brightness = 100.0, pct_saturation = 100.0, pct_hue = 100.0; char modulate[100]; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); switch (argc) { case 3: pct_hue = 100*NUM2DBL(argv[2]); case 2: pct_saturation = 100*NUM2DBL(argv[1]); case 1: pct_brightness = 100*NUM2DBL(argv[0]); break; case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 3)", argc); break; } if (pct_brightness <= 0.0) { rb_raise(rb_eArgError, "brightness is %g%%, must be positive", pct_brightness); } snprintf(modulate, sizeof(modulate), "%f%%,%f%%,%f%%", pct_brightness, pct_saturation, pct_hue); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); ModulateImage(new_image, modulate, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else ModulateImage(new_image, modulate); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#monitor=(monitor) ⇒ Proc
Magick::Image#monitor= is deprecated. This method will be removed in RMagick 5.0.
Establish a progress monitor.
-
A progress monitor is a callable object. Save the monitor proc as the client_data and establish ‘progress_monitor’ as the monitor exit. When ‘progress_monitor’ is called, retrieve the proc and call it.
9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 |
# File 'ext/RMagick/rmimage.c', line 9209 VALUE Image_monitor_eq(VALUE self, VALUE monitor) { Image *image = rm_check_frozen(self); rb_warning("Magick::Image#monitor= is deprecated. This method will be removed in RMagick 5.0."); if (NIL_P(monitor)) { image->progress_monitor = NULL; } else { SetImageProgressMonitor(image, rm_progress_monitor, (void *)monitor); } return monitor; } |
#monochrome? ⇒ Boolean
Return true if all the pixels in the image have the same red, green, and blue intensities and the intensity is either 0 or QuantumRange.
9235 9236 9237 9238 9239 9240 9241 9242 9243 |
# File 'ext/RMagick/rmimage.c', line 9235 VALUE Image_monochrome_q(VALUE self) { #if defined(IMAGEMAGICK_7) return has_image_attribute(self, IsImageMonochrome); #else return has_attribute(self, IsMonochromeImage); #endif } |
#montage ⇒ String
Tile size and offset within an image montage. Only valid for montage images.
9251 9252 9253 9254 9255 |
# File 'ext/RMagick/rmimage.c', line 9251 VALUE Image_montage(VALUE self) { IMPLEMENT_ATTR_READER(Image, montage, str); } |
#morphology(method_v, iterations, kernel_v) ⇒ Magick::Image
Apply a user supplied kernel to the image according to the given mophology method.
4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 |
# File 'ext/RMagick/rmimage.c', line 4365 VALUE Image_morphology(VALUE self, VALUE method_v, VALUE iterations, VALUE kernel_v) { static VALUE default_channels_const = 0; if(!default_channels_const) { default_channels_const = rb_const_get(Module_Magick, rb_intern("DefaultChannels")); } return Image_morphology_channel(self, default_channels_const, method_v, iterations, kernel_v); } |
#morphology_channel(channel_v, method_v, iterations, kernel_v) ⇒ Magick::Image
Apply a user supplied kernel to the image channel according to the given mophology method.
4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 |
# File 'ext/RMagick/rmimage.c', line 4391 VALUE Image_morphology_channel(VALUE self, VALUE channel_v, VALUE method_v, VALUE iterations, VALUE kernel_v) { Image *image, *new_image; ExceptionInfo *exception; MorphologyMethod method; ChannelType channel; KernelInfo *kernel; image = rm_check_destroyed(self); VALUE_TO_ENUM(method_v, method, MorphologyMethod); VALUE_TO_ENUM(channel_v, channel, ChannelType); Check_Type(iterations, T_FIXNUM); if (TYPE(kernel_v) == T_STRING) { kernel_v = rb_class_new_instance(1, &kernel_v, Class_KernelInfo); } if (!rb_obj_is_kind_of(kernel_v, Class_KernelInfo)) { rb_raise(rb_eArgError, "expected String or Magick::KernelInfo"); } Data_Get_Struct(kernel_v, KernelInfo, kernel); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channel); new_image = MorphologyImage(image, method, NUM2LONG(iterations), kernel, exception); CHANGE_RESULT_CHANNEL_MASK(new_image); END_CHANNEL_MASK(image); #else new_image = MorphologyImageChannel(image, channel, method, NUM2LONG(iterations), kernel, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#motion_blur(radius = 0.0, sigma = 1.0, angle = 0.0) ⇒ Magick::Image
Simulate motion blur. Convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and motion_blur selects a suitable radius for you. Angle gives the angle of the blurring motion.
9324 9325 9326 9327 9328 9329 |
# File 'ext/RMagick/rmimage.c', line 9324 VALUE Image_motion_blur(int argc, VALUE *argv, VALUE self) { rm_check_destroyed(self); return motion_blur(argc, argv, self, MotionBlurImage); } |
#negate(grayscale = false) ⇒ Magick::Image
Negate the colors in the reference image. The grayscale option means that only grayscale values within the image are negated.
9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 |
# File 'ext/RMagick/rmimage.c', line 9340 VALUE Image_negate(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; unsigned int grayscale = MagickFalse; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); if (argc == 1) { grayscale = RTEST(argv[0]); } else if (argc > 1) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc); } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); NegateImage(new_image, grayscale, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else NegateImage(new_image, grayscale); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#negate_channel(grayscale = false, channel = Magick::AllChannels) ⇒ Magick::Image #negate_channel(grayscale = false, *channels) ⇒ Magick::Image
Negate the colors on a particular channel. The grayscale option means that only grayscale values within the image are negated.
9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 |
# File 'ext/RMagick/rmimage.c', line 9392 VALUE Image_negate_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; ChannelType channels; unsigned int grayscale = MagickFalse; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // There can be at most 1 remaining argument. if (argc > 1) { raise_ChannelType_error(argv[argc-1]); } else if (argc == 1) { grayscale = RTEST(argv[0]); } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(new_image, channels); NegateImage(new_image, grayscale, exception); END_CHANNEL_MASK(new_image); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else NegateImageChannel(new_image, channels, grayscale); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#normalize ⇒ Magick::Image
Enhance the contrast of a color image by adjusting the pixels color to span the entire range of colors available.
9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 |
# File 'ext/RMagick/rmimage.c', line 9565 VALUE Image_normalize(VALUE self) { Image *image, *new_image; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); NormalizeImage(new_image, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else NormalizeImage(new_image); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#normalize_channel(channel = Magick::AllChannels) ⇒ Magick::Image
Enhances the contrast of a color image by adjusting the pixel color to span the entire range of colors available. Only the specified channels are normalized.
9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 |
# File 'ext/RMagick/rmimage.c', line 9598 VALUE Image_normalize_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; ChannelType channels; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // Ensure all arguments consumed. if (argc > 0) { raise_ChannelType_error(argv[argc-1]); } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(new_image, channels); NormalizeImage(new_image, exception); END_CHANNEL_MASK(new_image); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else NormalizeImageChannel(new_image, channels); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#normalized_maximum_error ⇒ Float
Get The normalized maximum error per pixel computed when an image is color reduced.
9649 9650 9651 9652 9653 |
# File 'ext/RMagick/rmimage.c', line 9649 VALUE Image_normalized_maximum_error(VALUE self) { IMPLEMENT_ATTR_READERF(Image, normalized_maximum_error, error.normalized_maximum_error, dbl); } |
#normalized_mean_error ⇒ Float
Get the normalized mean error per pixel computed when an image is color reduced.
9638 9639 9640 9641 9642 |
# File 'ext/RMagick/rmimage.c', line 9638 VALUE Image_normalized_mean_error(VALUE self) { IMPLEMENT_ATTR_READERF(Image, normalized_mean_error, error.normalized_mean_error, dbl); } |
#number_colors ⇒ Numeric
Return the number of unique colors in the image.
9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 |
# File 'ext/RMagick/rmimage.c', line 9661 VALUE Image_number_colors(VALUE self) { Image *image; ExceptionInfo *exception; unsigned long n = 0; image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); n = (unsigned long) GetNumberColors(image, NULL, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); return ULONG2NUM(n); } |
#offset ⇒ Number
Get the number of bytes to skip over when reading raw image.
9685 9686 9687 9688 9689 |
# File 'ext/RMagick/rmimage.c', line 9685 VALUE Image_offset(VALUE self) { IMPLEMENT_ATTR_READER(Image, offset, long); } |
#offset=(val) ⇒ Number
Set the number of bytes to skip over when reading raw image.
9697 9698 9699 9700 9701 |
# File 'ext/RMagick/rmimage.c', line 9697 VALUE Image_offset_eq(VALUE self, VALUE val) { IMPLEMENT_ATTR_WRITER(Image, offset, long); } |
#oil_paint(radius = 3.0) ⇒ Magick::Image
Apply a special effect filter that simulates an oil painting.
9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 |
# File 'ext/RMagick/rmimage.c', line 9711 VALUE Image_oil_paint(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double radius = 3.0; ExceptionInfo *exception; #if defined(IMAGEMAGICK_7) double sigma = 1.0; #endif image = rm_check_destroyed(self); switch (argc) { case 1: radius = NUM2DBL(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc); break; } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) new_image = OilPaintImage(image, radius, sigma, exception); #else new_image = OilPaintImage(image, radius, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#opaque(target, fill) ⇒ Magick::Image
Change any pixel that matches target with the color defined by fill.
- By default a pixel must match the specified target color exactly.
- Use {Image#fuzz=} to set the amount of tolerance acceptable to consider two colors as the
same.
9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 |
# File 'ext/RMagick/rmimage.c', line 9759 VALUE Image_opaque(VALUE self, VALUE target, VALUE fill) { Image *image, *new_image; MagickPixel target_pp; MagickPixel fill_pp; MagickBooleanType okay; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); // Allow color name or Pixel Color_to_MagickPixel(image, &target_pp, target); Color_to_MagickPixel(image, &fill_pp, fill); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); okay = OpaquePaintImage(new_image, &target_pp, &fill_pp, MagickFalse, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else okay = OpaquePaintImageChannel(new_image, DefaultChannels, &target_pp, &fill_pp, MagickFalse); rm_check_image_exception(new_image, DestroyOnError); #endif if (!okay) { // Force exception DestroyImage(new_image); rm_ensure_result(NULL); } return rm_image_new(new_image); } |
#opaque? ⇒ Boolean
Returns true if all of the pixels in the receiver have an opacity value of OpaqueOpacity.
9898 9899 9900 9901 9902 9903 9904 9905 9906 |
# File 'ext/RMagick/rmimage.c', line 9898 VALUE Image_opaque_q(VALUE self) { #if defined(IMAGEMAGICK_7) return has_attribute(self, IsImageOpaque); #else return has_attribute(self, IsOpaqueImage); #endif } |
#opaque_channel(target, fill, invert = false, fuzz = self.fuzz, channel = Magick::AllChannels) ⇒ Magick::Image #opaque_channel(target, fill, invert, fuzz, *channels) ⇒ Magick::Image
Changes all pixels having the target color to the fill color. If invert is true, changes all the pixels that are not the target color to the fill color.
9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 |
# File 'ext/RMagick/rmimage.c', line 9821 VALUE Image_opaque_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; MagickPixel target_pp, fill_pp; ChannelType channels; double keep, fuzz; MagickBooleanType okay, invert = MagickFalse; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); if (argc > 4) { raise_ChannelType_error(argv[argc-1]); } // Default fuzz value is image's fuzz attribute. fuzz = image->fuzz; switch (argc) { case 4: fuzz = NUM2DBL(argv[3]); if (fuzz < 0.0) { rb_raise(rb_eArgError, "fuzz must be >= 0.0 (%g given)", fuzz); } case 3: invert = RTEST(argv[2]); case 2: // Allow color name or Pixel Color_to_MagickPixel(image, &fill_pp, argv[1]); Color_to_MagickPixel(image, &target_pp, argv[0]); break; default: rb_raise(rb_eArgError, "wrong number of arguments (got %d, expected 2 or more)", argc); break; } new_image = rm_clone_image(image); keep = new_image->fuzz; new_image->fuzz = fuzz; #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(new_image, channels); okay = OpaquePaintImage(new_image, &target_pp, &fill_pp, invert, exception); END_CHANNEL_MASK(new_image); new_image->fuzz = keep; rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else okay = OpaquePaintImageChannel(new_image, channels, &target_pp, &fill_pp, invert); new_image->fuzz = keep; rm_check_image_exception(new_image, DestroyOnError); #endif if (!okay) { // Force exception DestroyImage(new_image); rm_ensure_result(NULL); } return rm_image_new(new_image); } |
#ordered_dither(threshold_map = '2x2') ⇒ Magick::Image
Dithers the image to a predefined pattern. The threshold_map argument defines the pattern to use.
-
Default threshold_map is ‘2x2’
-
Order of threshold_map must be 2, 3, or 4.
9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 |
# File 'ext/RMagick/rmimage.c', line 9919 VALUE Image_ordered_dither(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; int order; const char *threshold_map = "2x2"; ExceptionInfo *exception; image = rm_check_destroyed(self); if (argc > 1) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc); } if (argc == 1) { if (TYPE(argv[0]) == T_STRING) { threshold_map = StringValueCStr(argv[0]); } else { order = NUM2INT(argv[0]); if (order == 3) { threshold_map = "3x3"; } else if (order == 4) { threshold_map = "4x4"; } else if (order != 2) { rb_raise(rb_eArgError, "order must be 2, 3, or 4 (%d given)", order); } } } new_image = rm_clone_image(image); exception = AcquireExceptionInfo(); OrderedDitherImage(new_image, threshold_map, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#orientation ⇒ Magick::OrientationType
Get the value of the Exif Orientation Tag.
9975 9976 9977 9978 9979 9980 |
# File 'ext/RMagick/rmimage.c', line 9975 VALUE Image_orientation(VALUE self) { Image *image = rm_check_destroyed(self); return OrientationType_find(image->orientation); } |
#orientation=(orientation) ⇒ Magick::OrientationType
Set the orientation attribute.
9989 9990 9991 9992 9993 9994 9995 |
# File 'ext/RMagick/rmimage.c', line 9989 VALUE Image_orientation_eq(VALUE self, VALUE orientation) { Image *image = rm_check_frozen(self); VALUE_TO_ENUM(orientation, image->orientation, OrientationType); return orientation; } |
#page ⇒ Magick::Rectang
The page attribute getter.
10003 10004 10005 10006 10007 10008 |
# File 'ext/RMagick/rmimage.c', line 10003 VALUE Image_page(VALUE self) { Image *image = rm_check_destroyed(self); return Import_RectangleInfo(&image->page); } |
#page=(rect) ⇒ Magick::Rectang
The page attribute setter.
10017 10018 10019 10020 10021 10022 10023 |
# File 'ext/RMagick/rmimage.c', line 10017 VALUE Image_page_eq(VALUE self, VALUE rect) { Image *image = rm_check_frozen(self); Export_RectangleInfo(&image->page, rect); return rect; } |
#paint_transparent(target, invert, fuzz, alpha: Magick::TransparentAlpha) ⇒ Magick::Image
Changes the opacity value of all the pixels that match color to the value specified by opacity. If invert is true, changes the pixels that don’t match color.
10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 |
# File 'ext/RMagick/rmimage.c', line 10040 VALUE Image_paint_transparent(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; MagickPixel color; Quantum alpha = TransparentAlpha; double keep, fuzz; MagickBooleanType okay, invert; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); // Default fuzz value is image's fuzz attribute. fuzz = image->fuzz; invert = MagickFalse; switch (argc) { case 4: if (TYPE(argv[argc - 1]) == T_HASH) { fuzz = NUM2DBL(argv[2]); } else { fuzz = NUM2DBL(argv[3]); } case 3: if (TYPE(argv[argc - 1]) == T_HASH) { invert = RTEST(argv[1]); } else { invert = RTEST(argv[2]); } case 2: alpha = get_named_alpha_value(argv[argc - 1]); case 1: Color_to_MagickPixel(image, &color, argv[0]); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 to 4)", argc); break; } new_image = rm_clone_image(image); // Use fuzz value from caller keep = new_image->fuzz; new_image->fuzz = fuzz; #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); okay = TransparentPaintImage(new_image, (const MagickPixel *)&color, alpha, invert, exception); new_image->fuzz = keep; rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else okay = TransparentPaintImage(new_image, (const MagickPixel *)&color, QuantumRange - alpha, invert); new_image->fuzz = keep; // Is it possible for TransparentPaintImage to silently fail? rm_check_image_exception(new_image, DestroyOnError); #endif if (!okay) { // Force exception DestroyImage(new_image); rm_ensure_result(NULL); } return rm_image_new(new_image); } |
#palette? ⇒ Boolean
Return true if the image is PseudoClass and has 256 unique colors or less.
10124 10125 10126 10127 10128 10129 10130 10131 10132 |
# File 'ext/RMagick/rmimage.c', line 10124 VALUE Image_palette_q(VALUE self) { #if defined(IMAGEMAGICK_7) return has_image_attribute(self, IsPaletteImage); #else return has_attribute(self, IsPaletteImage); #endif } |
#pixel_color(x, y) ⇒ Magick::Pixel #pixel_color(x, y, color) ⇒ Magick::Pixel
Get/set the color of the pixel at x, y.
10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 |
# File 'ext/RMagick/rmimage.c', line 10164 VALUE Image_pixel_color(int argc, VALUE *argv, VALUE self) { Image *image; Pixel new_color; PixelPacket old_color; ExceptionInfo *exception; long x, y; unsigned int set = False; MagickBooleanType okay; #if defined(IMAGEMAGICK_7) Quantum *pixel; const Quantum *old_pixel; #else PixelPacket *pixel; const PixelPacket *old_pixel; MagickPixel mpp; IndexPacket *indexes; #endif memset(&old_color, 0, sizeof(old_color)); image = rm_check_destroyed(self); switch (argc) { case 3: rb_check_frozen(self); set = True; // Replace with new color? The arg can be either a color name or // a Magick::Pixel. Color_to_Pixel(&new_color, argv[2]); case 2: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc); break; } x = NUM2LONG(argv[0]); y = NUM2LONG(argv[1]); // Get the color of a pixel if (!set) { exception = AcquireExceptionInfo(); old_pixel = GetVirtualPixels(image, x, y, 1, 1, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #if defined(IMAGEMAGICK_7) old_color.red = GetPixelRed(image, old_pixel); old_color.green = GetPixelGreen(image, old_pixel); old_color.blue = GetPixelBlue(image, old_pixel); old_color.alpha = GetPixelAlpha(image, old_pixel); old_color.black = GetPixelBlack(image, old_pixel); return Pixel_from_PixelPacket(&old_color); #else old_color = *old_pixel; indexes = GetAuthenticIndexQueue(image); // PseudoClass if (image->storage_class == PseudoClass) { old_color = image->colormap[(unsigned long)*indexes]; } if (!image->matte) { old_color.opacity = OpaqueOpacity; } rm_init_magickpixel(image, &mpp); mpp.red = GetPixelRed(&old_color); mpp.green = GetPixelGreen(&old_color); mpp.blue = GetPixelBlue(&old_color); mpp.opacity = GetPixelOpacity(&old_color); if (indexes) { mpp.index = GetPixelIndex(indexes); } return Pixel_from_MagickPixel(&mpp); #endif } // ImageMagick segfaults if the pixel location is out of bounds. // Do what IM does and return the background color. if (x < 0 || y < 0 || (unsigned long)x >= image->columns || (unsigned long)y >= image->rows) { return Pixel_from_PixelColor(&image->background_color); } #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); #endif if (image->storage_class == PseudoClass) { #if defined(IMAGEMAGICK_7) okay = SetImageStorageClass(image, DirectClass, exception); CHECK_EXCEPTION(); if (!okay) { DestroyExceptionInfo(exception); rb_raise(Class_ImageMagickError, "SetImageStorageClass failed. Can't set pixel color."); } #else okay = SetImageStorageClass(image, DirectClass); rm_check_image_exception(image, RetainOnError); if (!okay) { rb_raise(Class_ImageMagickError, "SetImageStorageClass failed. Can't set pixel color."); } #endif } #if defined(IMAGEMAGICK_6) exception = AcquireExceptionInfo(); #endif pixel = GetAuthenticPixels(image, x, y, 1, 1, exception); CHECK_EXCEPTION(); if (pixel) { #if defined(IMAGEMAGICK_7) old_color.red = GetPixelRed(image, pixel); old_color.green = GetPixelGreen(image, pixel); old_color.blue = GetPixelBlue(image, pixel); old_color.alpha = GetPixelAlpha(image, pixel); old_color.black = GetPixelBlack(image, pixel); SetPixelRed(image, new_color.red, pixel); SetPixelGreen(image, new_color.green, pixel); SetPixelBlue(image, new_color.blue, pixel); SetPixelAlpha(image, new_color.alpha, pixel); SetPixelBlack(image, new_color.black, pixel); #else old_color = *pixel; indexes = GetAuthenticIndexQueue(image); if (!image->matte) { old_color.opacity = OpaqueOpacity; } SetPixelRed(pixel, new_color.red); SetPixelGreen(pixel, new_color.green); SetPixelBlue(pixel, new_color.blue); SetPixelOpacity(pixel, new_color.opacity); if (indexes) { SetPixelIndex(indexes, new_color.black); } #endif SyncAuthenticPixels(image, exception); CHECK_EXCEPTION(); } DestroyExceptionInfo(exception); return Pixel_from_PixelPacket(&old_color); } |
#pixel_interpolation_method ⇒ Magick::PixelInterpolateMethod
Get the “interpolate” field.
10334 10335 10336 10337 10338 10339 |
# File 'ext/RMagick/rmimage.c', line 10334 VALUE Image_pixel_interpolation_method(VALUE self) { Image *image = rm_check_destroyed(self); return PixelInterpolateMethod_find(image->interpolate); } |
#pixel_interpolation_method=(method) ⇒ Magick::PixelInterpolateMethod
Set the “interpolate” field.
10349 10350 10351 10352 10353 10354 10355 |
# File 'ext/RMagick/rmimage.c', line 10349 VALUE Image_pixel_interpolation_method_eq(VALUE self, VALUE method) { Image *image = rm_check_frozen(self); VALUE_TO_ENUM(method, image->interpolate, PixelInterpolateMethod); return method; } |
#polaroid(angle = -5.0) ⇒ Magick::Image #polaroid(angle = -5.0) {|Magick::Image::Info| ... } ⇒ Magick::Image
Produce an image that looks like a Polaroid instant picture. If the image has a “Caption” property, the value is used as a caption.
The following annotate attributes control the label rendering: align, decorate, density, encoding, fill, font, font_family, font_stretch, font_style, font_weight, gravity, pointsize, stroke, stroke_width, text_antialias, undercolor.
10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 |
# File 'ext/RMagick/rmimage.c', line 10381 VALUE Image_polaroid(int argc, VALUE *argv, VALUE self) { Image *image, *clone, *new_image; VALUE ; double angle = -5.0; Draw *draw; ExceptionInfo *exception; #if defined(IMAGEMAGICK_7) const char *caption; #endif image = rm_check_destroyed(self); switch (argc) { case 1: angle = NUM2DBL(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc); break; } = rm_polaroid_new(); Data_Get_Struct(, Draw, draw); clone = rm_clone_image(image); clone->background_color = draw->shadow_color; clone->border_color = draw->info->border_color; exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) caption = GetImageProperty(clone, "Caption", exception); new_image = PolaroidImage(clone, draw->info, caption, angle, image->interpolate, exception); #else new_image = PolaroidImage(clone, draw->info, angle, exception); #endif rm_check_exception(exception, clone, DestroyOnError); DestroyImage(clone); DestroyExceptionInfo(exception); RB_GC_GUARD(); return rm_image_new(new_image); } |
#posterize(levels = 4, dither = false) ⇒ Object
Reduces the image to a limited number of colors for a “poster” effect.
10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 |
# File 'ext/RMagick/rmimage.c', line 10439 VALUE Image_posterize(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; MagickBooleanType dither = MagickFalse; unsigned long levels = 4; #if defined(IMAGEMAGICK_7) DitherMethod dither_method; ExceptionInfo *exception; #endif image = rm_check_destroyed(self); switch (argc) { case 2: dither = (MagickBooleanType) RTEST(argv[1]); /* fall through */ case 1: levels = NUM2ULONG(argv[0]); /* fall through */ case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc); } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); dither_method = dither ? RiemersmaDitherMethod : NoDitherMethod; PosterizeImage(new_image, levels, dither_method, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else PosterizeImage(new_image, levels, dither); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#preview(preview) ⇒ Magick::Image
Creates an image that contains 9 small versions of the receiver image. The center image is the unchanged receiver. The other 8 images are variations created by transforming the receiver according to the specified preview type with varying parameters.
10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 |
# File 'ext/RMagick/rmimage.c', line 10489 VALUE Image_preview(VALUE self, VALUE preview) { Image *image, *new_image; PreviewType preview_type; ExceptionInfo *exception; image = rm_check_destroyed(self); VALUE_TO_ENUM(preview, preview_type, PreviewType); exception = AcquireExceptionInfo(); new_image = PreviewImage(image, preview_type, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#profile!(name, profile) ⇒ Magick::Image
Set the image profile. If “profile” is nil, deletes the profile. Otherwise “profile” must be a string containing the specified profile.
10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 |
# File 'ext/RMagick/rmimage.c', line 10517 VALUE Image_profile_bang(VALUE self, VALUE name, VALUE profile) { if (profile == Qnil) { return Image_delete_profile(self, name); } else { return set_profile(self, StringValueCStr(name), profile); } } |
#properties ⇒ Hash #properties {|Magick::Image::Info| ... } ⇒ Magick::Image
If called with an associated block, properties runs the block once for each property defined for the image. The block arguments are the property name and its value. If there is no block, properties returns a hash with one element for each property. The hash key is the property name and the associated value is the property value.
12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 |
# File 'ext/RMagick/rmimage.c', line 12352 VALUE Image_properties(VALUE self) { Image *image; VALUE attr_hash, ary; const char *property, *value; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); #endif if (rb_block_given_p()) { ary = rb_ary_new2(2); ResetImagePropertyIterator(image); property = GetNextImageProperty(image); while (property) { #if defined(IMAGEMAGICK_7) value = GetImageProperty(image, property, exception); #else value = GetImageProperty(image, property); #endif rb_ary_store(ary, 0, rb_str_new2(property)); rb_ary_store(ary, 1, rb_str_new2(value)); rb_yield(ary); property = GetNextImageProperty(image); } #if defined(IMAGEMAGICK_7) CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else rm_check_image_exception(image, RetainOnError); #endif RB_GC_GUARD(ary); return self; } // otherwise return properties hash else { attr_hash = rb_hash_new(); ResetImagePropertyIterator(image); property = GetNextImageProperty(image); while (property) { #if defined(IMAGEMAGICK_7) value = GetImageProperty(image, property, exception); #else value = GetImageProperty(image, property); #endif rb_hash_aset(attr_hash, rb_str_new2(property), rb_str_new2(value)); property = GetNextImageProperty(image); } #if defined(IMAGEMAGICK_7) CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else rm_check_image_exception(image, RetainOnError); #endif RB_GC_GUARD(attr_hash); return attr_hash; } } |
#quality ⇒ Numeric
Get image quality.
10538 10539 10540 10541 10542 |
# File 'ext/RMagick/rmimage.c', line 10538 VALUE Image_quality(VALUE self) { IMPLEMENT_ATTR_READER(Image, quality, ulong); } |
#quantize(number_colors = 256, colorspace = Magick::RGBColorspace, dither = true, tree_depth = 0, measure_error = false) ⇒ Magick::Image
Analyzes the colors within a reference image and chooses a fixed number of colors to represent the image. The goal of the algorithm is to minimize the difference between the input and output image while minimizing the processing time.
10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 |
# File 'ext/RMagick/rmimage.c', line 10758 VALUE Image_quantize(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; QuantizeInfo quantize_info; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); GetQuantizeInfo(&quantize_info); switch (argc) { case 5: quantize_info.measure_error = (MagickBooleanType) RTEST(argv[4]); case 4: quantize_info.tree_depth = NUM2UINT(argv[3]); case 3: if (rb_obj_is_kind_of(argv[2], Class_DitherMethod)) { VALUE_TO_ENUM(argv[2], quantize_info.dither_method, DitherMethod); #if defined(IMAGEMAGICK_6) quantize_info.dither = quantize_info.dither_method != NoDitherMethod; #endif } else { #if defined(IMAGEMAGICK_7) quantize_info.dither_method = RTEST(argv[2]) ? RiemersmaDitherMethod : NoDitherMethod; #else quantize_info.dither = (MagickBooleanType) RTEST(argv[2]); #endif } case 2: VALUE_TO_ENUM(argv[1], quantize_info.colorspace, ColorspaceType); case 1: quantize_info.number_colors = NUM2UINT(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 5)", argc); break; } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); QuantizeImage(&quantize_info, new_image, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else QuantizeImage(&quantize_info, new_image); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#quantum_depth ⇒ Numeric
Return the image depth to the nearest Quantum (8, 16, or 32).
10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 |
# File 'ext/RMagick/rmimage.c', line 10550 VALUE Image_quantum_depth(VALUE self) { Image *image; unsigned long quantum_depth; image = rm_check_destroyed(self); quantum_depth = GetImageQuantumDepth(image, MagickFalse); return ULONG2NUM(quantum_depth); } |
#quantum_operator(operator, rvalue, channel = Magick::AllChannels) ⇒ Magick::Image #quantum_operator(operator, rvalue, *channels) ⇒ Magick::Image
Performs the requested integer arithmetic operation on the selected channel of the image. This method allows simple arithmetic operations on the component values of all pixels in an image. Of course, you could also do this in Ruby using get_pixels and store_pixels, or view, but quantum_operator will be faster, especially for large numbers of pixels, since it does not need to convert the pixels from C to Ruby.
10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 |
# File 'ext/RMagick/rmimage.c', line 10583 VALUE Image_quantum_operator(int argc, VALUE *argv, VALUE self) { Image *image; QuantumExpressionOperator operator; MagickEvaluateOperator qop; double rvalue; ChannelType channel; ExceptionInfo *exception; image = rm_check_destroyed(self); // The default channel is AllChannels channel = AllChannels; /* If there are 3 arguments, argument 2 is a ChannelType argument. Arguments 1 and 0 are required and are the rvalue and operator, respectively. */ switch (argc) { case 3: VALUE_TO_ENUM(argv[2], channel, ChannelType); /* Fall through */ case 2: rvalue = NUM2DBL(argv[1]); VALUE_TO_ENUM(argv[0], operator, QuantumExpressionOperator); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc); break; } // Map QuantumExpressionOperator to MagickEvaluateOperator switch (operator) { default: case UndefinedQuantumOperator: qop = UndefinedEvaluateOperator; break; case AddQuantumOperator: qop = AddEvaluateOperator; break; case AndQuantumOperator: qop = AndEvaluateOperator; break; case DivideQuantumOperator: qop = DivideEvaluateOperator; break; case LShiftQuantumOperator: qop = LeftShiftEvaluateOperator; break; case MaxQuantumOperator: qop = MaxEvaluateOperator; break; case MinQuantumOperator: qop = MinEvaluateOperator; break; case MultiplyQuantumOperator: qop = MultiplyEvaluateOperator; break; case OrQuantumOperator: qop = OrEvaluateOperator; break; case RShiftQuantumOperator: qop = RightShiftEvaluateOperator; break; case SubtractQuantumOperator: qop = SubtractEvaluateOperator; break; case XorQuantumOperator: qop = XorEvaluateOperator; break; case PowQuantumOperator: qop = PowEvaluateOperator; break; case LogQuantumOperator: qop = LogEvaluateOperator; break; case ThresholdQuantumOperator: qop = ThresholdEvaluateOperator; break; case ThresholdBlackQuantumOperator: qop = ThresholdBlackEvaluateOperator; break; case ThresholdWhiteQuantumOperator: qop = ThresholdWhiteEvaluateOperator; break; case GaussianNoiseQuantumOperator: qop = GaussianNoiseEvaluateOperator; break; case ImpulseNoiseQuantumOperator: qop = ImpulseNoiseEvaluateOperator; break; case LaplacianNoiseQuantumOperator: qop = LaplacianNoiseEvaluateOperator; break; case MultiplicativeNoiseQuantumOperator: qop = MultiplicativeNoiseEvaluateOperator; break; case PoissonNoiseQuantumOperator: qop = PoissonNoiseEvaluateOperator; break; case UniformNoiseQuantumOperator: qop = UniformNoiseEvaluateOperator; break; case CosineQuantumOperator: qop = CosineEvaluateOperator; break; case SetQuantumOperator: qop = SetEvaluateOperator; break; case SineQuantumOperator: qop = SineEvaluateOperator; break; case AddModulusQuantumOperator: qop = AddModulusEvaluateOperator; break; case MeanQuantumOperator: qop = MeanEvaluateOperator; break; case AbsQuantumOperator: qop = AbsEvaluateOperator; break; case ExponentialQuantumOperator: qop = ExponentialEvaluateOperator; break; case MedianQuantumOperator: qop = MedianEvaluateOperator; break; case SumQuantumOperator: qop = SumEvaluateOperator; break; #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9) case RootMeanSquareQuantumOperator: qop = RootMeanSquareEvaluateOperator; break; #endif } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channel); EvaluateImage(image, qop, rvalue, exception); END_CHANNEL_MASK(image); #else EvaluateImageChannel(image, channel, qop, rvalue, exception); #endif CHECK_EXCEPTION(); DestroyExceptionInfo(exception); return self; } |
#radial_blur(angle_obj) ⇒ Magick::Image
Applies a radial blur to the image.
10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 |
# File 'ext/RMagick/rmimage.c', line 10825 VALUE Image_radial_blur(VALUE self, VALUE angle_obj) { Image *image, *new_image; ExceptionInfo *exception; double angle = NUM2DBL(angle_obj); image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9) new_image = RotationalBlurImage(image, angle, exception); #else new_image = RadialBlurImage(image, angle, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#radial_blur_channel(angle, channel = Magick::AllChannels) ⇒ Magick::Image #radial_blur_channel(angle, *channels) ⇒ Magick::Image
Applies a radial blur to the selected image channels.
10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 |
# File 'ext/RMagick/rmimage.c', line 10860 VALUE Image_radial_blur_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; ExceptionInfo *exception; ChannelType channels; double angle; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // There must be 1 remaining argument. if (argc == 0) { rb_raise(rb_eArgError, "wrong number of arguments (0 for 1 or more)"); } else if (argc > 1) { raise_ChannelType_error(argv[argc-1]); } angle = NUM2DBL(argv[0]); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); new_image = RotationalBlurImage(image, angle, exception); CHANGE_RESULT_CHANNEL_MASK(new_image); END_CHANNEL_MASK(image); #elif defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9) new_image = RotationalBlurImageChannel(image, channels, angle, exception); #else new_image = RadialBlurImageChannel(image, channels, angle, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#raise(width = 6, height = 6, raised = true) ⇒ Magick::Image
Create a simulated three-dimensional button-like effect by lightening and darkening the edges of the image. The “width” and “height” arguments define the width of the vertical and horizontal edge of the effect. If “raised” is true, creates a raised effect, otherwise a lowered effect.
10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 |
# File 'ext/RMagick/rmimage.c', line 10980 VALUE Image_raise(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; RectangleInfo rect; int raised = MagickTrue; // default #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif memset(&rect, 0, sizeof(rect)); rect.width = 6; // default rect.height = 6; // default image = rm_check_destroyed(self); switch (argc) { case 3: raised = RTEST(argv[2]); case 2: rect.height = NUM2ULONG(argv[1]); case 1: rect.width = NUM2ULONG(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 3)", argc); break; } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); RaiseImage(new_image, &rect, raised, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else RaiseImage(new_image, &rect, raised); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#random_threshold_channel(geometry_str, channel = Magick::AllChannels) ⇒ Magick::Image #random_threshold_channel(geometry_str, *channels) ⇒ Magick::Image
Changes the value of individual pixels based on the intensity of each pixel compared to a random threshold. The result is a low-contrast, two color image.
10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 |
# File 'ext/RMagick/rmimage.c', line 10916 VALUE Image_random_threshold_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; ChannelType channels; char *thresholds; VALUE geom_str; ExceptionInfo *exception; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // There must be 1 remaining argument. if (argc == 0) { rb_raise(rb_eArgError, "missing threshold argument"); } else if (argc > 1) { raise_ChannelType_error(argv[argc-1]); } // Accept any argument that has a to_s method. geom_str = rb_String(argv[0]); thresholds = StringValueCStr(geom_str); new_image = rm_clone_image(image); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(new_image, channels); { GeometryInfo geometry_info; ParseGeometry(thresholds, &geometry_info); RandomThresholdImage(new_image, geometry_info.rho, geometry_info.sigma, exception); } END_CHANNEL_MASK(new_image); #else RandomThresholdImageChannel(new_image, channels, thresholds, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); RB_GC_GUARD(geom_str); return rm_image_new(new_image); } |
#recolor(color_matrix) ⇒ Magick::Image
Use this method to translate, scale, shear, or rotate image colors. Although you can use variable sized matrices, typically you use a 5x5 for an RGBA image and a 6x6 for CMYKA. Populate the last row with normalized values to translate.
11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 |
# File 'ext/RMagick/rmimage.c', line 11158 VALUE Image_recolor(VALUE self, VALUE color_matrix) { Image *image, *new_image; unsigned long order; long x, len; double *matrix; ExceptionInfo *exception; KernelInfo *kernel_info; image = rm_check_destroyed(self); color_matrix = rm_check_ary_type(color_matrix); // Allocate color matrix from Ruby's memory len = RARRAY_LEN(color_matrix); matrix = ALLOC_N(double, len); for (x = 0; x < len; x++) { VALUE element = rb_ary_entry(color_matrix, x); if (rm_check_num2dbl(element)) { matrix[x] = NUM2DBL(element); } else { xfree(matrix); rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(element))); } } order = (unsigned long)sqrt((double)(len + 1.0)); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) kernel_info = AcquireKernelInfo(NULL, exception); if (rm_should_raise_exception(exception, RetainExceptionRetention)) { if (kernel_info != (KernelInfo *) NULL) { DestroyKernelInfo(kernel_info); } xfree((void *)matrix); rm_raise_exception(exception); } #else kernel_info = AcquireKernelInfo(NULL); #endif if (kernel_info == (KernelInfo *) NULL) { xfree((void *) matrix); DestroyExceptionInfo(exception); return Qnil; } kernel_info->width = order; kernel_info->height = order; kernel_info->values = (double *) matrix; new_image = ColorMatrixImage(image, kernel_info, exception); kernel_info->values = (double *) NULL; DestroyKernelInfo(kernel_info); xfree((void *) matrix); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#reduce_noise(radius) ⇒ Magick::Image
Smooth the contours of an image while still preserving edge information.
11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 |
# File 'ext/RMagick/rmimage.c', line 11328 VALUE Image_reduce_noise(VALUE self, VALUE radius) { Image *image, *new_image; ExceptionInfo *exception; size_t radius_size = NUM2SIZET(radius); image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); new_image = StatisticImage(image, NonpeakStatistic, radius_size, radius_size, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#remap(remap_image, dither_method = Magick::RiemersmaDitherMethod) ⇒ Object Also known as: affinity
Reduce the number of colors in img to the colors used by remap_image. If a dither method is specified then the given colors are dithered over the image as necessary, otherwise the closest color (in RGB colorspace) is selected to replace that pixel in the image.
11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 |
# File 'ext/RMagick/rmimage.c', line 11358 VALUE Image_remap(int argc, VALUE *argv, VALUE self) { Image *image, *remap_image; QuantizeInfo quantize_info; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_frozen(self); GetQuantizeInfo(&quantize_info); switch (argc) { case 2: VALUE_TO_ENUM(argv[1], quantize_info.dither_method, DitherMethod); #if defined(IMAGEMAGICK_6) quantize_info.dither = MagickTrue; #endif break; case 1: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc); break; } remap_image = rm_check_destroyed(rm_cur_image(argv[0])); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); RemapImage(&quantize_info, image, remap_image, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else RemapImage(&quantize_info, image, remap_image); rm_check_image_exception(image, RetainOnError); #endif return self; } |
#rendering_intent ⇒ Magick::RenderingIntent
Get the type of rendering intent.
11407 11408 11409 11410 11411 11412 |
# File 'ext/RMagick/rmimage.c', line 11407 VALUE Image_rendering_intent(VALUE self) { Image *image = rm_check_destroyed(self); return RenderingIntent_find(image->rendering_intent); } |
#rendering_intent=(ri) ⇒ Magick::RenderingIntent
Set the type of rendering intent..
11421 11422 11423 11424 11425 11426 11427 |
# File 'ext/RMagick/rmimage.c', line 11421 VALUE Image_rendering_intent_eq(VALUE self, VALUE ri) { Image *image = rm_check_frozen(self); VALUE_TO_ENUM(ri, image->rendering_intent, RenderingIntent); return ri; } |
#resample(x_resolution = 72.0, y_resolution = 72.0, filter = self.filter, blur = self.blur) ⇒ Magick
Resample image to specified horizontal resolution, vertical resolution, filter and blur factor.
Resize the image so that its rendered size remains the same as the original at the specified target resolution. For example, if a 300 DPI image renders at 3 inches by 2 inches on a 300 DPI device, when the image has been resampled to 72 DPI, it will render at 3 inches by 2 inches on a 72 DPI device. Note that only a small number of image formats (e.g. JPEG, PNG, and TIFF) are capable of storing the image resolution. For formats which do not support an image resolution, the original resolution of the image must be specified via the density attribute prior to specifying the resample resolution.
11584 11585 11586 11587 11588 11589 |
# File 'ext/RMagick/rmimage.c', line 11584 VALUE Image_resample(int argc, VALUE *argv, VALUE self) { rm_check_destroyed(self); return resample(False, argc, argv, self); } |
#resample!(x_resolution = 72.0, y_resolution = 72.0, filter = self.filter, blur = self.blur) ⇒ Magick
Resample image to specified horizontal resolution, vertical resolution, filter and blur factor. In-place form of #resample.
11604 11605 11606 11607 11608 11609 |
# File 'ext/RMagick/rmimage.c', line 11604 VALUE Image_resample_bang(int argc, VALUE *argv, VALUE self) { rm_check_frozen(self); return resample(True, argc, argv, self); } |
#resize(scale) ⇒ Magick::Image #resize(cols, rows, filter, blur) ⇒ Magick::Image
Scale an image to the desired dimensions using the specified filter and blur factor.
11725 11726 11727 11728 11729 11730 |
# File 'ext/RMagick/rmimage.c', line 11725 VALUE Image_resize(int argc, VALUE *argv, VALUE self) { rm_check_destroyed(self); return resize(False, argc, argv, self); } |
#resize!(scale) ⇒ Magick::Image #resize!(cols, rows, filter, blur) ⇒ Magick::Image
Scale an image to the desired dimensions using the specified filter and blur factor. In-place form of #resize.
11751 11752 11753 11754 11755 11756 |
# File 'ext/RMagick/rmimage.c', line 11751 VALUE Image_resize_bang(int argc, VALUE *argv, VALUE self) { rm_check_frozen(self); return resize(True, argc, argv, self); } |
#resize_to_fill(ncols, nrows = nil, gravity = CenterGravity) ⇒ Object Also known as: crop_resized
Force an image to exact dimensions without changing the aspect ratio. Resize and crop if necessary. (Thanks to Jerett Taylor!)
1016 1017 1018 |
# File 'lib/rmagick_internal.rb', line 1016 def resize_to_fill(ncols, nrows = nil, gravity = CenterGravity) copy.resize_to_fill!(ncols, nrows, gravity) end |
#resize_to_fill!(ncols, nrows = nil, gravity = CenterGravity) ⇒ Object Also known as: crop_resized!
1020 1021 1022 1023 1024 1025 1026 1027 1028 |
# File 'lib/rmagick_internal.rb', line 1020 def resize_to_fill!(ncols, nrows = nil, gravity = CenterGravity) nrows ||= ncols if ncols != columns || nrows != rows scale = [ncols / columns.to_f, nrows / rows.to_f].max resize!(scale * columns + 0.5, scale * rows + 0.5) end crop!(gravity, ncols, nrows, true) if ncols != columns || nrows != rows self end |
#resize_to_fit(cols, rows = nil) ⇒ Object
Convenience method to resize retaining the aspect ratio. (Thanks to Robert Manni!)
1036 1037 1038 1039 1040 1041 |
# File 'lib/rmagick_internal.rb', line 1036 def resize_to_fit(cols, rows = nil) rows ||= cols change_geometry(Geometry.new(cols, rows)) do |ncols, nrows| resize(ncols, nrows) end end |
#resize_to_fit!(cols, rows = nil) ⇒ Object
1043 1044 1045 1046 1047 1048 |
# File 'lib/rmagick_internal.rb', line 1043 def resize_to_fit!(cols, rows = nil) rows ||= cols change_geometry(Geometry.new(cols, rows)) do |ncols, nrows| resize!(ncols, nrows) end end |
#roll(x_offset, y_offset) ⇒ Magick::Image
Offset an image as defined by x_offset and y_offset.
11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 |
# File 'ext/RMagick/rmimage.c', line 11766 VALUE Image_roll(VALUE self, VALUE x_offset, VALUE y_offset) { Image *image, *new_image; ExceptionInfo *exception; ssize_t x = NUM2LONG(x_offset); ssize_t y = NUM2LONG(y_offset); image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); new_image = RollImage(image, x, y, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#rotate(degrees) ⇒ Magick::Image #rotate(degrees, qualifier) ⇒ Magick::Image
Rotate the receiver by the specified angle. Positive angles rotate clockwise while negative angles rotate counter-clockwise. New pixels introduced by the rotation are the same color as the current background color. Set the background color to “none” to make the new pixels transparent black.
11868 11869 11870 11871 11872 11873 |
# File 'ext/RMagick/rmimage.c', line 11868 VALUE Image_rotate(int argc, VALUE *argv, VALUE self) { rm_check_destroyed(self); return rotate(False, argc, argv, self); } |
#rotate!(degrees) ⇒ Magick::Image #rotate!(degrees, qualifier) ⇒ Magick::Image
Rotate the image. In-place form of #rotate.
11892 11893 11894 11895 11896 11897 |
# File 'ext/RMagick/rmimage.c', line 11892 VALUE Image_rotate_bang(int argc, VALUE *argv, VALUE self) { rm_check_frozen(self); return rotate(True, argc, argv, self); } |
#rows ⇒ Numeric
Return image rows.
11905 11906 11907 11908 11909 |
# File 'ext/RMagick/rmimage.c', line 11905 VALUE Image_rows(VALUE self) { IMPLEMENT_ATTR_READER(Image, rows, int); } |
#sample(scale) ⇒ Magick::Image #sample(cols, rows) ⇒ Magick::Image
Scale an image to the desired dimensions with pixel sampling. Unlike other scaling methods, this method does not introduce any additional color into the scaled image.
11928 11929 11930 11931 11932 11933 |
# File 'ext/RMagick/rmimage.c', line 11928 VALUE Image_sample(int argc, VALUE *argv, VALUE self) { rm_check_destroyed(self); return scale(False, argc, argv, self, SampleImage); } |
#sample!(scale) ⇒ Magick::Image #sample!(cols, rows) ⇒ Magick::Image
Scale an image to the desired dimensions with pixel sampling. In-place form of #sample.
11952 11953 11954 11955 11956 11957 |
# File 'ext/RMagick/rmimage.c', line 11952 VALUE Image_sample_bang(int argc, VALUE *argv, VALUE self) { rm_check_frozen(self); return scale(True, argc, argv, self, SampleImage); } |
#scale(scale) ⇒ Magick::Image #scale(cols, rows) ⇒ Magick::Image
Change the size of an image to the given dimensions. Alias of #sample.
11976 11977 11978 11979 11980 11981 |
# File 'ext/RMagick/rmimage.c', line 11976 VALUE Image_scale(int argc, VALUE *argv, VALUE self) { rm_check_destroyed(self); return scale(False, argc, argv, self, ScaleImage); } |
#scale!(scale) ⇒ Magick::Image #scale!(cols, rows) ⇒ Magick::Image
Change the size of an image to the given dimensions. Alias of #sample!.
12000 12001 12002 12003 12004 12005 |
# File 'ext/RMagick/rmimage.c', line 12000 VALUE Image_scale_bang(int argc, VALUE *argv, VALUE self) { rm_check_frozen(self); return scale(True, argc, argv, self, ScaleImage); } |
#scene ⇒ Numeric
Return the scene number assigned to the image the last time the image was written to a multi-image image file.
12091 12092 12093 12094 12095 |
# File 'ext/RMagick/rmimage.c', line 12091 VALUE Image_scene(VALUE self) { IMPLEMENT_ATTR_READER(Image, scene, ulong); } |
#segment(colorspace = Magick::RGBColorspace, cluster_threshold = 1.0, smoothing_threshold = 1.5, verbose = false) ⇒ Magick::Image
Segments an image by analyzing the histograms of the color components and identifying units that are homogeneous with the fuzzy c-means technique.
12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 |
# File 'ext/RMagick/rmimage.c', line 12293 VALUE Image_segment(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; int colorspace = RGBColorspace; // These are the Magick++ defaults unsigned int verbose = MagickFalse; double cluster_threshold = 1.0; double smoothing_threshold = 1.5; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); switch (argc) { case 4: verbose = RTEST(argv[3]); case 3: smoothing_threshold = NUM2DBL(argv[2]); case 2: cluster_threshold = NUM2DBL(argv[1]); case 1: VALUE_TO_ENUM(argv[0], colorspace, ColorspaceType); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 4)", argc); break; } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); SegmentImage(new_image, colorspace, verbose, cluster_threshold, smoothing_threshold, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else SegmentImage(new_image, colorspace, verbose, cluster_threshold, smoothing_threshold); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#selective_blur_channel(radius, sigma, threshold, channel = Magick::AllChannels) ⇒ Magick::Image #selective_blur_channel(radius, sigma, threshold, *channels) ⇒ Magick::Image
Selectively blur pixels within a contrast threshold.
12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 |
# File 'ext/RMagick/rmimage.c', line 12117 VALUE Image_selective_blur_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double radius, sigma, threshold; ExceptionInfo *exception; ChannelType channels; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); if (argc > 3) { raise_ChannelType_error(argv[argc-1]); } if (argc != 3) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 3 or more)", argc); } radius = NUM2DBL(argv[0]); sigma = NUM2DBL(argv[1]); // threshold is either a floating-point number or a string in the form "NN%". // Either way it's supposed to represent a percentage of the QuantumRange. threshold = rm_percentage(argv[2], 1.0) * QuantumRange; exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); new_image = SelectiveBlurImage(image, radius, sigma, threshold, exception); CHANGE_RESULT_CHANNEL_MASK(new_image); END_CHANNEL_MASK(image); #else new_image = SelectiveBlurImageChannel(image, channels, radius, sigma, threshold, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#separate(channel = Magick::AllChannels) ⇒ Magick::ImageList #separate(*channels) ⇒ Magick::ImageList
Constructs a grayscale image for each channel specified.
12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 |
# File 'ext/RMagick/rmimage.c', line 12207 VALUE Image_separate(int argc, VALUE *argv, VALUE self) { Image *image, *new_images; ChannelType channels = 0; ExceptionInfo *exception; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // All arguments are ChannelType enums if (argc > 0) { raise_ChannelType_error(argv[argc-1]); } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); new_images = SeparateImages(image, exception); CHANGE_RESULT_CHANNEL_MASK(new_images); END_CHANNEL_MASK(image); #else new_images = SeparateImages(image, channels, exception); #endif rm_check_exception(exception, new_images, DestroyOnError); DestroyExceptionInfo(exception); return rm_imagelist_from_images(new_images); } |
#sepiatone(threshold = Magick::QuantumRange) ⇒ Magick::Image
Applies a special effect to the image, similar to the effect achieved in a photo darkroom by sepia toning.
12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 |
# File 'ext/RMagick/rmimage.c', line 12248 VALUE Image_sepiatone(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double threshold = (double) QuantumRange; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 1: threshold = NUM2DBL(argv[0]); break; case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc); } exception = AcquireExceptionInfo(); new_image = SepiaToneImage(image, threshold, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#set_channel_depth(channel_arg, depth) ⇒ Object
Sets the depth of the image channel.
12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 |
# File 'ext/RMagick/rmimage.c', line 12165 VALUE Image_set_channel_depth(VALUE self, VALUE channel_arg, VALUE depth) { Image *image; ChannelType channel; unsigned long channel_depth; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_frozen(self); VALUE_TO_ENUM(channel_arg, channel, ChannelType); channel_depth = NUM2ULONG(depth); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(image, channel); SetImageDepth(image, channel_depth, exception); END_CHANNEL_MASK(image); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else SetImageChannelDepth(image, channel, channel_depth); rm_check_image_exception(image, RetainOnError); #endif return self; } |
#shade(shading = false, azimuth = 30.0, elevation = 30.0) ⇒ Magick::Image
Shine a distant light on an image to create a three-dimensional effect. You control the positioning of the light with azimuth and elevation; azimuth is measured in degrees off the x axis and elevation is measured in pixels above the Z axis.
12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 |
# File 'ext/RMagick/rmimage.c', line 12442 VALUE Image_shade(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double azimuth = 30.0, elevation = 30.0; unsigned int shading = MagickFalse; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 3: elevation = NUM2DBL(argv[2]); case 2: azimuth = NUM2DBL(argv[1]); case 1: shading = RTEST(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 3)", argc); break; } exception = AcquireExceptionInfo(); new_image = ShadeImage(image, shading, azimuth, elevation, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#Image ⇒ Magick::Image
Call ShadowImage. X- and y-offsets are the pixel offset. Alpha is either a number between 0 and 1 or a string “NN%”. Sigma is the std. dev. of the Gaussian, in pixels.
12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 |
# File 'ext/RMagick/rmimage.c', line 12489 VALUE Image_shadow(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double alpha = 100.0; double sigma = 4.0; long x_offset = 4L; long y_offset = 4L; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 4: alpha = rm_percentage(argv[3], 1.0); // Clamp to 1.0 < x <= 100.0 if (fabs(alpha) < 0.01) { rb_warning("shadow will be transparent - alpha %g very small", alpha); } alpha = FMIN(alpha, 1.0); alpha = FMAX(alpha, 0.01); alpha *= 100.0; case 3: sigma = NUM2DBL(argv[2]); case 2: y_offset = NUM2LONG(argv[1]); case 1: x_offset = NUM2LONG(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 4)", argc); break; } exception = AcquireExceptionInfo(); new_image = ShadowImage(image, alpha, sigma, x_offset, y_offset, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#sharpen(radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Sharpen an image.
12541 12542 12543 12544 12545 |
# File 'ext/RMagick/rmimage.c', line 12541 VALUE Image_sharpen(int argc, VALUE *argv, VALUE self) { return effect_image(self, argc, argv, SharpenImage); } |
#sharpen_channel(radius = 0.0, sigma = 1.0, channel = Magick::AllChannels) ⇒ Magick::Image #sharpen_channel(radius = 0.0, sigma = 1.0, *channels) ⇒ Magick::Image
Sharpen image on a channel.
12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 |
# File 'ext/RMagick/rmimage.c', line 12563 VALUE Image_sharpen_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; ChannelType channels; ExceptionInfo *exception; double radius = 0.0, sigma = 1.0; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); // There must be 0, 1, or 2 remaining arguments. switch (argc) { case 2: sigma = NUM2DBL(argv[1]); /* Fall thru */ case 1: radius = NUM2DBL(argv[0]); /* Fall thru */ case 0: break; default: raise_ChannelType_error(argv[argc-1]); } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); new_image = SharpenImage(image, radius, sigma, exception); CHANGE_RESULT_CHANNEL_MASK(new_image); END_CHANNEL_MASK(image); #else new_image = SharpenImageChannel(image, channels, radius, sigma, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#shave(width, height) ⇒ Magick::Image
Shave pixels from the image edges, leaving a rectangle of the specified width & height in the center.
12615 12616 12617 12618 12619 12620 |
# File 'ext/RMagick/rmimage.c', line 12615 VALUE Image_shave(VALUE self, VALUE width, VALUE height) { rm_check_destroyed(self); return xform_image(False, self, INT2FIX(0), INT2FIX(0), width, height, ShaveImage); } |
#shave!(width, height) ⇒ Magick::Image
Shave pixels from the image edges, leaving a rectangle of the specified width & height in the center. In-place form of #shave.
12633 12634 12635 12636 12637 12638 |
# File 'ext/RMagick/rmimage.c', line 12633 VALUE Image_shave_bang(VALUE self, VALUE width, VALUE height) { rm_check_frozen(self); return xform_image(True, self, INT2FIX(0), INT2FIX(0), width, height, ShaveImage); } |
#shear(x_shear, y_shear) ⇒ Magick::Image
Shearing slides one edge of an image along the X or Y axis, creating a parallelogram. An X direction shear slides an edge along the X axis, while a Y direction shear slides an edge along the Y axis. The amount of the shear is controlled by a shear angle. For X direction shears, x_shear is measured relative to the Y axis, and similarly, for Y direction shears y_shear is measured relative to the X axis. Empty triangles left over from shearing the image are filled with the background color.
12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 |
# File 'ext/RMagick/rmimage.c', line 12653 VALUE Image_shear(VALUE self, VALUE x_shear, VALUE y_shear) { Image *image, *new_image; ExceptionInfo *exception; double x = NUM2DBL(x_shear); double y = NUM2DBL(y_shear); image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); new_image = ShearImage(image, x, y, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#sigmoidal_contrast_channel(contrast = 3.0, midpoint = 50.0, sharpen = false, channel = Magick::AllChannels) ⇒ Magick::Image #sigmoidal_contrast_channel(contrast = 3.0, midpoint = 50.0, sharpen = false, *channels) ⇒ Magick::Image
Adjusts the contrast of an image channel with a non-linear sigmoidal contrast algorithm. Increases the contrast of the image using a sigmoidal transfer function without saturating highlights or shadows.
12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 |
# File 'ext/RMagick/rmimage.c', line 12700 VALUE Image_sigmoidal_contrast_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; MagickBooleanType sharpen = MagickFalse; double contrast = 3.0; double midpoint = 50.0; ChannelType channels; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); switch (argc) { case 3: sharpen = (MagickBooleanType) RTEST(argv[2]); case 2: midpoint = NUM2DBL(argv[1]); case 1: contrast = NUM2DBL(argv[0]); case 0: break; default: raise_ChannelType_error(argv[argc-1]); break; } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BEGIN_CHANNEL_MASK(new_image, channels); SigmoidalContrastImage(new_image, sharpen, contrast, midpoint, exception); END_CHANNEL_MASK(new_image); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else SigmoidalContrastImageChannel(new_image, channels, sharpen, contrast, midpoint); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#signature ⇒ String?
Compute a message digest from an image pixel stream with an implementation of the NIST SHA-256 Message Digest algorithm.
12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 |
# File 'ext/RMagick/rmimage.c', line 12754 VALUE Image_signature(VALUE self) { Image *image; const char *signature; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); SignatureImage(image, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else SignatureImage(image); rm_check_image_exception(image, RetainOnError); #endif signature = rm_get_property(image, "signature"); if (!signature) { return Qnil; } return rb_str_new(signature, 64); } |
#sketch(radius = 0.0, sigma = 1.0, angle = 0.0) ⇒ Magick::Image
Simulates a pencil sketch. For best results start with a grayscale image.
12793 12794 12795 12796 12797 12798 |
# File 'ext/RMagick/rmimage.c', line 12793 VALUE Image_sketch(int argc, VALUE *argv, VALUE self) { rm_check_destroyed(self); return motion_blur(argc, argv, self, SketchImage); } |
#solarize(threshold = 50.0) ⇒ Object
Apply a special effect to the image, similar to the effect achieved in a photo darkroom by selectively exposing areas of photo sensitive paper to light. Threshold ranges from 0 to QuantumRange and is a measure of the extent of the solarization.
12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 |
# File 'ext/RMagick/rmimage.c', line 12811 VALUE Image_solarize(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double threshold = 50.0; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); switch (argc) { case 1: threshold = NUM2DBL(argv[0]); if (threshold < 0.0 || threshold > QuantumRange) { rb_raise(rb_eArgError, "threshold out of range, must be >= 0.0 and < QuantumRange"); } case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc); break; } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); SolarizeImage(new_image, threshold, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else SolarizeImage(new_image, threshold); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#sparse_color(method, x1, y1, color) ⇒ Magick::Image #sparse_color(method, x1, y1, color, x2, y2, color) ⇒ Magick::Image #sparse_color(method, x1, y1, color, x2, y2, color, ...) ⇒ Magick::Image #sparse_color(method, x1, y1, color, channel) ⇒ Magick::Image #sparse_color(method, x1, y1, color, x2, y2, color, channel) ⇒ Magick::Image #sparse_color(method, x1, y1, color, x2, y2, color, ..., channel) ⇒ Magick::Image #sparse_color(method, x1, y1, color, channel, ...) ⇒ Magick::Image #sparse_color(method, x1, y1, color, x2, y2, color, channel, ...) ⇒ Magick::Image #sparse_color(method, x1, y1, color, x2, y2, color, ..., channel, ...) ⇒ Magick::Image
Fills the image with the specified color or colors, starting at the x,y coordinates associated with the color and using the specified interpolation method.
12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 |
# File 'ext/RMagick/rmimage.c', line 12977 VALUE Image_sparse_color(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; unsigned long x, nargs, ncolors; SparseColorMethod method; int n, exp; double * volatile args; ChannelType channels; MagickPixel pp; ExceptionInfo *exception; image = rm_check_destroyed(self); n = argc; channels = extract_channels(&argc, argv); n -= argc; // n is now the number of channel arguments // After the channel arguments have been removed, and not counting the first // (method) argument, the number of arguments should be a multiple of 3. if (argc < 4 || argc % 3 != 1) { exp = (argc + 2) / 3 * 3; exp = max(exp, 3); rb_raise(rb_eArgError, "wrong number of arguments (expected at least %d, got %d)", n+exp+1, n+argc); } // Get the method from the argument list VALUE_TO_ENUM(argv[0], method, SparseColorMethod); argv += 1; argc -= 1; // A lot of the following code is based on SparseColorOption, in wand/mogrify.c ncolors = count_channels(image, &channels); nargs = (argc / 3) * (2 + ncolors); // Allocate args from Ruby's memory so that GC will collect it if one of // the type conversions below raises an exception. args = ALLOC_N(double, nargs); memset(args, 0, nargs * sizeof(double)); x = 0; n = 0; while (n < argc) { VALUE elem1 = argv[n++]; VALUE elem2 = argv[n++]; if (rm_check_num2dbl(elem1) && rm_check_num2dbl(elem2)) { args[x++] = NUM2DBL(elem1); args[x++] = NUM2DBL(elem2); } else { xfree((void *) args); rb_raise(rb_eTypeError, "type mismatch: %s and %s given", rb_class2name(CLASS_OF(elem1)), rb_class2name(CLASS_OF(elem2))); } Color_to_MagickPixel(NULL, &pp, argv[n++]); if (channels & RedChannel) { args[x++] = pp.red / QuantumRange; } if (channels & GreenChannel) { args[x++] = pp.green / QuantumRange; } if (channels & BlueChannel) { args[x++] = pp.blue / QuantumRange; } if (channels & IndexChannel) { args[x++] = pp.index / QuantumRange; } if (channels & OpacityChannel) { #if defined(IMAGEMAGICK_7) args[x++] = pp.alpha / QuantumRange; #else args[x++] = pp.opacity / QuantumRange; #endif } } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); new_image = SparseColorImage(image, method, nargs, args, exception); CHANGE_RESULT_CHANNEL_MASK(new_image); END_CHANNEL_MASK(image); #else new_image = SparseColorImage(image, channels, method, nargs, args, exception); #endif xfree((void *) args); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#splice(x, y, width, height, color = self.background_color) ⇒ Magick::Image
Splice a solid color into the part of the image specified by the x, y, width, and height arguments. If the color argument is specified it must be a color name or Pixel.
13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 |
# File 'ext/RMagick/rmimage.c', line 13092 VALUE Image_splice(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; PixelColor color, old_color; RectangleInfo rectangle; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 4: // use background color color = image->background_color; break; case 5: // Convert color argument to PixelColor Color_to_PixelColor(&color, argv[4]); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 4 or 5)", argc); break; } rectangle.x = NUM2LONG(argv[0]); rectangle.y = NUM2LONG(argv[1]); rectangle.width = NUM2ULONG(argv[2]); rectangle.height = NUM2ULONG(argv[3]); exception = AcquireExceptionInfo(); // Swap in color for the duration of this call. old_color = image->background_color; image->background_color = color; new_image = SpliceImage(image, &rectangle, exception); image->background_color = old_color; rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#spread(radius = 3.0) ⇒ Magick::Image
Randomly displace each pixel in a block defined by “radius”.
13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 |
# File 'ext/RMagick/rmimage.c', line 13144 VALUE Image_spread(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double radius = 3.0; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 1: radius = NUM2DBL(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc); break; } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) new_image = SpreadImage(image, image->interpolate, radius, exception); #else new_image = SpreadImage(image, radius, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#start_loop ⇒ Boolean
Get the Boolean value that indicates the first image in an animation.
13181 13182 13183 13184 13185 |
# File 'ext/RMagick/rmimage.c', line 13181 VALUE Image_start_loop(VALUE self) { IMPLEMENT_ATTR_READER(Image, start_loop, boolean); } |
#start_loop=(val) ⇒ Boolean
Set the Boolean value that indicates the first image in an animation.
13193 13194 13195 13196 13197 |
# File 'ext/RMagick/rmimage.c', line 13193 VALUE Image_start_loop_eq(VALUE self, VALUE val) { IMPLEMENT_ATTR_WRITER(Image, start_loop, boolean); } |
#stegano(watermark_image, offset) ⇒ Magick::Image
Hides a digital watermark in the receiver. You can retrieve the watermark by reading the file with the stegano: prefix, thereby proving the authenticity of the file.
The watermarked image must be saved in a lossless RGB format such as MIFF, or PNG. You cannot save a watermarked image in a lossy format such as JPEG or a pseudocolor format such as GIF. Once written, the file must not be modified or processed in any way.
13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 |
# File 'ext/RMagick/rmimage.c', line 13212 VALUE Image_stegano(VALUE self, VALUE watermark_image, VALUE offset) { Image *image, *new_image; VALUE wm_image; Image *watermark; ExceptionInfo *exception; image = rm_check_destroyed(self); wm_image = rm_cur_image(watermark_image); watermark = rm_check_destroyed(wm_image); image->offset = NUM2LONG(offset); exception = AcquireExceptionInfo(); new_image = SteganoImage(image, watermark, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); RB_GC_GUARD(wm_image); return rm_image_new(new_image); } |
#stereo(offset_image_arg) ⇒ Magick::Image
Combine two images and produces a single image that is the composite of a left and right image of a stereo pair. Special red-green stereo glasses are required to view this effect.
13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 |
# File 'ext/RMagick/rmimage.c', line 13246 VALUE Image_stereo(VALUE self, VALUE offset_image_arg) { Image *image, *new_image; VALUE offset_image; Image *offset; ExceptionInfo *exception; image = rm_check_destroyed(self); offset_image = rm_cur_image(offset_image_arg); offset = rm_check_destroyed(offset_image); exception = AcquireExceptionInfo(); new_image = StereoImage(image, offset, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); RB_GC_GUARD(offset_image); return rm_image_new(new_image); } |
#store_pixels(x_arg, y_arg, cols_arg, rows_arg, new_pixels) ⇒ Magick::Image
Replace the pixels in the specified rectangle with the pixels in the pixels array.
-
This is the complement of get_pixels. The array object returned by get_pixels is suitable for use as the “new_pixels” argument.
13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 |
# File 'ext/RMagick/rmimage.c', line 13362 VALUE Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg, VALUE rows_arg, VALUE new_pixels) { Image *image; Pixel *pixel; VALUE new_pixel; long n, size; long x, y; unsigned long cols, rows; unsigned int okay; ExceptionInfo *exception; #if defined(IMAGEMAGICK_7) Quantum *pixels; #else PixelPacket *pixels; #endif image = rm_check_destroyed(self); x = NUM2LONG(x_arg); y = NUM2LONG(y_arg); cols = NUM2ULONG(cols_arg); rows = NUM2ULONG(rows_arg); if (x < 0 || y < 0 || x+cols > image->columns || y+rows > image->rows) { rb_raise(rb_eRangeError, "geometry (%lux%lu%+ld%+ld) exceeds image bounds", cols, rows, x, y); } size = (long)(cols * rows); new_pixels = rb_Array(new_pixels); rm_check_ary_len(new_pixels, size); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); okay = SetImageStorageClass(image, DirectClass, exception); CHECK_EXCEPTION(); if (!okay) { DestroyExceptionInfo(exception); rb_raise(Class_ImageMagickError, "SetImageStorageClass failed. Can't store pixels."); } #else okay = SetImageStorageClass(image, DirectClass); rm_check_image_exception(image, RetainOnError); if (!okay) { rb_raise(Class_ImageMagickError, "SetImageStorageClass failed. Can't store pixels."); } exception = AcquireExceptionInfo(); #endif // Get a pointer to the pixels. Replace the values with the PixelPackets // from the pixels argument. { pixels = GetAuthenticPixels(image, x, y, cols, rows, exception); CHECK_EXCEPTION(); if (pixels) { #if defined(IMAGEMAGICK_6) IndexPacket *indexes = GetAuthenticIndexQueue(image); #endif for (n = 0; n < size; n++) { new_pixel = rb_ary_entry(new_pixels, n); if (CLASS_OF(new_pixel) != Class_Pixel) { DestroyExceptionInfo(exception); rb_raise(rb_eTypeError, "Item in array should be a Pixel."); } Data_Get_Struct(new_pixel, Pixel, pixel); #if defined(IMAGEMAGICK_7) SetPixelRed(image, pixel->red, pixels); SetPixelGreen(image, pixel->green, pixels); SetPixelBlue(image, pixel->blue, pixels); SetPixelAlpha(image, pixel->alpha, pixels); SetPixelBlack(image, pixel->black, pixels); pixels += GetPixelChannels(image); #else SetPixelRed(pixels, pixel->red); SetPixelGreen(pixels, pixel->green); SetPixelBlue(pixels, pixel->blue); SetPixelOpacity(pixels, pixel->opacity); if (indexes) { SetPixelIndex(indexes + n, pixel->black); } pixels++; #endif } SyncAuthenticPixels(image, exception); CHECK_EXCEPTION(); } DestroyExceptionInfo(exception); } RB_GC_GUARD(new_pixel); return self; } |
#strip! ⇒ Magick::Image
Strips an image of all profiles and comments.
13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 |
# File 'ext/RMagick/rmimage.c', line 13472 VALUE Image_strip_bang(VALUE self) { #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif Image *image = rm_check_frozen(self); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); StripImage(image, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else StripImage(image); rm_check_image_exception(image, RetainOnError); #endif return self; } |
#swirl(degrees_obj) ⇒ Magick::Image
Swirl the pixels about the center of the image, where degrees indicates the sweep of the arc through which each pixel is moved. You get a more dramatic effect as the degrees move from 1 to 360.
13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 |
# File 'ext/RMagick/rmimage.c', line 13502 VALUE Image_swirl(VALUE self, VALUE degrees_obj) { Image *image, *new_image; ExceptionInfo *exception; double degrees = NUM2DBL(degrees_obj); image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) new_image = SwirlImage(image, degrees, image->interpolate, exception); #else new_image = SwirlImage(image, degrees, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#texture_fill_to_border(x, y, texture) ⇒ Object
Replace neighboring pixels to border color with texture pixels
1057 1058 1059 |
# File 'lib/rmagick_internal.rb', line 1057 def texture_fill_to_border(x, y, texture) texture_flood_fill(border_color, texture, x, y, FillToBorderMethod) end |
#texture_flood_fill(color_obj, texture_obj, x_obj, y_obj, method_obj) ⇒ Magick::Image
Emulates Magick++‘s floodFillTexture.
If the FloodfillMethod method is specified, flood-fills texture across pixels starting at the target pixel and matching the specified color.
If the FillToBorderMethod method is specified, flood-fills ‘texture across pixels starting at the target pixel and stopping at pixels matching the specified color.’
13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 |
# File 'ext/RMagick/rmimage.c', line 13541 VALUE Image_texture_flood_fill(VALUE self, VALUE color_obj, VALUE texture_obj, VALUE x_obj, VALUE y_obj, VALUE method_obj) { Image *image, *new_image; Image *texture_image; PixelColor color; VALUE texture; DrawInfo *draw_info; long x, y; PaintMethod method; MagickPixel color_mpp; MagickBooleanType invert; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); Color_to_PixelColor(&color, color_obj); texture = rm_cur_image(texture_obj); texture_image = rm_check_destroyed(texture); x = NUM2LONG(x_obj); y = NUM2LONG(y_obj); if ((unsigned long)x > image->columns || (unsigned long)y > image->rows) { rb_raise(rb_eArgError, "target out of range. %ldx%ld given, image is %"RMIuSIZE"x%"RMIuSIZE"", x, y, image->columns, image->rows); } VALUE_TO_ENUM(method_obj, method, PaintMethod); if (method != FillToBorderMethod && method != FloodfillMethod) { rb_raise(rb_eArgError, "paint method must be FloodfillMethod or " "FillToBorderMethod (%d given)", (int)method); } draw_info = CloneDrawInfo(NULL, NULL); if (!draw_info) { rb_raise(rb_eNoMemError, "not enough memory to continue"); } draw_info->fill_pattern = rm_clone_image(texture_image); new_image = rm_clone_image(image); rm_init_magickpixel(new_image, &color_mpp); if (method == FillToBorderMethod) { invert = MagickTrue; color_mpp.red = (MagickRealType) image->border_color.red; color_mpp.green = (MagickRealType) image->border_color.green; color_mpp.blue = (MagickRealType) image->border_color.blue; } else { invert = MagickFalse; color_mpp.red = (MagickRealType) color.red; color_mpp.green = (MagickRealType) color.green; color_mpp.blue = (MagickRealType) color.blue; } #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); FloodfillPaintImage(new_image, draw_info, &color_mpp, x, y, invert, exception); DestroyDrawInfo(draw_info); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else FloodfillPaintImage(new_image, DefaultChannels, draw_info, &color_mpp, x, y, invert); DestroyDrawInfo(draw_info); rm_check_image_exception(new_image, DestroyOnError); #endif RB_GC_GUARD(texture); return rm_image_new(new_image); } |
#texture_floodfill(x, y, texture) ⇒ Object
Replace matching neighboring pixels with texture pixels
1051 1052 1053 1054 |
# File 'lib/rmagick_internal.rb', line 1051 def texture_floodfill(x, y, texture) target = pixel_color(x, y) texture_flood_fill(target, texture, x, y, FloodfillMethod) end |
#threshold(threshold_obj) ⇒ Magick::Image
Change the value of individual pixels based on the intensity of each pixel compared to threshold. The result is a high-contrast, two color image.
13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 |
# File 'ext/RMagick/rmimage.c', line 13632 VALUE Image_threshold(VALUE self, VALUE threshold_obj) { Image *image, *new_image; double threshold = NUM2DBL(threshold_obj); #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); BilevelImage(new_image, threshold, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else BilevelImageChannel(new_image, DefaultChannels, threshold); rm_check_image_exception(new_image, DestroyOnError); #endif return rm_image_new(new_image); } |
#thumbnail(scale) ⇒ Magick::Image #thumbnail(cols, rows) ⇒ Magick::Image
The thumbnail method is a fast resizing method suitable for use when the size of the resulting image is < 10% of the original.
13819 13820 13821 13822 13823 13824 |
# File 'ext/RMagick/rmimage.c', line 13819 VALUE Image_thumbnail(int argc, VALUE *argv, VALUE self) { rm_check_destroyed(self); return thumbnail(False, argc, argv, self); } |
#thumbnail!(scale) ⇒ Magick::Image #thumbnail!(cols, rows) ⇒ Magick::Image
The thumbnail method is a fast resizing method suitable for use when the size of the resulting image is < 10% of the original. In-place form of #thumbnail.
13841 13842 13843 13844 13845 13846 |
# File 'ext/RMagick/rmimage.c', line 13841 VALUE Image_thumbnail_bang(int argc, VALUE *argv, VALUE self) { rm_check_frozen(self); return thumbnail(True, argc, argv, self); } |
#ticks_per_second ⇒ Numeric
Get the number of ticks per second. This attribute is used in conjunction with the delay attribute to establish the amount of time that must elapse between frames in an animation.The default is 100.
13856 13857 13858 13859 13860 13861 |
# File 'ext/RMagick/rmimage.c', line 13856 VALUE Image_ticks_per_second(VALUE self) { Image *image = rm_check_destroyed(self); return INT2FIX(image->ticks_per_second); } |
#ticks_per_second=(tps) ⇒ Numeric
Set the number of ticks per second. This attribute is used in conjunction with the delay attribute to establish the amount of time that must elapse between frames in an animation.The default is 100.
13872 13873 13874 13875 13876 13877 13878 |
# File 'ext/RMagick/rmimage.c', line 13872 VALUE Image_ticks_per_second_eq(VALUE self, VALUE tps) { Image *image = rm_check_frozen(self); image->ticks_per_second = NUM2ULONG(tps); return tps; } |
#tint(tint, red_alpha, green_alpha = red_alpha, blue_alpha = red_alpha, alpha_alpha = 1.0) ⇒ Object
Applies a color vector to each pixel in the image.
-
Alpha values are percentages: 0.10 -> 10%.
13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 |
# File 'ext/RMagick/rmimage.c', line 13894 VALUE Image_tint(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; PixelColor tint; double red_pct_opaque, green_pct_opaque, blue_pct_opaque; double alpha_pct_opaque = 1.0; char alpha[50]; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 2: red_pct_opaque = NUM2DBL(argv[1]); green_pct_opaque = blue_pct_opaque = red_pct_opaque; break; case 3: red_pct_opaque = NUM2DBL(argv[1]); green_pct_opaque = NUM2DBL(argv[2]); blue_pct_opaque = red_pct_opaque; break; case 4: red_pct_opaque = NUM2DBL(argv[1]); green_pct_opaque = NUM2DBL(argv[2]); blue_pct_opaque = NUM2DBL(argv[3]); break; case 5: red_pct_opaque = NUM2DBL(argv[1]); green_pct_opaque = NUM2DBL(argv[2]); blue_pct_opaque = NUM2DBL(argv[3]); alpha_pct_opaque = NUM2DBL(argv[4]); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 to 5)", argc); break; } if (red_pct_opaque < 0.0 || green_pct_opaque < 0.0 || blue_pct_opaque < 0.0 || alpha_pct_opaque < 0.0) { rb_raise(rb_eArgError, "alpha percentages must be non-negative."); } snprintf(alpha, sizeof(alpha), "%g,%g,%g,%g", red_pct_opaque*100.0, green_pct_opaque*100.0, blue_pct_opaque*100.0, alpha_pct_opaque*100.0); Color_to_PixelColor(&tint, argv[0]); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) new_image = TintImage(image, alpha, &tint, exception); #else new_image = TintImage(image, alpha, tint, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#to_blob ⇒ String
Return a “blob” (a String) from the image.
-
The magick member of the Image structure determines the format of the returned blob (GIG, JPEG, PNG, etc.)
13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 |
# File 'ext/RMagick/rmimage.c', line 13967 VALUE Image_to_blob(VALUE self) { Image *image; Info *info; const MagickInfo *magick_info; VALUE info_obj; VALUE blob_str; void *blob = NULL; size_t length = 2048; // Do what Magick++ does ExceptionInfo *exception; // The user can specify the depth (8 or 16, if the format supports // both) and the image format by setting the depth and format // values in the info parm block. info_obj = rm_info_new(); Data_Get_Struct(info_obj, Info, info); image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); // Copy the depth and magick fields to the Image if (info->depth != 0) { #if defined(IMAGEMAGICK_7) SetImageDepth(image, info->depth, exception); CHECK_EXCEPTION(); #else SetImageDepth(image, info->depth); rm_check_image_exception(image, RetainOnError); #endif } if (*info->magick) { SetImageInfo(info, MagickTrue, exception); CHECK_EXCEPTION(); if (*info->magick == '\0') { return Qnil; } strlcpy(image->magick, info->magick, sizeof(image->magick)); } // Fix #2844 - libjpeg exits when image is 0x0 magick_info = GetMagickInfo(image->magick, exception); CHECK_EXCEPTION(); if (magick_info) { if ( (!rm_strcasecmp(magick_info->name, "JPEG") || !rm_strcasecmp(magick_info->name, "JPG")) && (image->rows == 0 || image->columns == 0)) { rb_raise(rb_eRuntimeError, "Can't convert %"RMIuSIZE"x%"RMIuSIZE" %.4s image to a blob", image->columns, image->rows, magick_info->name); } } (image, info); blob = ImageToBlob(info, image, &length, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); if (length == 0 || !blob) { return Qnil; } blob_str = rb_str_new(blob, length); magick_free((void*)blob); RB_GC_GUARD(info_obj); RB_GC_GUARD(blob_str); return blob_str; } |
#to_color(pixel_arg) ⇒ String
Return a color name for the color intensity specified by the Magick::Pixel argument.
14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 |
# File 'ext/RMagick/rmimage.c', line 14057 VALUE Image_to_color(VALUE self, VALUE pixel_arg) { Image *image; PixelColor pixel; ExceptionInfo *exception; char name[MaxTextExtent]; image = rm_check_destroyed(self); Color_to_PixelColor(&pixel, pixel_arg); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) pixel.depth = MAGICKCORE_QUANTUM_DEPTH; pixel.colorspace = image->colorspace; #endif // QueryColorname returns False if the color represented by the PixelPacket // doesn't have a "real" name, just a sequence of hex digits. We don't care // about that. QueryColorname(image, &pixel, AllCompliance, name, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); return rb_str_new2(name); } |
#total_colors ⇒ Numeric
Alias for #number_colors.
14094 14095 14096 14097 14098 |
# File 'ext/RMagick/rmimage.c', line 14094 VALUE Image_total_colors(VALUE self) { return Image_number_colors(self); } |
#total_ink_density ⇒ Float
Return the total ink density for a CMYK image.
14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 |
# File 'ext/RMagick/rmimage.c', line 14106 VALUE Image_total_ink_density(VALUE self) { Image *image; double density; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); density = GetImageTotalInkDensity(image, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else density = GetImageTotalInkDensity(image); rm_check_image_exception(image, RetainOnError); #endif return rb_float_new(density); } |
#transparent(color, alpha: Magick::TransparentAlpha) ⇒ Magick::Image
Changes the opacity value of all the pixels that match color to the value specified by opacity. By default the pixel must match exactly, but you can specify a tolerance level by setting the fuzz attribute on the image.
-
Default alpha is Magick::TransparentAlpha.
-
Can use Magick::OpaqueAlpha or Magick::TransparentAlpha, or any value >= 0 && <= QuantumRange.
-
Use Image#fuzz= to define the tolerance level.
14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 |
# File 'ext/RMagick/rmimage.c', line 14146 VALUE Image_transparent(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; MagickPixel color; Quantum alpha = TransparentAlpha; MagickBooleanType okay; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); switch (argc) { case 2: alpha = get_named_alpha_value(argv[1]); case 1: Color_to_MagickPixel(image, &color, argv[0]); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc); break; } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); okay = TransparentPaintImage(new_image, &color, alpha, MagickFalse, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else okay = TransparentPaintImage(new_image, &color, QuantumRange - alpha, MagickFalse); rm_check_image_exception(new_image, DestroyOnError); #endif if (!okay) { // Force exception DestroyImage(new_image); rm_magick_error("TransparentPaintImage failed with no explanation"); } return rm_image_new(new_image); } |
#transparent_chroma(low, high, invert, alpha: Magick::TransparentAlpha) ⇒ Magick::Image
Changes the opacity value associated with any pixel between low and high to the value defined by opacity.
As there is one fuzz value for the all the channels, the transparent method is not suitable for the operations like chroma, where the tolerance for similarity of two color components (RGB) can be different, Thus we define this method take two target pixels (one low and one high) and all the pixels of an image which are lying between these two pixels are made transparent.
14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 |
# File 'ext/RMagick/rmimage.c', line 14210 VALUE Image_transparent_chroma(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; Quantum alpha = TransparentAlpha; MagickPixel low, high; MagickBooleanType invert = MagickFalse; MagickBooleanType okay; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); switch (argc) { case 4: if (TYPE(argv[argc - 1]) == T_HASH) { invert = RTEST(argv[3]); } else { invert = RTEST(argv[2]); } case 3: alpha = get_named_alpha_value(argv[argc - 1]); case 2: Color_to_MagickPixel(image, &high, argv[1]); Color_to_MagickPixel(image, &low, argv[0]); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 2, 3 or 4)", argc); break; } new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); okay = TransparentPaintImageChroma(new_image, &low, &high, alpha, invert, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else okay = TransparentPaintImageChroma(new_image, &low, &high, QuantumRange - alpha, invert); rm_check_image_exception(new_image, DestroyOnError); #endif if (!okay) { // Force exception DestroyImage(new_image); rm_magick_error("TransparentPaintImageChroma failed with no explanation"); } return rm_image_new(new_image); } |
#transparent_color ⇒ String
Return the name of the transparent color as a String.
14273 14274 14275 14276 14277 14278 |
# File 'ext/RMagick/rmimage.c', line 14273 VALUE Image_transparent_color(VALUE self) { Image *image = rm_check_destroyed(self); return rm_pixelcolor_to_color_name(image, &image->transparent_color); } |
#transparent_color=(color) ⇒ Magick::Pixel, String
Set the the transparent color to the specified color spec.
14287 14288 14289 14290 14291 14292 14293 |
# File 'ext/RMagick/rmimage.c', line 14287 VALUE Image_transparent_color_eq(VALUE self, VALUE color) { Image *image = rm_check_frozen(self); Color_to_PixelColor(&image->transparent_color, color); return color; } |
#transpose ⇒ Magick::Image
Creates a horizontal mirror image by reflecting the pixels around the central y-axis while rotating them by 90 degrees.
14303 14304 14305 14306 14307 14308 |
# File 'ext/RMagick/rmimage.c', line 14303 VALUE Image_transpose(VALUE self) { rm_check_destroyed(self); return crisscross(False, self, TransposeImage); } |
#transpose! ⇒ Magick::Image
Creates a horizontal mirror image by reflecting the pixels around the central y-axis while rotating them by 90 degrees. In-place form of #transpose.
14319 14320 14321 14322 14323 14324 |
# File 'ext/RMagick/rmimage.c', line 14319 VALUE Image_transpose_bang(VALUE self) { rm_check_frozen(self); return crisscross(True, self, TransposeImage); } |
#transverse ⇒ Magick::Image
Creates a vertical mirror image by reflecting the pixels around the central x-axis while rotating them by 270 degrees
14334 14335 14336 14337 14338 14339 |
# File 'ext/RMagick/rmimage.c', line 14334 VALUE Image_transverse(VALUE self) { rm_check_destroyed(self); return crisscross(False, self, TransverseImage); } |
#transverse! ⇒ Magick::Image
Creates a vertical mirror image by reflecting the pixels around the central x-axis while rotating them by 270 degrees In-place form of #transverse.
14349 14350 14351 14352 14353 14354 |
# File 'ext/RMagick/rmimage.c', line 14349 VALUE Image_transverse_bang(VALUE self) { rm_check_frozen(self); return crisscross(True, self, TransverseImage); } |
#trim(reset = false) ⇒ Magick::Image
Removes the edges that are exactly the same color as the corner pixels. Use the fuzz attribute to make trim remove edges that are nearly the same color as the corner pixels.
14428 14429 14430 14431 14432 14433 |
# File 'ext/RMagick/rmimage.c', line 14428 VALUE Image_trim(int argc, VALUE *argv, VALUE self) { rm_check_destroyed(self); return trimmer(False, argc, argv, self); } |
#trim!(reset = false) ⇒ Magick::Image
Removes the edges that are exactly the same color as the corner pixels. Use the fuzz attribute to make trim remove edges that are nearly the same color as the corner pixels.
14448 14449 14450 14451 14452 14453 |
# File 'ext/RMagick/rmimage.c', line 14448 VALUE Image_trim_bang(int argc, VALUE *argv, VALUE self) { rm_check_frozen(self); return trimmer(True, argc, argv, self); } |
#undefine(artifact) ⇒ Magick::Image
Removes an artifact from the image and returns its value.
14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 |
# File 'ext/RMagick/rmimage.c', line 14547 VALUE Image_undefine(VALUE self, VALUE artifact) { Image *image; char *key; image = rm_check_frozen(self); key = StringValueCStr(artifact); DeleteImageArtifact(image, key); return self; } |
#unique_colors ⇒ Magick::Image
Constructs a new image with one pixel for each unique color in the image. The new image has 1 row. The row has 1 column for each unique pixel in the image.
14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 |
# File 'ext/RMagick/rmimage.c', line 14566 VALUE Image_unique_colors(VALUE self) { Image *image, *new_image; ExceptionInfo *exception; image = rm_check_destroyed(self); exception = AcquireExceptionInfo(); new_image = UniqueImageColors(image, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#units ⇒ Magick::ResolutionType
Get the units of image resolution.
14588 14589 14590 14591 14592 14593 |
# File 'ext/RMagick/rmimage.c', line 14588 VALUE Image_units(VALUE self) { Image *image = rm_check_destroyed(self); return ResolutionType_find(image->units); } |
#units=(restype) ⇒ Magick::ResolutionType
Set the units of image resolution.
14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 |
# File 'ext/RMagick/rmimage.c', line 14602 VALUE Image_units_eq(VALUE self, VALUE restype) { ResolutionType units; Image *image = rm_check_frozen(self); VALUE_TO_ENUM(restype, units, ResolutionType); if (image->units != units) { switch (image->units) { case PixelsPerInchResolution: if (units == PixelsPerCentimeterResolution) { #if defined(IMAGEMAGICK_7) image->resolution.x /= 2.54; image->resolution.y /= 2.54; #else image->x_resolution /= 2.54; image->y_resolution /= 2.54; #endif } break; case PixelsPerCentimeterResolution: if (units == PixelsPerInchResolution) { #if defined(IMAGEMAGICK_7) image->resolution.x *= 2.54; image->resolution.y *= 2.54; #else image->x_resolution *= 2.54; image->y_resolution *= 2.54; #endif } break; default: // UndefinedResolution #if defined(IMAGEMAGICK_7) image->resolution.x = 0.0; image->resolution.y = 0.0; #else image->x_resolution = 0.0; image->y_resolution = 0.0; #endif break; } image->units = units; } return restype; } |
#unsharp_mask(radius = 0.0, sigma = 1.0, amount = 1.0, threshold = 0.05) ⇒ Magick::Image
Sharpen an image. “amount” is the percentage of the difference between the original and the blur image that is added back into the original. “threshold” is the threshold in pixels needed to apply the diffence amount.
14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 |
# File 'ext/RMagick/rmimage.c', line 14729 VALUE Image_unsharp_mask(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double radius = 0.0, sigma = 1.0, amount = 1.0, threshold = 0.05; ExceptionInfo *exception; image = rm_check_destroyed(self); unsharp_mask_args(argc, argv, &radius, &sigma, &amount, &threshold); exception = AcquireExceptionInfo(); new_image = UnsharpMaskImage(image, radius, sigma, amount, threshold, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#unsharp_mask(radius = 0.0, sigma = 1.0, amount = 1.0, threshold = 0.05, channel = Magick::AllChannels) ⇒ Magick::Image #unsharp_mask(radius = 0.0, sigma = 1.0, amount = 1.0, threshold = 0.05, *channels) ⇒ Magick::Image
Sharpen an image. “amount” is the percentage of the difference between the original and the blur image that is added back into the original. “threshold” is the threshold in pixels needed to apply the diffence amount.
Only the specified channels are sharpened.
14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 |
# File 'ext/RMagick/rmimage.c', line 14776 VALUE Image_unsharp_mask_channel(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; ChannelType channels; double radius = 0.0, sigma = 1.0, amount = 1.0, threshold = 0.05; ExceptionInfo *exception; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); if (argc > 4) { raise_ChannelType_error(argv[argc-1]); } unsharp_mask_args(argc, argv, &radius, &sigma, &amount, &threshold); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); new_image = UnsharpMaskImage(image, radius, sigma, amount, threshold, exception); CHANGE_RESULT_CHANNEL_MASK(new_image); END_CHANNEL_MASK(image); #else new_image = UnsharpMaskImageChannel(image, channels, radius, sigma, amount, threshold, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#view(x, y, width, height) ⇒ Object
Construct a view. If a block is present, yield and pass the view object, otherwise return the view object.
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 |
# File 'lib/rmagick_internal.rb', line 1063 def view(x, y, width, height) view = View.new(self, x, y, width, height) return view unless block_given? begin yield(view) ensure view.sync end nil end |
#vignette(horz_radius = self.columns*0.1+0.5, vert_radius = self.rows*0.1+0.5, radius = 0.0, sigma = 1.0) ⇒ Magick::Image
Soften the edges of an image.
14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 |
# File 'ext/RMagick/rmimage.c', line 14819 VALUE Image_vignette(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; long horz_radius, vert_radius; double radius = 0.0, sigma = 10.0; ExceptionInfo *exception; image = rm_check_destroyed(self); horz_radius = (long)(image->columns * 0.10 + 0.5); vert_radius = (long)(image->rows * 0.10 + 0.5); switch (argc) { case 4: sigma = NUM2DBL(argv[3]); case 3: radius = NUM2DBL(argv[2]); case 2: vert_radius = NUM2INT(argv[1]); case 1: horz_radius = NUM2INT(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 4)", argc); break; } exception = AcquireExceptionInfo(); new_image = VignetteImage(image, radius, sigma, horz_radius, vert_radius, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#virtual_pixel_method ⇒ Magick::VirtualPixelMethod
Get the “virtual pixels” behave. Virtual pixels are pixels that are outside the boundaries of the image.
14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 |
# File 'ext/RMagick/rmimage.c', line 14865 VALUE Image_virtual_pixel_method(VALUE self) { Image *image; VirtualPixelMethod vpm; image = rm_check_destroyed(self); vpm = GetImageVirtualPixelMethod(image); return VirtualPixelMethod_find(vpm); } |
#virtual_pixel_method=(method) ⇒ Magick::VirtualPixelMethod
Specify how “virtual pixels” behave. Virtual pixels are pixels that are outside the boundaries of the image.
14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 |
# File 'ext/RMagick/rmimage.c', line 14884 VALUE Image_virtual_pixel_method_eq(VALUE self, VALUE method) { Image *image; VirtualPixelMethod vpm; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_frozen(self); VALUE_TO_ENUM(method, vpm, VirtualPixelMethod); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); SetImageVirtualPixelMethod(image, vpm, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else SetImageVirtualPixelMethod(image, vpm); rm_check_image_exception(image, RetainOnError); #endif return method; } |
#watermark(mark, brightness = 1.0, saturation = 1.0, x_off = 0, y_off = 0) ⇒ Magick::Image #watermark(mark, brightness, saturation, gravity, x_off = 0, y_off = 0) ⇒ Magick::Image
Composites a watermark image on the target image using the Modulate composite operator. This composite operation operates in the HSL colorspace and combines part of the lightness, part of the saturation, and all of the hue of each pixel in the watermark with the corresponding pixel in the target image
14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 |
# File 'ext/RMagick/rmimage.c', line 14948 VALUE Image_watermark(int argc, VALUE *argv, VALUE self) { Image *image, *, *new_image; double src_percent = 100.0, dst_percent = 100.0; long x_offset = 0L, y_offset = 0L; char geometry[20]; VALUE ovly; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); if (argc < 1) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 to 6)", argc); } ovly = rm_cur_image(argv[0]); = rm_check_destroyed(ovly); if (argc > 3) { get_composite_offsets(argc-3, &argv[3], image, , &x_offset, &y_offset); // There must be 3 arguments left argc = 3; } switch (argc) { case 3: dst_percent = rm_percentage(argv[2], 1.0) * 100.0; case 2: src_percent = rm_percentage(argv[1], 1.0) * 100.0; case 1: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 to 6)", argc); break; } blend_geometry(geometry, sizeof(geometry), src_percent, dst_percent); CloneString(&->geometry, geometry); SetImageArtifact(, "compose:args", geometry); new_image = rm_clone_image(image); #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); CompositeImage(new_image, , ModulateCompositeOp, MagickTrue, x_offset, y_offset, exception); rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); #else CompositeImage(new_image, ModulateCompositeOp, , x_offset, y_offset); rm_check_image_exception(new_image, DestroyOnError); #endif RB_GC_GUARD(ovly); return rm_image_new(new_image); } |
#wave(amplitude = 25.0, wavelength = 150.0) ⇒ Magick::Image
Create a “ripple” effect in the image by shifting the pixels vertically along a sine wave whose amplitude and wavelength is specified by the given parameters.
15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 |
# File 'ext/RMagick/rmimage.c', line 15021 VALUE Image_wave(int argc, VALUE *argv, VALUE self) { Image *image, *new_image; double amplitude = 25.0, wavelength = 150.0; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 2: wavelength = NUM2DBL(argv[1]); case 1: amplitude = NUM2DBL(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc); break; } exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) new_image = WaveImage(image, amplitude, wavelength, image->interpolate, exception); #else new_image = WaveImage(image, amplitude, wavelength, exception); #endif rm_check_exception(exception, new_image, DestroyOnError); DestroyExceptionInfo(exception); return rm_image_new(new_image); } |
#wet_floor(initial = 0.5, rate = 1.0) ⇒ Magick::Image
Creates a “wet floor” reflection. The reflection is an inverted copy of the image that changes from partially transparent to entirely transparent. By default only the bottom third of the image appears in the reflection.
15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 |
# File 'ext/RMagick/rmimage.c', line 15074 VALUE Image_wet_floor(int argc, VALUE *argv, VALUE self) { Image *image, *reflection, *flip_image; #if defined(IMAGEMAGICK_7) const Quantum *p; Quantum *q; #else const PixelPacket *p; PixelPacket *q; #endif RectangleInfo geometry; long x, y, max_rows; double initial = 0.5; double rate = 1.0; double opacity, step; const char *func; ExceptionInfo *exception; image = rm_check_destroyed(self); switch (argc) { case 2: rate = NUM2DBL(argv[1]); case 1: initial = NUM2DBL(argv[0]); case 0: break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc); break; } if (initial < 0.0 || initial > 1.0) { rb_raise(rb_eArgError, "Initial transparency must be in the range 0.0-1.0 (%g)", initial); } if (rate < 0.0) { rb_raise(rb_eArgError, "Transparency change rate must be >= 0.0 (%g)", rate); } #if defined(IMAGEMAGICK_7) initial *= QuantumRange; #else initial *= TransparentOpacity; #endif // The number of rows in which to transition from the initial level of // transparency to complete transparency. rate == 0.0 -> no change. if (rate > 0.0) { max_rows = (long)((double)image->rows) / (3.0 * rate); max_rows = (long)min((unsigned long)max_rows, image->rows); #if defined(IMAGEMAGICK_7) step = (QuantumRange - initial) / max_rows; #else step = (TransparentOpacity - initial) / max_rows; #endif } else { max_rows = (long)image->rows; step = 0.0; } exception = AcquireExceptionInfo(); flip_image = FlipImage(image, exception); CHECK_EXCEPTION(); geometry.x = 0; geometry.y = 0; geometry.width = image->columns; geometry.height = max_rows; reflection = CropImage(flip_image, &geometry, exception); DestroyImage(flip_image); CHECK_EXCEPTION(); #if defined(IMAGEMAGICK_7) SetImageStorageClass(reflection, DirectClass, exception); rm_check_exception(exception, reflection, DestroyOnError); SetImageAlphaChannel(reflection, ActivateAlphaChannel, exception); rm_check_exception(exception, reflection, DestroyOnError); #else SetImageStorageClass(reflection, DirectClass); rm_check_image_exception(reflection, DestroyOnError); reflection->matte = MagickTrue; #endif opacity = initial; for (y = 0; y < max_rows; y++) { #if defined(IMAGEMAGICK_7) if (opacity > QuantumRange) { opacity = QuantumRange; } #else if (opacity > TransparentOpacity) { opacity = TransparentOpacity; } #endif p = GetVirtualPixels(reflection, 0, y, image->columns, 1, exception); rm_check_exception(exception, reflection, DestroyOnError); if (!p) { func = "AcquireImagePixels"; goto error; } q = QueueAuthenticPixels(reflection, 0, y, image->columns, 1, exception); rm_check_exception(exception, reflection, DestroyOnError); if (!q) { func = "SetImagePixels"; goto error; } for (x = 0; x < (long) image->columns; x++) { // Never make a pixel *less* transparent than it already is. #if defined(IMAGEMAGICK_7) *q = *p; SetPixelAlpha(reflection, min(GetPixelAlpha(image, q), QuantumRange - (Quantum)opacity), q); p += GetPixelChannels(reflection); q += GetPixelChannels(reflection); #else q[x] = p[x]; q[x].opacity = max(q[x].opacity, (Quantum)opacity); #endif } SyncAuthenticPixels(reflection, exception); rm_check_exception(exception, reflection, DestroyOnError); opacity += step; } DestroyExceptionInfo(exception); return rm_image_new(reflection); error: DestroyExceptionInfo(exception); DestroyImage(reflection); rb_raise(rb_eRuntimeError, "%s failed on row %lu", func, y); return(VALUE)0; } |
#white_threshold(red, green, blue, alpha: alpha) ⇒ Magick::Image
Forces all pixels above the threshold into white while leaving all pixels below the threshold unchanged.
15247 15248 15249 15250 15251 |
# File 'ext/RMagick/rmimage.c', line 15247 VALUE Image_white_threshold(int argc, VALUE *argv, VALUE self) { return threshold_image(argc, argv, self, WhiteThresholdImage); } |
#write(file) ⇒ Magick::Image
Write the image to the file.
15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 |
# File 'ext/RMagick/rmimage.c', line 15350 VALUE Image_write(VALUE self, VALUE file) { Image *image; Info *info; VALUE info_obj; #if defined(IMAGEMAGICK_7) ExceptionInfo *exception; #endif image = rm_check_destroyed(self); info_obj = rm_info_new(); Data_Get_Struct(info_obj, Info, info); if (TYPE(file) == T_FILE) { rb_io_t *fptr; // Ensure file is open - raise error if not GetOpenFile(file, fptr); rb_io_check_writable(fptr); #if defined(_WIN32) add_format_prefix(info, fptr->pathv); strlcpy(image->filename, info->filename, sizeof(image->filename)); SetImageInfoFile(info, NULL); #else SetImageInfoFile(info, rb_io_stdio_file(fptr)); memset(image->filename, 0, sizeof(image->filename)); #endif } else { add_format_prefix(info, file); strlcpy(image->filename, info->filename, sizeof(image->filename)); SetImageInfoFile(info, NULL); } (image, info); info->adjoin = MagickFalse; #if defined(IMAGEMAGICK_7) exception = AcquireExceptionInfo(); WriteImage(info, image, exception); CHECK_EXCEPTION(); DestroyExceptionInfo(exception); #else WriteImage(info, image); rm_check_image_exception(image, RetainOnError); #endif RB_GC_GUARD(info_obj); return self; } |
#x_resolution ⇒ Float
Get the horizontal resolution of the image.
15458 15459 15460 15461 15462 |
# File 'ext/RMagick/rmimage.c', line 15458 VALUE Image_x_resolution(VALUE self) { IMPLEMENT_ATTR_READER(Image, x_resolution, dbl); } |
#x_resolution=(val) ⇒ Float
Set the horizontal resolution of the image.
15470 15471 15472 15473 15474 |
# File 'ext/RMagick/rmimage.c', line 15470 VALUE Image_x_resolution_eq(VALUE self, VALUE val) { IMPLEMENT_ATTR_WRITER(Image, x_resolution, dbl); } |
#y_resolution ⇒ Float
Get the vertical resolution of the image.
15481 15482 15483 15484 15485 |
# File 'ext/RMagick/rmimage.c', line 15481 VALUE Image_y_resolution(VALUE self) { IMPLEMENT_ATTR_READER(Image, y_resolution, dbl); } |
#y_resolution=(val) ⇒ Float
Set the vertical resolution of the image.
15493 15494 15495 15496 15497 |
# File 'ext/RMagick/rmimage.c', line 15493 VALUE Image_y_resolution_eq(VALUE self, VALUE val) { IMPLEMENT_ATTR_WRITER(Image, y_resolution, dbl); } |