Class: Magick::Image

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/RMagick.rb,
ext/RMagick/rmmain.c

Overview

Ruby-level Magick::Image methods

Defined Under Namespace

Classes: Info, View

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeObject

Class Method Details

._loadObject

.captureObject

.constituteObject

.from_blobObject

.newObject

.pingObject

.readObject

.read_inlineObject

Instance Method Details

#<=>Object

#[]Object

#[]=Object

#_dumpObject

#adaptive_thresholdObject

#add_noiseObject

#affine_transformObject

#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.



599
600
601
602
# File 'lib/RMagick.rb', line 599

def annotate(draw, width, height, x, y, text, &block)
  draw.annotate(self, width, height, x, y, text, &block)
  self
end

#bilevel_channelObject

#black_thresholdObject

#blur_channelObject

#blur_imageObject

#borderObject

#border!Object

#change_geometryObject

#change_geometry!Object

#changed?Boolean

Returns:

  • (Boolean)

#channelObject

#channel_compareObject

An alias for compare_channel

#channel_depthObject

#channel_extremaObject

#channel_meanObject

#channel_thresholdObject

#charcoalObject

#chopObject

#cloneObject

#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



620
621
622
# File 'lib/RMagick.rb', line 620

def color_fill_to_border(x, y, fill)
    color_flood_fill(border_color, fill, x, y, Magick::FillToBorderMethod)
end

#color_flood_fillObject

#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



613
614
615
616
# File 'lib/RMagick.rb', line 613

def color_floodfill(x, y, fill)
    target = pixel_color(x, y)
    color_flood_fill(target, fill, x, y, Magick::FloodfillMethod)
end

#color_histogramObject

#color_point(x, y, fill) ⇒ Object

Set the color at x,y



605
606
607
608
609
# File 'lib/RMagick.rb', line 605

def color_point(x, y, fill)
    f = copy
    f.pixel_color(x, y, fill)
    return f
end

#color_reset!(fill) ⇒ Object

Set all pixels to the fill color. Very similar to Image#erase! Accepts either String or Pixel arguments



626
627
628
629
630
631
632
633
634
635
636
637
638
# File 'lib/RMagick.rb', line 626

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

#colorizeObject

#colormapObject

#compare_channelObject

#compositeObject

#composite!Object

#composite_affineObject

#compress_colormap!Object

#contrastObject

#convolveObject

#convolve_channelObject

#copyObject

#cropObject

#crop!Object

#cur_imageObject

Used by ImageList methods - see ImageList#cur_image



641
642
643
# File 'lib/RMagick.rb', line 641

def cur_image
    self
end

#cycle_colormapObject

#despeckleObject

#differenceObject

#dispatchObject

#displayObject Also known as: __display__

#distortion_channelObject

#dupObject

#each_profileObject

#edgeObject

#embossObject

#enhanceObject

#equalizeObject

#erase!Object

#export_pixelsObject

#flipObject

#flip!Object

#flopObject

#flop!Object

#frameObject

#gamma_channelObject

#gamma_correctObject

#gaussian_blurObject

#gaussian_blur_channelObject

#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.



707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
# File 'lib/RMagick.rb', line 707

def get_exif_by_entry(*entry)
    ary = Array.new
    if entry.length == 0
        exif_data = self['EXIF:*']
        if exif_data
            exif_data.split("\n").each { |exif| ary.push(exif.split('=')) }
        end
    else
        entry.each do |name|
            rval = self["EXIF:#{name}"]
            ary.push([name, rval])
        end
    end
    return 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.



724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
# File 'lib/RMagick.rb', line 724

def get_exif_by_number(*tag)
    hash = Hash.new
    if tag.length == 0
        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
        tag.each do |num|
            rval = self["EXIF:#{'#%04X' % num}"]
            hash[num] = rval == 'unknown' ? nil : rval
        end
    end
    return hash
end

#get_pixelsObject

#gray?Boolean

Returns:

  • (Boolean)

#grayscale_pseudo_classObject

#grey?Boolean

Returns:

  • (Boolean)

#implodeObject

#import_pixelsObject

#initialize_copyObject

#inspectObject

#levelObject

#level_channelObject

#magnifyObject

#magnify!Object

#mapObject

#matte_fill_to_border(x, y) ⇒ Object

Make transparent any neighbor pixel that is not the border color.



679
680
681
682
683
684
# File 'lib/RMagick.rb', line 679

