0

I'm trying to build a rails app that generates an image by overlaying a text over a default image.

I'm almost there - by using carrierwave + mini magick i have this method working :

    def generate_image
            message = self.description.upcase
            image = MiniMagick::Image.open('public/base.jpg')
            image.combine_options do |c|
                c.size '400x500'
                c.gravity 'NorthWest'
                c.fill 'black'
                c.strokewidth '2'
                c.pointsize '48'
                c.interline_spacing '-9'
                c.font "#{Rails.root}/public/black.ttf"
                c.draw "text 40,40 '#{message}'"
                c.antialias
            end
            self.image = image
end

the problem is that i want my text to fit the size i've specified - but I had no luck !

reading the Image Magick documentation I know that I should use the "capition" method instead of draw - but when I do so it throws out an orrible error :) :

failed with error: mogrify: no encode delegate for this image format `CAPTION' @ 
  error/constitute.c/WriteImage/1167.

any clues ?

thanks !

Casper
  • 33,403
  • 4
  • 84
  • 79
  • 1
    Possible duplicate of [ImageMagick no decode delegate](http://stackoverflow.com/questions/9586048/imagemagick-no-decode-delegate) – Brad Werth Nov 16 '15 at 18:53
  • Also possible explanation: http://stackoverflow.com/questions/13724057/no-encode-delegate-for-this-image-format-error-constitute-c-writeimage-1153 – Casper Nov 16 '15 at 19:03
  • What's the code for the `image.write(...)` call? How are you naming the output file? – Casper Nov 16 '15 at 19:03
  • Thank you Casper - i don't need the image.write part as i let carrierwave handle the upload of the image. the function generate_image is called :before_validation on the model. the problem happends when I sub c.draw with c.caption - that is the call i need to do – Frenciccio Nov 16 '15 at 20:31

0 Answers0