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: GDHandler make WebP with option quality #7506

Merged
merged 7 commits into from
May 25, 2023
Merged

feat: GDHandler make WebP with option quality #7506

merged 7 commits into from
May 25, 2023

Conversation

ddevsr
Copy link
Collaborator

@ddevsr ddevsr commented May 17, 2023

Description
With condition of SEO Strategic, we need compress all image web with WebP for speed performance.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@ddevsr ddevsr added the refactor Pull requests that refactor code label May 17, 2023
@ddevsr ddevsr marked this pull request as ready for review May 17, 2023 09:55
@kenjis
Copy link
Member

kenjis commented May 17, 2023

Isn't this an enhancement?

@ddevsr
Copy link
Collaborator Author

ddevsr commented May 17, 2023

Isn't this an enhancement?

Thanks for correct

@ddevsr ddevsr changed the base branch from develop to 4.4 May 17, 2023 15:49
@ddevsr ddevsr added the enhancement PRs that improve existing functionalities label May 17, 2023
@kenjis kenjis removed the refactor Pull requests that refactor code label May 18, 2023
@kenjis kenjis changed the title refactor: GDHandler make WebP with option quality feat: GDHandler make WebP with option quality May 18, 2023
@kenjis
Copy link
Member

kenjis commented May 18, 2023

Add this enhancement in the changelog 4.4.0 to let devs know.
https://github.com/codeigniter4/CodeIgniter4/blob/4.4/user_guide_src/source/changelogs/v4.4.0.rst#libraries

@kenjis kenjis added the 4.4 label May 18, 2023
@ddevsr ddevsr requested a review from kenjis May 18, 2023 01:24
@kenjis
Copy link
Member

kenjis commented May 18, 2023

Thank you for updates. We are close to merge.

@ddevsr ddevsr requested a review from kenjis May 18, 2023 09:19
@@ -267,7 +267,7 @@ public function save(?string $target = null, int $quality = 90): bool
throw ImageException::forInvalidImageCreate(lang('Images.webpNotSupported'));
}

if (! @imagewebp($this->resource, $target)) {
if (! @imagewebp($this->resource, $target, $quality)) {
Copy link
Member

Choose a reason for hiding this comment

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

This PR changes the default quality from -1 to 90.
https://www.php.net/manual/en/function.imagewebp.php#refsect1-function.imagewebp-description
I don't know what -1 means.
Does this degrade the image quality?

Copy link
Member

Choose a reason for hiding this comment

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

It's probably the same as in imagejpeg() - https://www.php.net/manual/en/function.imagejpeg.php

The default (-1) uses the default IJG quality value (about 75).

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it appears to be a fixed value.

Copy link
Member

Choose a reason for hiding this comment

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

Since the behavior changes (80 -> 90), should we add this to changelog?
This doesn't seem to destroy the application, though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we must change default $quality to 80, And i can set parameter $quality to PNG with 0 - 9.

Copy link
Member

Choose a reason for hiding this comment

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

Do you mean that the default quality for webp is 80, for jpeg is 90?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should stay with 90 as the default value for quality. Having a separate value for WEBP makes not much sense to me.

Regarding PNG, we can't speak about the quality since these files are lossless. The image quality, as we know it from JPEG or WEBP, will not be changed. Only the compression - file size will be changed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its okay, i agree to $quality to WebP using default 90. And with this changes make developer have preferences to changes quality compression for WebP

Copy link
Member

Choose a reason for hiding this comment

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

@ddevsr ddevsr requested a review from kenjis May 25, 2023 08:36
@kenjis kenjis merged commit 613c2bf into codeigniter4:4.4 May 25, 2023
@kenjis
Copy link
Member

kenjis commented May 25, 2023

@ddevsr Thank you!

@ddevsr ddevsr deleted the quality-option branch May 26, 2023 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.4 enhancement PRs that improve existing functionalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants