The most useful & easy for use PHP library for converting any text to image. Uses GD extension.
The most useful & easy2use PHP library for converting any text into image
Version : 1.0 Beta
Requirements: PHP-GD, (*1)
Text2Image was created basically for translating any text information into an image representation.
And the point is, that there are no other libs for this task, at least there are no such easy4use libs for such tasks.
So all you need is require header file of this lib, create an instance and call "output" or "save" function, that's it! :), (*2)
There is exactly 2 modes in it, "Simple" and "Smart".
The main difference between them is that "Simple" is a lot faster than "Smart".
But, "Simple" mode not support's text-size and angle params.
Also, to use custom fonts in "Simple" mode you need to convert them into GDF.
With "Smart" mode you can use any font's you want, of course, if they are supported by GD, for example, TTF work nice.
See "List of all public methods" below for understanding how to switch between this modes., (*3)
Also, see "examples" folder for more., (*4)
<?php require "../src/magic.class.php"; // manual include, instead you can use composer $test = new Priler\Text2Image\Magic('Hello world!'); $test->output();
Example output:, (*5)
, (*6)
<?php require "../src/magic.class.php"; // manual include, instead you can use composer $test = new Priler\Text2Image\Magic( " Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. " ); // force mode into smart $test->set_mode('smart'); // load custom font // smart-mode work's exactly with .TTF, but other font's may also be supported, see PHP GD docs for more info $test->add_font('MyFont', './assets/foughtknight.ttf'); $test->font = $test->get_font('MyFont'); // also, smart mode supports text-size property and angle property (last one shown in 5th example) $test->text_size = 20; //ANGLE GOES HERE $test->angle = 3;//negative values also supported // let's change some basic stuff $test->background_color = '#eee'; // custom background color $test->text_color = '#FF5370'; // custom text color $test->padding = 100; // custom padding // this settings is same as on 4th example $test->width = 720; // custom width $test->line_height = 30; // custom line height $test->output();
, (*7)