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

PHP: Support libwebp on PHP 7.0 – 7.3 #1381

Open
sejas opened this issue May 13, 2024 · 6 comments
Open

PHP: Support libwebp on PHP 7.0 – 7.3 #1381

sejas opened this issue May 13, 2024 · 6 comments

Comments

@sejas
Copy link
Collaborator

sejas commented May 13, 2024

Some Studio users reported an error uploading webp images to the Media Gallery.

Steps to reproduce:

  1. Download a webp image to your computer. For example: https://www.gstatic.com/webp/gallery/1.webp
  2. Access https://playground.wordpress.net/
  3. Navigate to Media > Upload Images
  4. Select the downloaded image
  5. Observe the error: This image cannot be processed by the web server. Convert it to JPEG or PNG before uploading.

Workaround

  1. Rename the image from 1.webp to 1.jpg in your computer.
  2. Try again uploading the image to the WordPress Media Library
  3. Observe the file is correctly uploaded and it has the webp extension

Screencast

webp-error-and-workaround.mp4
@sejas sejas added the [Type] Bug An existing feature does not function as intended label May 13, 2024
@adamziel
Copy link
Collaborator

@sejas just to make sure – does this work in regular WordPress?

@sejas
Copy link
Collaborator Author

sejas commented May 13, 2024

Yes! I tried it in a regular WordPress without plugins and it worked without any issues.

@brandonpayton
Copy link
Member

From the "Using WebP images" section of the WP WebP announcement post:

In WordPress, the lossless WebP format is only supported when the hosting server uses Imagick (the PHP library) until LibGD adds support.

It looks like libgd ought to support webp now based on libgd/libgd#698 merging.

But Playground doesn't appear to support webp. From the Playground WP-CLI demo:

$ wp eval 'var_dump(array_search( "gd", get_loaded_extensions() ) );'
int(13)

$ wp eval 'var_dump(wp_image_editor_supports( array( "mime_type" => "image/webp" ) ) );'
bool(false)

In Playground, PHP loads the "gd" extension, but WP doesn't think the image editor supports webp. Some possibilities:

  • Maybe WP doesn't yet support webp images via libgd.
  • Maybe our version of libgd is old enough to be missing webp support
  • Maybe our build of libgd doesn't include webp support

@adamziel adamziel added [Type] Enhancement New feature or request [Package][@php-wasm] Compile and removed [Type] Bug An existing feature does not function as intended labels May 14, 2024
@adamziel adamziel added this to the PHP Feature Parity milestone May 14, 2024
@adamziel
Copy link
Collaborator

We'd likely need to build GD with libwebp.

@adamziel adamziel changed the title Error uploading webp images into Media Library PHP: Build with libwebp to support uploading webp images into Media Library May 14, 2024
adamziel added a commit that referenced this issue May 14, 2024
Related to #1381
and #1175.

Ships WASM builds og libjpeg and libwebp. This PR doesn't include them
in the PHP build yet, only ships pre-build wasm binaries. It might
require further tweaking before they can be included in the GD build.
adamziel added a commit that referenced this issue May 17, 2024
Ships WASM builds of libjpeg and libwebp.

Related to #1381
and #1175.

## Remaining work

* Rename the `WITH_LIBPNG` Dockerfile option to `WITH_GD`
* Rebuild all node.js and kitchen-sink PHP versions
* Confirm [webp uploads
work](#1381)
* Confirm [GD supports
JPEG](#1175)
@adamziel
Copy link
Collaborator

This is now resolved for PHP >= 7.4, but not for 7.0 – 7.3. How important is webp support in these version for you @sejas?

@adamziel adamziel changed the title PHP: Build with libwebp to support uploading webp images into Media Library PHP: Support libwebp on PHP 7.0 – 7.3 May 17, 2024
@adamziel adamziel mentioned this issue May 17, 2024
28 tasks
@sejas
Copy link
Collaborator Author

sejas commented May 17, 2024

Thank you for fixing the webp issue for PHP 7.4+. You are Awesome!

The main reason we don't need to support older versions is that PHP 7.4 and even 8.0 are already deprecated. Versions lower than 7.3 do not appear in the chart 😆.

https://www.php.net/supported-versions.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants