简体   繁体   中英

How to convert .tiff images into .jpeg format

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM