D
D
Dmitry2018-05-14 13:58:07
PHP
Dmitry, 2018-05-14 13:58:07

How to overlay text with CSS style on an image in PHP?

Tell me who knows, if I have a design layout with a background and text layers that need to be styled with a CSS style and dynamically overlay different text in this style on the background, and make different pictures in this way, how best to do it on the side PHP?
I'm interested in an implementation example, for example, of the same risovach.ru/mem-generators - is that how it's done? There is a picture, there is text. They overlay this text on the server and give out a picture. I basically need the same, only text with CSS style. It is clear that if you make the font in the desired style, then the usual GD will do. They probably do just that. But what I need is CSS support so that I can easily make changes and not have to redraw the font.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Talalaev, 2018-05-14
@Itachi261092

No, it's not done that way.
Working with images in php through a special library GD / ImageMagick .
But in order not to mess around with the bike building yourself, it's better to use ready-made wrappers.
I recommend image.intervention.io , they have great documentation, a lot of options for image manipulation, filters, crops, effects and so on and so forth. Including working with text, font support.
If you really want css / html templates, then there is a library https://github.com/niklasvh/html2canvas, but here you should already separate logic and display. We have successfully used this library to implement the generation of banners automatically to the desired size using adaptive layout. The library itself is not ideal, in practice jambs and problems pop up, but I think it will be more than suitable for your task.

A
Alexander Aksentiev, 2018-05-14
@Sanasol

everything that can be done with css is done with css.
If you just have blocks with a background, and not memes, then this is done in html / css.
Text is text on the page, not on the picture.
Those. it is necessary to typeset the layout, and not cut and paste with pictures ( sushiwhite.ru/sets/)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question