Foo
Foo

Reputation: 810

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

Upvotes: 5

Views: 180

Answers (1)

Jeff Steil
Jeff Steil

Reputation: 1770

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"' }

Upvotes: 2

Related Questions