How to resize and image watermarks in Ruby / Rails?

I am looking for gems that will allow me to resize and upload watermarks.

I see a lot of posts on ImageScience and Mini-Magick, but nothing new. I am looking for any experience to help me make a decision.

+2


source to share


3 answers


I would recommend using Paperclip to load images.

With Paperclip, you define how you want the images to be processed after loading.

Automatic resizing is done by setting values ​​in your load model

 class User < ActiveRecord::Base
    has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
 end

      



Here is a good example of creating Post Processors and another one to add using ImageMagick .

It should be noted that you already have the app (with the images loaded) live, you can run the Paperclip commands over it again with the command:

rake paperclip:refresh ModelName RAILS_ENV=production

      

+7


source


I am currently using RMagick for several products and it works great for me. However, people are constantly complaining about memory usage . However, the documentation can be a little confusing.



A new project I've heard about is MagickWand for Ruby . But I have no experience with that.

+3


source


I just recommend a gem that I wrote myself:

Github page: https://github.com/wrymax/image_clipper

It's a very simple use of this for resizing and watermarking. Also it works well with Paperclip in ROR.

Just add:

gem install image_clipper

      

And install ImageMagick as base image library:

brew install imagemagick

      

Sample code:

image.resize('200x100', save_new_file_path)

image.resize('35%')

image.watermarking(watermark_image_path)

      

Hope it helps.

0


source







All Articles