Getting image data from a CarrierWave uploader into RMagick

May 10, 2012 Mark Rushakoff

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.

About the Author

Biography

More Content by Mark Rushakoff
Previous
Xtreme Labs On Building Apps with Cascades at BlackBerry 10 Jam
Xtreme Labs On Building Apps with Cascades at BlackBerry 10 Jam

We were down in Orlando discussing building apps with BlackBerry Cascades with Christopher Smith, VP Handh...

Next
The Globe News for Android Users, By Android Users
The Globe News for Android Users, By Android Users

As one of Canada’s national newspapers, the Globe and Mail is Canada’s authoritative source for news, comme...

Enter curious. Exit smarter.

Register Now