From: Tim Hunter Date: 2008-04-01T07:20:32+09:00 Subject: Re: metrics rmagick problem Eduard Bondarenko wrote: > Thanks Tim, > > But centerGravity don't works as expects. > I've added > d.gravity = Magick::CenterGravity > > and changed > d.text(0,0, text) > > but the text isn't in the image center. > annotate give the same result. > Sorry this is so much trouble. Try this. For me, this exactly centers the word "RMagick" on the image. I'm using ImageMagick 6.4.0 and RMagick 2.3.0, but I would expect this to work with any relatively recent version of ImageMagick and RMagick. If it doesn't work for you, please open a support request on the RMagick project on RubyForge, let me know what versions of ImageMagick and RMagick you're using, include a simple reproduction of your problem and attach the output image you get. require 'RMagick' img = Magick::Image.new(500, 500) gc = Magick::Draw.new gc.stroke "red" gc.fill "white" gc.circle 249.5, 249.5, 249.5, 255 gc.line 0, 0, 499, 499 gc.line 0, 499, 499, 0 gc.draw img translucent_blue = Magick::Pixel.from_color "blue" translucent_blue.opacity = Magick::QuantumRange * 0.50 translucent_blue = translucent_blue.to_color(Magick::AllCompliance, true) gc = Magick::Draw.new gc.gravity Magick::CenterGravity gc.text_undercolor translucent_blue gc.pointsize 48 gc.fill "rgba(100%, 100%, 100%, 0.50)" gc.text 0, 0, "RMagick" gc.draw img img.matte = false img.display -- RMagick: http://rmagick.rubyforge.org/ RMagick 2: http://rmagick.rubyforge.org/rmagick2.html