Image Watermark MiniMagick & Rails 5.2
Image Watermark MiniMagick & Rails 5.2
I am trying to watermark the product images from a model. I have set static images for testing but I am getting an error and I don't understand why.
Can anyone assist in why I am getting this error:
undefined method `composite' for "CIAO12.png":String
Current Setup:
Rails 5.2
gem 'mini_magick', '~> 4.8' (Included in the Gemfile)
Brew install imagemagick (Successful)
Code is testing on static images but will be change to the product image instead of the 'CIA012.png' image.
Show Action
<div class="card-body">
<h5 class="card-title"><%= @product.product_name %></h5>
<% if @product.image.attached? %>
<%= image_tag(@product.watermark) %>
<% end %>
</div>
Product Model
def watermark
first_image = "CIAO12.png"
second_image = "watermark.png"
result = first_image.composite(second_image) do |c|
c.compose "Over" # OverCompositeOp
c.geometry "+20+20" # copy second_image onto first_image from (20, 20)
end
result.write "output.jpg"
end
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.