Number, or perform an interactive capture whereby you designate You can create an image by capturing it from the XWindowĬan capture the root window, a window identified by name or ID That Ruby knows that this statement is a method call, not an Within the parameter block you must use self so The background color of a new image to red with theį = Image.new(100,100) You set the parameters by calling attribute setter methodsĭefined in the parameter object's class. Object and yields to the block in the scope of that object. Image.new accepts an optional block that can be used Like many other methods in the Image and ImageList classes, Scratch images are good for drawing on or Imagelist, and sets the scene number to point to the new image. Method calls Image.new, adds the new image to the "scratch" image to an imagelist, call ImageList#new_image. If present, the 3rd argument is a Fill object. The first argument is the number of columns in You can also create an image from scratch by calling Image.new. The simple case, new reads a single image from a The scene number to point to the last image in the imagelist. Is a multi-frame image file, new adds an image forĮach frame or layer in the file. The file contains a single image, new reads theįile, creates an image, and adds it to the imagelist. New can take any number of file name arguments. Initialize it by specifying the name of an image file as the You've already seen that you can create an imagelist and The receiver in place.) Reading, writing, and creating images (Following the Ruby convention, when a method alters the receiver For example, the resize method returns a new Instead, the method returnsĪ new image, suitably modified. Note: In most cases, an Image method does not One image to deal with, imagelists and images are pretty much So why, in the previous example, did I create catĪs an ImageList object containing just one image, instead ofĬreating an Image object? No reason, really. Notice how easy it is to covert an image from one format toĪnother? (For more details, see Image formats and filenames.) Small-Cheetah.gif file will be in the GIF format. Images, ImageMagick uses the filename extension to determine what The statement on line 7 writes the image to a file. Here's how to write the small cheetah to a file in GIF Image#display makes a picture of a (in this case, Method, which displays a single image on the X Window screen. Line 6 demonstrates the Image class's display Value is a new image, half the size of the original. Minify is an Image method, the ImageList class sends Size of an image to half its original size. Minify method is an Image method that reduces the Sends the minify method to the imagelist. The difference is the statement on line 5. Going back to the example, let's make one modification. The ImageList class is a subclass of the Array class, so youĬan use most Array methods to change the images in the imagelist.įor example, you can use the << method to add Image, that is, the image specified by the scene number. Imagelist, the ImageList class sends the method to the current Operate on a single image, when an Image method is sent to an Also, with a very few exceptions, any method defined in the The ImageListĬlass includes methods that operate on all the images in the Scene number indicates the current image. ItĬontains zero or more images and a scene number. It to another format, or otherwise modify it using one of overĪn ImageList object is a list of images. You can write an image to disk,ĭisplay it on a screen, change its size or orientation, convert With multiple layers are examples of images with multipleįrames.) You can create a image object from an image file such asĪ GIF, PNG, or JPEG. Image object describes one image or one frame in an The Image and ImageList classes are closely related. Subdirectory where you installed the RMagick documentation. Type this program in and try running it now. In this case, theĭisplay method makes a picture of a cheetah appear Imagelist, it causes all the images in the imagelist to beĭisplayed on the default X Window screen. The statement on line 5 creates an imagelist objectĪnd initializes it by reading the Cheetah.jpg file The Draw class is explained in the Drawing on and adding text to images section, This section -īasic Concepts - describes the ImageList and ImageĬlasses. The Magick module contains 3 major classes, Line 1 requires 2 the RMagick.rb file, which defines the Program reads an image file named "Cheetah.jpg" and Let's look at the RMagick equivalent of "Hello, world".
0 Comments
Leave a Reply. |