0

Due to the performance advantages of Minimagick of Rmagick (and the fact the Rmagik is on the way out) I would like to be able to able to perform the following operation in Minimagick. By default it seems that Minimagick does not handle unicode character well, but Rmagick has no roblem at all (this code works fine):

def getimage
      bg = Magick::ImageList.new("#{Rails.root}/app/assets/images/template.png")
      text = Magick::Draw.new
      text.encoding = "Unicode"
      text.text(23,14,"ÿüñCe#43535r(*&^%$#ð")
      text.draw(bg)
   send_data(bg.to_blob, :type => 'image/png', :disposition => 'inline')
end
Jackson Henley
  • 1,531
  • 2
  • 15
  • 27
  • Hmm? You quote *'performance advantages of Rmagick over Minimagick'* and yet you want to perform your stuff in Minimagick?! Which way is it? – Kurt Pfeifle Aug 11 '12 at 21:14
  • In addition, I am wondering why the above works by default and why c.draw 'text' (minimagick) does not... – Jackson Henley Aug 11 '12 at 21:27
  • Kurt, if you take a quick stab at why there is a difference I'll give you credit. I understand that my question leads to obscure areas. – Jackson Henley Aug 12 '12 at 21:37
  • Can you please quote both versions of code snippets you use (Minimagick and Rmagick) in your question, and also clearly state: (1) which one works and which one doesn't; (2) what exactly doesn't work... – Kurt Pfeifle Aug 13 '12 at 16:56

1 Answers1

0

I'm still struggling to understand what exactly does work for you and what doesn't, and where your actual problem is....

Nevertheless, my first stab into the fog is this. Swap the following two lines:

  text.text(23,14,"ÿüñCe#43535r(*&^%$#ð")
  text.draw(bg)

and make them read this:

  text.draw(bg)
  text.text(23,14,"ÿüñCe#43535r(*&^%$#ð")

That is: first draw the background, then draw the text. (Minimagick most likely executes the drawing statements in the stated order, because the commandline's behavior is the same -- and Minimagick is only a wrapper around the commandline...)

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345