user3339562
user3339562

Reputation: 1385

How to place text on image

Is there a way to place text on image in Rails? I am using Carrierwave for image upload, but I don't think it supports watermarking.

I tried attaching image watermark and made it work but can't figure out how to watermark with text.

For example, this is good way to place image watermark.

Upvotes: 0

Views: 634

Answers (1)

vectorbooster
vectorbooster

Reputation: 105

This is the code that I user to put watermarks on a image I am sure that you can change it a bit to make it your own. Also make sure that you have Magick turned on.
Take a look at carrierwave-add-a-watermark-to-processed-images its similar

# Process files as they are uploaded:
process :resize_to_fill => [850, 315]
process :convert => 'png'
process :watermark

def watermark
  manipulate! do |img|
    logo = Magick::Image.read("#{Rails.root}/app/assets/images/watermark.png").first
    img = img.composite(logo, Magick::NorthWestGravity, 15, 0, Magick::OverCompositeOp)
  end
end

Upvotes: 4

Related Questions