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: AVIF Supported #8560

Closed
wants to merge 9 commits into from
Closed

feat: AVIF Supported #8560

wants to merge 9 commits into from

Conversation

ALTITUDE-DEV-FR
Copy link
Contributor

@ALTITUDE-DEV-FR ALTITUDE-DEV-FR commented Feb 19, 2024

Description
Here is an edition to support the .AVIF format on CodeIgniter 4.5.0, which is the successor to .webp in the years to come. Currently, only three browsers do not yet support AVIF (88.81% of browsers support this version).

https://caniuse.com/avif

The AVIF format is lighter than WEBP.

Here is an example of a comparison from my CodeIgniter CMS, for instance.
Capture d'écran 2024-02-19 132846

Warning, changing the format to a larger one than the original image increases its file size.
Exemple of use:

$image->withFile($pathfolder.$newName)->convert(IMAGETYPE_AVIF)->save($pathfolderLarge.mb_url_title($newNameC).'.avif');

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

@ALTITUDE-DEV-FR ALTITUDE-DEV-FR changed the base branch from develop to 4.5 February 19, 2024 12:30
@kenjis kenjis added enhancement PRs that improve existing functionalities 4.5 labels Feb 19, 2024
@kenjis kenjis changed the title AVIF Supported ffeat: AVIF Supported Feb 19, 2024
@kenjis kenjis changed the title ffeat: AVIF Supported feat: AVIF Supported Feb 19, 2024
@kenjis
Copy link
Member

kenjis commented Feb 19, 2024

Thank you for sending PR!

But you created your PR branch from develop. It is wrong, and it runs incorrect GitHub Action checks, and some fails.
See "PHPUnit / Others (8.0)". Of course 4.5 does not support PHP 8.0.

Can you run git rebase --onto?
See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#if-you-sent-to-the-wrong-branch

@kenjis
Copy link
Member

kenjis commented Feb 19, 2024

Also, fix the coding style. If you run composer cs-fix, it fixes automatically.

   1) system/Images/Handlers/GDHandler.php (unary_operator_spaces, statement_indentation, not_operator_with_successor_space, no_extra_blank_lines, blank_line_before_statement, no_whitespace_in_blank_line)
      ---------- begin diff ----------
--- /home/runner/work/CodeIgniter4/CodeIgniter4/system/Images/Handlers/GDHandler.php
+++ /home/runner/work/CodeIgniter4/CodeIgniter4/system/Images/Handlers/GDHandler.php
@@ -274,7 +274,7 @@
                     throw ImageException::forSaveFailed();
                 }
                 break;
-            
+
             case IMAGETYPE_AVIF:
                 if (! function_exists('imageavif')) {
                     throw ImageException::forInvalidImageCreate(lang('Images.avifNotSupported'));
@@ -376,11 +376,11 @@
 
                 return imagecreatefromwebp($path);
 
-             case IMAGETYPE_AVIF:
+            case IMAGETYPE_AVIF:
                 if (! function_exists('imagecreatefromavif')) {
                     throw ImageException::forInvalidImageCreate(lang('Images.avifNotSupported'));
                 }
-            
+
                 return imagecreatefromavif($path);
 
             default:

      ----------- end diff -----------

   2) system/Images/Handlers/BaseHandler.php (trailing_comma_in_multiline, unary_operator_spaces, not_operator_with_successor_space, no_extra_blank_lines, blank_line_before_statement)
      ---------- begin diff ----------
--- /home/runner/work/CodeIgniter4/CodeIgniter4/system/Images/Handlers/BaseHandler.php
+++ /home/runner/work/CodeIgniter4/CodeIgniter4/system/Images/Handlers/BaseHandler.php
@@ -113,7 +113,7 @@
     protected $supportTransparency = [
         IMAGETYPE_PNG,
         IMAGETYPE_WEBP,
-        IMAGETYPE_AVIF
+        IMAGETYPE_AVIF,
     ];
 
     /**

      ----------- end diff -----------

@ALTITUDE-DEV-FR
Copy link
Contributor Author

Also, fix the coding style. If you run composer cs-fix, it fixes automatically.

   1) system/Images/Handlers/GDHandler.php (unary_operator_spaces, statement_indentation, not_operator_with_successor_space, no_extra_blank_lines, blank_line_before_statement, no_whitespace_in_blank_line)
      ---------- begin diff ----------
--- /home/runner/work/CodeIgniter4/CodeIgniter4/system/Images/Handlers/GDHandler.php
+++ /home/runner/work/CodeIgniter4/CodeIgniter4/system/Images/Handlers/GDHandler.php
@@ -274,7 +274,7 @@
                     throw ImageException::forSaveFailed();
                 }
                 break;
-            
+
             case IMAGETYPE_AVIF:
                 if (! function_exists('imageavif')) {
                     throw ImageException::forInvalidImageCreate(lang('Images.avifNotSupported'));
@@ -376,11 +376,11 @@
 
                 return imagecreatefromwebp($path);
 
-             case IMAGETYPE_AVIF:
+            case IMAGETYPE_AVIF:
                 if (! function_exists('imagecreatefromavif')) {
                     throw ImageException::forInvalidImageCreate(lang('Images.avifNotSupported'));
                 }
-            
+
                 return imagecreatefromavif($path);
 
             default:

      ----------- end diff -----------

   2) system/Images/Handlers/BaseHandler.php (trailing_comma_in_multiline, unary_operator_spaces, not_operator_with_successor_space, no_extra_blank_lines, blank_line_before_statement)
      ---------- begin diff ----------
--- /home/runner/work/CodeIgniter4/CodeIgniter4/system/Images/Handlers/BaseHandler.php
+++ /home/runner/work/CodeIgniter4/CodeIgniter4/system/Images/Handlers/BaseHandler.php
@@ -113,7 +113,7 @@
     protected $supportTransparency = [
         IMAGETYPE_PNG,
         IMAGETYPE_WEBP,
-        IMAGETYPE_AVIF
+        IMAGETYPE_AVIF,
     ];
 
     /**

      ----------- end diff -----------

Thanks for your help, i dont use composer for Github, i push directly from Github Website.

@ALTITUDE-DEV-FR ALTITUDE-DEV-FR closed this by deleting the head repository Feb 19, 2024
@ALTITUDE-DEV-FR
Copy link
Contributor Author

ALTITUDE-DEV-FR commented Feb 19, 2024

oh no i have delete the repo.. do you have possibilitie to re-open ? (i have make other change in toolbar, and my commit is deleted :O)

@kenjis
Copy link
Member

kenjis commented Feb 19, 2024

i dont use composer for Github, i push directly from Github Website.

I recommend to use local IDE like PhpStorm, VS Code, etc.
Then you can easily manipulate your code and/or git.

Also, one branch is needed for one PR.
See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/pull_request.md#branching

I pushed the branch in my local repository:
https://github.com/kenjis/CodeIgniter4/tree/ALTITUDE-DEV-FR/develop

@kenjis kenjis mentioned this pull request Apr 5, 2024
5 tasks
@kenjis kenjis added the tests needed Pull requests that need tests label Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.5 enhancement PRs that improve existing functionalities tests needed Pull requests that need tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants