Taken from the rubyonrails wiki, for my reference:

If you need RMagick support for your web app, your going to need to install ImageMagick and RMagick.

sudo apt-get install imagemagickdpkg -l | grep magick

This will install the most current imagemagick and then

list the ‘magick’ packages installed. Look for what version of
libmagick got installed and make sure you specify THAT version number when you install libmagick-dev.

sudo apt-get install libmagick9-devsudo gem install rmagick

After a lengthy build process, you’re ready to edit images in ruby!