PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > metrics rmagick problem
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
metrics rmagick problem

Réponse
 
LinkBack Outils de la discussion
Vieux 31/03/2008, 17h00   #1
Eduard Bondarenko
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut metrics rmagick problem

I get a strange rmagick result.

I need to add a centered text to image.
Draw#inspect tell me that all is good, but on result image text isn't
centered.

See http://pastie.caboo.se/173196
for code and link to result image.

Thanks for any in advance.
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 31/03/2008, 17h29   #2
Tim Hunter
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: metrics rmagick problem

Eduard Bondarenko wrote:
> I get a strange rmagick result.
>
> I need to add a centered text to image.
> Draw#inspect tell me that all is good, but on result image text isn't
> centered.
>
> See http://pastie.caboo.se/173196
> for code and link to result image.
>
> Thanks for any in advance.


You're working too hard :-) Use gravity(Magick::CenterGravity), like the
example for composite_layers:
http://studio.imagemagick.org/RMagic...mposite_layers.

--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 31/03/2008, 17h55   #3
Eduard Bondarenko
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: metrics rmagick problem

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.

Best regards,
Eduard

Tim Hunter wrote:
> Eduard Bondarenko wrote:
>> I get a strange rmagick result.
>>
>> I need to add a centered text to image.
>> Draw#inspect tell me that all is good, but on result image text isn't
>> centered.
>>
>> See http://pastie.caboo.se/173196
>> for code and link to result image.
>>
>> Thanks for any in advance.

>
> You're working too hard :-) Use gravity(Magick::CenterGravity), like the
> example for composite_layers:
> http://studio.imagemagick.org/RMagic...mposite_layers.


--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 31/03/2008, 23h20   #4
Tim Hunter
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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:raw.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:raw.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

  Réponse avec citation
Vieux 01/04/2008, 09h35   #5
Eduard Bondarenko
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: metrics rmagick problem

ImageMagick 6.4.0 03/28/08 Q16
rmagick (2.3.0)
Rails 2.0.2

I guess I found a problem.
When I change Image.read to Image.new
with the same dimensions text written at the
desired location.

SOLUTION (possible):
image.page was not right.
public/print_images/bc5085fc45bb5697aec6e181e33ebe78.png PNG 535x535
768x768+177+79 DirectClass 16-bit 68kb
width=768, height=768, x=177, y=79
width=535, height=535, x=0, y=0

I assign image.page to new Rectangle.
Is there any better solution?

Thanks a lot Tim!

Tim Hunter wrote:
> Eduard Bondarenko wrote:
>> 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:raw.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:raw.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


--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 01/04/2008, 12h22   #6
Tim Hunter
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: metrics rmagick problem

Eduard Bondarenko wrote:
> ImageMagick 6.4.0 03/28/08 Q16
> rmagick (2.3.0)
> Rails 2.0.2
>
> I guess I found a problem.
> When I change Image.read to Image.new
> with the same dimensions text written at the
> desired location.
>
> SOLUTION (possible):
> image.page was not right.
> public/print_images/bc5085fc45bb5697aec6e181e33ebe78.png PNG 535x535
> 768x768+177+79 DirectClass 16-bit 68kb
> width=768, height=768, x=177, y=79
> width=535, height=535, x=0, y=0
>
> I assign image.page to new Rectangle.
> Is there any better solution?
>


That's the best solution.

--
RMagick: http://rmagick.rubyforge.org/
RMagick 2: http://rmagick.rubyforge.org/rmagick2.html

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h16.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14872 seconds with 14 queries