-
Notifications
You must be signed in to change notification settings - Fork 212
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
Add GD Image backend #114
Add GD Image backend #114
Conversation
e8be99e
to
e41b372
Compare
Well, I can understand not supporting gradients through this backend, as that would require pixel-level control, which is extremely slow to do in PHP. Though general paths shouldn't be an issue: A very primitive approach could use |
Codecov Report
@@ Coverage Diff @@
## master #114 +/- ##
============================================
+ Coverage 63.42% 66.83% +3.41%
- Complexity 928 988 +60
============================================
Files 47 48 +1
Lines 2783 2946 +163
============================================
+ Hits 1765 1969 +204
+ Misses 1018 977 -41
Help us with your feedback. Take ten seconds to tell us how you rate us. |
I was trying to do that, but I don't know how to solve subtraction. Because there is There is an outer path and inside is an inner path. And the inner one subtracts from the outer one. Look at this SVG <svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
<path fill="#7e7e7e" fill-rule="evenodd" d="M131 55 L245 55 L245 154 L114 159 Z
M169 79 L206 78 L206 121 L158 122 L169 79 Z"></path>
</svg> Result will look like this So I'm not sure how I would be able to use If you know how to handle this with |
Maybe this might be of help (README states that he never finished the code for the path, but might be good guidance): https://github.com/stefanak-michal/SvgRenderer/blob/master/Shapes.php#L318-L419 Maybe there are other libraries out there as well, who knows :) |
Here's another library which seems to be actually maintained: https://github.com/meyfa/php-svg/tree/main/src/Rasterization/Path |
PHP-SVG seems interesting. Will take a look at it, how and if it works. |
So I did some checks and it seems promising. However, latest release is So when they will release new version, I can rewrite that to use PHP-SVG library. |
An alternative would be to not use the ImageRenderer with all its features at all for GDLib, but implement a GDLibRenderer which doesn't have any styling support at all. |
I see that PHP-SVG released new version couple of hours ago. I will check that. But what you are suggesting might be better solution. Even I would integrate PHP-SVG, it would not support Gradients anyway. |
dce5aa4
to
650e101
Compare
I changed implementation including README. So no hacks across all files, but a completely new rendered is added. Please check it now. Thanks |
Closing in favor of #159 |
My client's web hosting provider sucks, and they don't have support for Imagick, even though they are promising it will be added.
I'm generating QR codes for payment, which is added into email body. And email client's do not have nice support for SVG. So I need old-school GD support.
However, GD has limited sets of functions. I believe, that it is OK, when that backend will have also limited sets of features.
So this is not supported:
DotsModule
,RoundnessModule
orSimpleCircleEye
And because GD does not support Paths like Imagick or SVG do, I need to generate a bit different paths, so they are not so complex.