Search code examples
rubyrmagick

RMagick posterize and other does not work


I guy's i have write this code:

require 'RMagick'
include Magick

img = Image.read("small_img.gif").first
img.posterize
img.display
exit

the result of image don't change i've tested blur_image, oil_paint, other but don't work only rotate! work form me, maybe have writed too bad the code? p.s. sorry for my bad english


Solution

  • This line

    img.posterize
    

    returns a new image object, it does not alter the image in place. So if you do the following

    new_img = img.posterize
    new_img.display
    

    you should see results of your test.

    The same applies to a lot of rmagic transformations.