3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MiniMagick Carrierwave 画像にウォーターマークを追加する

Posted at

Carrierwaveを使用した画像アップロードの際に、ロゴなどを右下に配置する実装

#image_uploader.rb

  process :store_watermark

  ~省略~

private

  def store_watermark
    ## ウォーターマーク用のロゴ
    wartermark_logo = MiniMagick::Image.open("#{Rails.root}/app/assets/images/common/logo.png")

    manipulate! do |img|
      img.composite(wartermark_logo) do |c|
        c.compose "Screen"  ##タイプ "Over"でもいいかな
        c.gravity "Southeast"  ##位置
        c.geometry "+15+15"  ## 右下を基準に ?px 空けるか
        c.dissolve "30%" ## 透過率
      end
    end
  end
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?