Rmagick there is a way to convert image to memory

From the Rmagick :

Convert image to another format

Converting an image to another format is as simple as writing an image to a file.

ImageMagick uses the suffix (".jpg" for JPEG, ".gif" for GIF, for example) output file name suffix (".jpg" for JPEG, ".gif" for GIF, for example) or prefix ("ps:" for PostScript, for example) to determine the output image format.

Is there a way to convert an image to memory?

+6
source share
1 answer
 # assuming you have an image # img = Magick::Image.new( 100, 100 ) img = Magick::Image.from_blob( img.to_blob { self.format = "png" } ) 

Source: RMagick Docs

Here is an example of how to provide it to the user

 image.format = "png" send_data image.to_blob, :filename => "woohoo.png", :disposition => 'inline', :quality => 90, :type => 'image/png' 
+7
source

Source: https://habr.com/ru/post/948536/


All Articles