Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Getting image data from a CarrierWave uploader into RMagick

Carrierwave has an RMagick module that offers a handy manipulate! method that takes a block where you can modify the image, and then it saves the changes to the image.

But sometimes you only want to interrogate the image, and there’s no need to save any changes.

After spending probably 30-45 minutes trying to figure out how to read an image that may not necessarily exist on your local disk, the simplest solution we found was to call uploader#read to get the contents of the file as a string, and then pass that into Magick::Image.from_blob.

  1. Trevor Turk says:

    Please consider adding a page to the CarrierWave wiki about this!

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *