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

feat: add GD image backend #171

Merged
merged 1 commit into from
Mar 19, 2024
Merged

Conversation

arxeiss
Copy link
Contributor

@arxeiss arxeiss commented Mar 19, 2024

Copy of closed #114


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 Renderer will have also limited sets of features.
So this is not supported:

  • Any roundness like DotsModule, RoundnessModule or SimpleCircleEye
  • Gradients

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.


Sorry for opening new PR, but I had to change branch. I really needed the GD Renderer and in many projects I'm using this in package.json. Not to break them by changing commit name, I had to create new branch. But then it is not possible to change source branch in PR.

"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/arxeiss/BaconQrCode"
        }
    ],
    "require": {
        "php": "^8.2",
        "bacon/bacon-qr-code": "dev-add-gd-backend#650e10121f4d8707ecdc5984b042cae7731e388a",

Copy link

codecov bot commented Mar 19, 2024

Codecov Report

Attention: Patch coverage is 90.83333% with 11 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (main@86deb82). Click here to learn what that means.

Files Patch % Lines
src/Renderer/GDLibRenderer.php 90.83% 11 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #171   +/-   ##
=======================================
  Coverage        ?   64.93%           
  Complexity      ?      981           
=======================================
  Files           ?       48           
  Lines           ?     3094           
  Branches        ?        0           
=======================================
  Hits            ?     2009           
  Misses          ?     1085           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

README.md Outdated
@@ -37,3 +37,21 @@ BaconQrCode comes with multiple back ends for rendering images. Currently includ
- `ImagickImageBackEnd`: renders raster images using the Imagick library
- `SvgImageBackEnd`: renders SVG files using XMLWriter
- `EpsImageBackEnd`: renders EPS files

### GDLib Renderer
GD library has so many limitations, that GD support is not added as backend, but as separated rendered.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/rendered/renderer/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

README.md Outdated

### GDLib Renderer
GD library has so many limitations, that GD support is not added as backend, but as separated rendered.
Use `GDLibRendered` instead of `ImageRenderer`. Here are limitations:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Rendered/Renderer/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and: "These are the limitations" :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


private function imageFilledPolygon(array $points, int $color): bool
{
if (\PHP_VERSION_ID >= 80000) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should not be required anymore, as we raised the minimum version to 8.1 in the next release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@arxeiss arxeiss changed the title Add GD Image backend featAdd GD Image backend Mar 19, 2024
@arxeiss arxeiss changed the title featAdd GD Image backend feat: Add GD Image backend Mar 19, 2024
@DASPRiD DASPRiD changed the title feat: Add GD Image backend feat: add GD image backend Mar 19, 2024
@DASPRiD DASPRiD merged commit c01758c into Bacon:main Mar 19, 2024
7 checks passed
@DASPRiD
Copy link
Member

DASPRiD commented Mar 19, 2024

LGTM, thanks for your work! :)

@arxeiss arxeiss deleted the add-gd-backend-php8.1 branch March 19, 2024 21:18
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

Successfully merging this pull request may close these issues.

2 participants