def matte_fill_to_border(x, y)
    f = copy
    f.opacity = Magick::OpaqueOpacity unless f.matte
    f.matte_flood_fill(border_color, TransparentOpacity,
                       x, y, FillToBorderMethod)
end

#matte_flood_fillObject

#matte_floodfill(x, y) ⇒ Object

Make transparent any pixel that matches the color of the pixel at (x,y) and is a neighbor.



670
671
672
673
674
675
676
# File 'lib/RMagick.rb', line 670

def matte_floodfill(x, y)
    f = copy
    f.opacity = OpaqueOpacity unless f.matte
    target = f.pixel_color(x, y)
    f.matte_flood_fill(target, TransparentOpacity,
                       x, y, FloodfillMethod)
end

#matte_point(x, y) ⇒ Object

Make the pixel at (x,y) transparent.



650
651
652
653
654
655
656
657
# File 'lib/RMagick.rb', line 650

def matte_point(x, y)
    f = copy
    f.opacity = OpaqueOpacity unless f.matte
    pixel = f.pixel_color(x,y)
    pixel.opacity = TransparentOpacity
    f.pixel_color(x, y, pixel)
    return f
end

#matte_replace(x, y) ⇒ Object

Make transparent all pixels that are the same color as the pixel at (x, y).



661
662
663
664
665
666
# File 'lib/RMagick.rb', line 661

def matte_replace(x, y)
    f = copy
    f.opacity = OpaqueOpacity unless f.matte
    target = f.pixel_color(x, y)
    f.transparent(target)
end

#matte_reset!Object

Make all pixels transparent.



687
688
689
690
# File 'lib/RMagick.rb', line 687

def matte_reset!
    self.opacity = Magick::TransparentOpacity
    self
end

#median_filterObject

#minifyObject

#minify!Object

#modulateObject

#monochrome?Boolean

Returns:

  • (Boolean)

#motion_blurObject

#negateObject

#negate_channelObject

#normalizeObject

#normalize_channelObject

#oil_paintObject

#opaqueObject

#opaque?Boolean

Returns:

  • (Boolean)

#ordered_ditherObject

#palette?Boolean

Returns:

  • (Boolean)

#pixel_colorObject

#posterizeObject

#previewObject

rb_define_method(Class_Image, “plasma”, Image_plasma, 6);

#profile!Object

#propertiesObject

#quantizeObject

#quantum_operatorObject

#radial_blurObject

#raiseObject

#random_channel_thresholdObject

#random_threshold_channelObject

#reduce_noiseObject

#resizeObject

#resize!Object

#rollObject

#rotateObject

#rotate!Object

#sampleObject

#sample!Object

#scaleObject

#scale!Object

#segmentObject

#sepiatoneObject

#set_channel_depthObject

#shadeObject

#shadowObject

#sharpenObject

#sharpen_channelObject

#shaveObject

#shave!Object

#shearObject

#sigmoidal_contrast_channelObject

#signatureObject

#solarizeObject

#spliceObject

#spreadObject

#statisticsObject

#steganoObject

#stereoObject

#store_pixelsObject

#strip!Object

#swirlObject

#texture_fill_to_border(x, y, texture) ⇒ Object

Replace neighboring pixels to border color with texture pixels



699
700
701
# File 'lib/RMagick.rb', line 699

def texture_fill_to_border(x, y, texture)
    texture_flood_fill(border_color, texture, x, y, FillToBorderMethod)
end

#texture_flood_fillObject

#texture_floodfill(x, y, texture) ⇒ Object

Replace matching neighboring pixels with texture pixels



693
694
695
696
# File 'lib/RMagick.rb', line 693

def texture_floodfill(x, y, texture)
    target = pixel_color(x, y)
    texture_flood_fill(target, texture, x, y, FloodfillMethod)
end

#thresholdObject

#thumbnailObject

#thumbnail!Object

#tintObject

#to_blobObject

#to_colorObject

#transparentObject

#trimObject

#trim!Object

#unsharp_maskObject

#unsharp_mask_channelObject

#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.



746
747
748
749
750
751
752
753
754
755
756
757
758
759
# File 'lib/RMagick.rb', line 746

def view(x, y, width, height)
    view = View.new(self, x, y, width, height)

    if block_given?
        begin
            yield(view)
        ensure
            view.sync
        end
        return nil
    else
        return view
    end
end

#waveObject

#white_thresholdObject

#writeObject