note 129572 added to imagickdraw.annotation

From: Date: Mon, 10 Jun 2024 08:11:20 +0000
Subject: note 129572 added to imagickdraw.annotation
Groups: php.notes 
Request: Send a blank email to php-notes+get-221370@lists.php.net to get a copy of this message
[As mentioned in another comment] To correctly position text in the vertical plane when using annotation(), you can use the value of the "ascender" element returned by Imagick::queryFontMetrics(). So, to effectively make your text touch [0, 0], for example, you could do something like the following. <?php $textDraw = new ImagickDraw(); $textDraw->setFont($fontPathname); $textDraw->setFontSize($fontSize); $textDraw->setFillColor(new ImagickPixel($color)); $imagick= new Imagick(); $textMetrics = $imagick->queryFontMetrics($textDraw, 'Hello, World!'); $textDraw->annotation( 0, $textMetrics['ascender'], // <-- This is the important bit :-) 'Hello, World!' ); ?> Hope that helps clarify. The other comment was a blessing for me. ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 2a01:4b00:8377:6900:1d8:6ad6:bf74:501d) ---- Manual Page -- https://php.net/manual/en/imagickdraw.annotation.php Edit -- https://main.php.net/note/edit/129572 Del: integrated -- https://main.php.net/note/delete/129572/integrated Del: useless -- https://main.php.net/note/delete/129572/useless Del: bad code -- https://main.php.net/note/delete/129572/bad+code Del: spam -- https://main.php.net/note/delete/129572/spam Del: non-english -- https://main.php.net/note/delete/129572/non-english Del: in docs -- https://main.php.net/note/delete/129572/in+docs Del: other reasons-- https://main.php.net/note/delete/129572 Reject -- https://main.php.net/note/reject/129572 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221370) next »