Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add text #21

Open
yonatonreid opened this issue Dec 15, 2019 · 4 comments
Open

Cannot add text #21

yonatonreid opened this issue Dec 15, 2019 · 4 comments

Comments

@yonatonreid
Copy link

yonatonreid commented Dec 15, 2019

`require_once('vendor/autoload.php');

use Treinetic\ImageArtist\lib\Text\TextBox;
use Treinetic\ImageArtist\lib\Text\Color;
use Treinetic\ImageArtist\lib\Text\Font;

$img = new \Treinetic\ImageArtist\lib\Image("image1.jpg");
$nm = new \Treinetic\ImageArtist\lib\Image("circle.png");
$nm->resize(200,200);
$img->merge($nm,0,0);

$textBox = new TextBox(310,40);
$textBox->setColor(Color::getColor(Color::$WHITE));
$textBox->setFont(Font::getFont(Font::$NOTOSERIF_REGULAR));
$textBox->setSize(20);
$textBox->setMargin(2);
$textBox->setText("We Are Team Treinetic");
$img->setTextBox($textBox,($img->getWidth()-$textBox->getWidth())/2,$img->getHeight()* (5/7),true);

$img->dump();

Produces

PHP Fatal error: Uncaught ImagickException: unable to open image pango:We Are Team Treinetic': No such file or directory @ error/blob.c/OpenBlob/2701 in /var/www/html/genphoto/vendor/treinetic/imageartist/src/lib/Text/Write/ImagickWritingStrategy.php:56
Stack trace:
#0 /var/www/html/genphoto/vendor/treinetic/imageartist/src/lib/Text/Write/ImagickWritingStrategy.php(56): Imagick->newpseudoimage(310, 40, 'pango:We Are Te...')
#1 /var/www/html/genphoto/vendor/treinetic/imageartist/src/lib/Text/TextWriter.php(49): Treinetic\ImageArtist\lib\Text\Write\ImagickWritingStrategy->write()
#2 /var/www/html/genphoto/vendor/treinetic/imageartist/src/lib/Text/TextWriter.php(43): Treinetic\ImageArtist\lib\Text\TextWriter->getImage()
#3 /var/www/html/genphoto/vendor/treinetic/imageartist/src/lib/Image.php(167): Treinetic\ImageArtist\lib\Text\TextWriter->write(Object(Treinetic\ImageArtist\lib\Image), 145, 428.57142857143)
#4 /var/www/html/genphoto/index.php(21): Treinetic\ImageArtist\lib\Image->setTextBox(Object(Treinetic\ImageArtist\lib\Text in /var/www/html/genphoto/vendor/treinetic/imageartist/src/lib/Text/Write/ImagickWritingStrategy.php on line 56
`

@MmKargar
Copy link

same problem

@szef0
Copy link

szef0 commented Dec 29, 2020

any info? 👍

@yonatonreid
Copy link
Author

nope. switched to a different library, dont remember which one though lol sorry :(

@sirion89
Copy link

I resolved this by switching to GD. With gd i had no issue. All you have to do is change this:

$textBox = new TextBox(310,40);

to this:

$textBox = new TextBox(310,40,false);

which disable auto-detect for writer (which internally defaults to imagick as first choice)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants