Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set up my model with ImageMagick in this case?

I'd like to insert arguement as text onto the image file that user uploads.
With the code below, It doesn't work. It just saves image without any effect.
I'm using the gem called 'papaerclip' for uploading.

comment.rb

#paperclip
has_attached_file :comment_icon,
    :styles => {
    :thumb=> "100x100>",
    :small  => "400x400>" }, 
    :convert_options => {
    :all => " -stroke '#000C' -strokewidth 2 -annotate 0 'Faerie Dragon' -stroke  none   -fill white    -annotate 0 'Faerie Dragon'" }

How can I insert text to the bottom of images like this example?
How comment.rb should be written?

ImageMagick code

  convert dragon.gif -gravity south \
          -stroke '#000C' -strokewidth 2 -annotate 0 'Faerie Dragon' \
          -stroke  none   -fill white    -annotate 0 'Faerie Dragon' \
          anno_outline.jpg
like image 522
Foo Avatar asked Nov 03 '22 07:11

Foo


1 Answers

It doesn't like the single quotes you have in your convert_options. Try using:

' -gravity south -stroke "#000C" -strokewidth 2 -annotate 0 "Faerie Dragon" -stroke none -fill white -annotate 0 "Faerie Dragon"'

instead. I am using Paperclip 3.2.0 and was able to get it to apply the text by changing the quotes.

Here is my image attribute:

has_attached_file :avatar,
:styles => {:large => "300x300", :medium => "140x140>", :thumb => "100x100>", :tiny => "50x50" },
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/amazons3.yml",
:path => "avatars/:id/:style_:filename",
:convert_options => {
:all => ' -gravity south -stroke "#000C" -strokewidth 2 -annotate 0 "Faerie Dragon" -stroke none -fill white -annotate 0 "Faerie Dragon"' }
like image 76
Jeff Steil Avatar answered Nov 14 '22 02:11

Jeff Steil