Comments (3)
Did you try https://joseluisq.github.io/gimage/examples/text-embedding/?
You can create a canvas as base image, then every text that you want to use you can append it to canvas but for each text as well you can adjust the position how to display them in canvas. Check out the Text class too https://joseluisq.github.io/gimage/classes/text/
from gimage.
In general your example is fine for your requirement.
So I'm going to close the issue for now.
from gimage.
yes, i'm using it. After a few attempts I managed to come up with a code that apparently will serve me. The goal is to pass an array of products (and their respective values) and create an image for sharing on social networks. Look at the code I got (if it's not the best option and I want to suggest changes, thank you), but I'm still starting development.
`
$figure = new Figure(400, 250);
$figure
->setBackgroundColor(47, 42, 39)
->create();
$final_text = new stdClass();
$x = 40;
$y = 20;
//simulate array
$products[] = array ('txt'=> 'texto 001');
$products[] = array ('txt'=> 'texto 004');
$products[] = array ('txt'=> 'texto 007');
$products[] = array ('txt'=> 'texto 005');
$products[] = array ('txt'=> 'texto 006');
$canvas = new Canvas($figure);
foreach ($products as $txt) {
$text = new Text($txt['txt']);
$y = $y + 30;
$text
->setWidth(400)
->setHeight(250)
->setAlign('center') // "none" by default
->setLineHeight(1.2)
->setLeft($x)
->setTop($y)
->setSize(22)
->setColor(255, 255, 255)
->setFontface(FCPATH . 'uploads/fonts/Roboto-Black.ttf');
//$final_text= (object) array_merge((array) $final_text, (array) $text);
$canvas
->append($text);
}
$canvas
->toPNG()
->draw()
->output();
//->save('text.png');
}
`
from gimage.
Related Issues (17)
- Add documentation API HOT 2
- imagerotate() expects parameter 1 to be resource, null given
- PHP Warning: imagecreatetruecolor(): Invalid image dimensions
- Website for GImage and documentation
- Examples don't work. HOT 6
- How I can remove the spacing in the text by using my font? HOT 16
- Get the image resource without saving
- Cloud uploading examples HOT 3
- New documentation v3.0
- Can the loading method directly support the loading of image content? HOT 14
- Load an image resource directly HOT 1
- Line-height support for GText HOT 3
- Calculate font size automatically to fit a given box area HOT 4
- Project opens for new maintainers HOT 8
- Add more sample codes for API
- How can I use this library in Codeigniter? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gimage.