Gregwar / Image

A PHP library to handle images
MIT License
1k stars 191 forks source link

Obtain result of "imagettftext" of method write of Adapter (GD, ...) #153

Open developez opened 6 years ago

developez commented 6 years ago

I need to obtain the result of imagettftext that is called on write method of GD class.

To do this I put a variable on GD called "last_write" to get the last result of this operation. The thing is that I modify the code on GD.php file but the changes dont seem to happen. Do I need to update composer or similar thing?

class GD extends Common
{
    public $last_write;

...

    public function write($font, $text, $x = 0, $y = 0, $size = 12, $angle = 0, $color = 0x000000, $align = 'left')
    {       
        imagealphablending($this->resource, true);

        if ($align != 'left') {
            $sim_size = self::TTFBox($font, $text, $size, $angle);

            if ($align == 'center') {
                $x -= $sim_size['width'] / 2;
            }

            if ($align == 'right') {
                $x -= $sim_size['width'];
            }
        }       
        $this->last_write = imagettftext($this->resource, $size, $angle, $x, $y, ImageColor::gdAllocate($this->resource, $color), $font, $text);                        

        return $this;
    }