diff --git a/Adispatch.rb.html b/Adispatch.rb.html deleted file mode 100644 index 08cfc33..0000000 --- a/Adispatch.rb.html +++ /dev/null @@ -1,65 +0,0 @@ - - -
- - - - --#!/usr/local/bin/ruby -w -require 'RMagick' - -f = Magick::Image.read("images/Flower_Hat.jpg").first - -pixels = f.dispatch(0,0,f.columns,f.rows,"RGB") - -# Write the pixels to a file, to be loaded in the Zconstitute.rb -# example. Ruby 1.6.8 # loads the Pixels array much faster if we break -# the array into many small pieces and concatenate them together, so this -# program generates such a sequence. - -first = true -total = pixels.length - -File.open('pixels-array', 'w') { |txt| - txt.puts("Width = #{f.columns}") - txt.puts("Height = #{f.rows}") - txt.puts('Pixels = [') - x = 0 - pixels.each do |p| - txt.printf("%3d,", p) - x = x.succ - txt.printf("\n") if x % 25 == 0 - if x % 1000 == 0 - if first - txt.puts(']') - first = false - else - txt.puts('])') - end - txt.print('Pixels.concat([') - end - end - - if first - txt.puts(']') - first = false - else - txt.puts('])') - end -} -exit --
-#!/usr/local/bin/ruby -w -require 'RMagick' - -load 'pixels-array' - -image = Magick::Image.constitute(Width, Height, "RGB", Pixels) - -image.write("constitute.jpg") -exit --
-#!/home/software/ruby-1.8.2//bin/ruby -w -require 'RMagick' - -# Demonstrate the Image#channel_threshold method - -img = Magick::Image.read('images/Flower_Hat.jpg').first - -# Make the "before" image -imgs = Magick::ImageList.new -imgs << img.copy -imgs.cur_image['Label'] = "\n\n" -imgs << img.copy -imgs.cur_image['Label'] = "\n\n\n" - -montage = imgs.montage { - self.background_color = "white" - self.geometry = "#{img.columns}x#{img.rows}+10+10" - self.tile = "2x1" - } -montage.border!(1,1,"black") -montage.write("channel_threshold_before.jpg") - -# Now the "after" image. -# Channel threshold values should be a %-age of MaxRGB -# Let the opacity threshold default to MaxRGB. -img2 = img.channel_threshold(Magick::MaxRGB*0.75, - Magick::MaxRGB*0.50) -img2['Label'] = "channel_threshold(\nMagick::MaxRGB*0.75,\nMagick::MaxRGB*0.50)" - -img3 = img.channel_threshold(Magick::MaxRGB*0.50, - Magick::MaxRGB*0.25, - Magick::MaxRGB*0.25) -img3['Label'] = 'channel_threshold(\nMagick::MaxRGB*0.50,\nMagick::MaxRGB*0.25,\nMagick::MaxRGB*0.25)' - -# Montage the two sample images -imgs = Magick::ImageList.new -imgs << img2 << img3 - -montage = imgs.montage { - self.background_color = "white" - self.geometry = "#{img.columns}x#{img.rows}+10+10" - self.tile = "2x1" - } - -# Give the montage a black border -montage.border!(1,1,'black') -montage.write('channel_threshold_after.jpg') -exit --
-#!/usr/local/bin/ruby -w -require 'RMagick' - -# Demonstrate the crop_resize method - -img = Magick::Image.read('images/Flower_Hat.jpg')[0] -thumbnail = img.crop_resized(76, 76) -thumbnail.write("crop_resized.jpg") - - --
-#!/home/software/ruby-1.8.4/bin/ruby -w -require 'RMagick' - -# Demonstrate the Image#level_channel method - -before = Magick::Image.read('images/Flower_Hat.jpg').first - -# Let the final argument default -begin - red = before.level_channel(Magick::RedChannel, Magick::MaxRGB, 2) - green = before.level_channel(Magick::GreenChannel,Magick::MaxRGB, 2) - blue = before.level_channel(Magick::BlueChannel, Magick::MaxRGB, 2) - - # Composite the green image over the middle of the red image. - # Composite the blue image over the right-hand side of the red image. - green.crop!(red.columns/3, 0, red.columns/3, red.rows) - blue.crop!(red.columns/3*2+1, 0, red.columns/3+1, red.rows) - result = red.composite(green, Magick::CenterGravity, Magick::OverCompositeOp) - result = result.composite(blue, Magick::EastGravity, Magick::OverCompositeOp) - - # Draw a black line between each of the three images. - line = Magick::Draw.new - line.line(result.columns/3, 0, result.columns/3, result.rows) - line.line(result.columns/3*2+1, 0, result.columns/3*2+1, result.rows) - line.draw(result) - -# Substitute the standard "Not Implemented" image -rescue NotImplementedError - result = Magick::Image.read("images/notimplemented.gif").first -end - -result.write('level_channel.jpg') -exit --
-#!/usr/local/bin/ruby -w - -# Demonstrate the map, append, and composite methods by -# mapping the colors in three separate images into the -# 216 "Web-safe" colors. - -require 'RMagick' - -# Read three images. -unmapped = Magick::ImageList.new("images/Hot_Air_Balloons.jpg","images/Violin.jpg","images/Polynesia.jpg") - -# "Read" the Netscape 216-color cube -map = Magick::ImageList.new "netscape:" - -# Map the group of unmapped into the Netscape colors -$stdout.sync = true -printf "Mapping... Please be patient, this may take a few seconds... " -mapped = unmapped.map map, false -puts "Done." - -# Use the append method to arrange the unmapped images -# side-by-side into a single image. Repeat for the mapped images. -before = unmapped.append false -before.write 'map_before.jpg' - -after = mapped.append false -after.write 'map_after.jpg' -exit --
-#!/usr/local/bin/ruby -w -require 'RMagick' - -# Demonstrate the Image#map method - -img = Magick::Image.read('images/Flower_Hat.jpg')[0] - -# "Read" the builtin Netscape format, which -# contains the 216 colors in the Netscape palette. -nsmap = Magick::Image.read('netscape:')[0] - -# Map the original image colors into the Netscape colors. -after = img.map(nsmap) - -after.write('map_f.jpg') --
-#!/home/software/ruby-1.8.4/bin/ruby -w -require 'RMagick' -include Magick - -# Demonstrate the Image#opaque method. - -img = Image.read('images/Flower_Hat.jpg').first - -# Allow non-exact matches -img.fuzz = 25 -img = img.opaque('white', 'red') - -img.write('opaque.jpg') - --
-#!/home/software/ruby-1.8.2//bin/ruby -w - -# Demonstrate the random_channel_threshold method - -require 'RMagick' -include Magick - -img = Image.read('images/Flower_Hat.jpg').first - -begin - img2 = img.random_channel_threshold('intensity', '35%') -rescue NotImplementedError - img2 = Image.read('images/notimplemented.gif').first -end - -img2.write('random_channel_threshold.jpg') -exit --