Converting One Image Format to Another using Ruby

Insert the following code in your Ruby file.
 require 'rubygems'
 require 'RMagick'
img = Magick::Image.read("image.png").first
 img.write("image.jpg")                 # Writes a JPEG
 img.write("image.gif")                 # Writes a GIF
 img.write("JPG:image")                 # Writes a JPEG
 img.write("JPG:image.gif")             # Writes a JPEG

Comments

Popular posts from this blog

Inserting and Moving elements inside Ruby Array

Difference between Validations, Callbacks and Observers