0

I am using Attachment_fu to upload images.

I need to convert .tiff images into .jpeg format after uploading image in application.

I used below code:

 :styles => {
    :thumb => ["150x172#",:jpg],
    :large => ["100%", :jpg]
  },

But it is not useful for me.

Please help me how to convert image format?

Dipali Nagrale
  • 510
  • 5
  • 17

1 Answers1

0

As already implied in your tags ImageMagic will do the trick. You can either use the convert command line utility or use its ruby binding RMagic. In the latter case you just have to read the image and write it again with the new name. The above documentation says:

require 'RMagick'
include Magick

cat = ImageList.new("Cheetah.jpg")
smallcat = cat.minify
smallcat.display
smallcat.write("Small-Cheetah.gif")

You can also read and write from a string if you do not want the file on disk.

michas
  • 25,361
  • 15
  • 76
  • 121