Repository navigation
GD: Use imageflip() for flipping images - #13549
arshidkv12 wants to merge 5 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
dhruvang21
left a comment
There was a problem hiding this comment.
The move from imagecopyresampled() to imageflip() otherwise looks good.
| * @param bool $horz Flip along Horizontal Axis. | ||
| * @param bool $vert Flip along Vertical Axis. | ||
| * @return true|WP_Error | ||
| * @return bool|WP_Error |
There was a problem hiding this comment.
Could we preserve the true|WP_Error return contract here?
imageflip() returns bool, so returning it directly means this method can now return false when the GD operation fails. The parent WP_Image_Editor::flip() contract is true|WP_Error, and the Imagick implementation also converts failures to WP_Error.
I think we should keep @return true|WP_Error and convert a false result from imageflip() into the existing image_flip_error WP_Error, e.g.:
$result = imageflip( ... );
if ( $result ) {
return true;
}
return new WP_Error( 'image_flip_error', __( 'Image flip failed.' ), $this->file );
|
Hi @arshidkv12, Thank you for opening this PR and contributing to WordPress! ❤️ It seems that there is still unaddressed feedback on here, and #13920 and #13925 are much further along as they have unit tests and documentation about the broader consequences and edge cases from switching to using I'm going to close this out so that efforts can be focused in one place, but please do feel free to continue helping to fix this. |
|
Thank you |
Use
imageflip()inWP_Image_Editor_GD::flip()instead ofimagecopyresampled()with negative dimensions.This fixes image flipping with PHP 8.6 / GD 2.4.0, where the existing implementation can produce incorrect pixel data.
Trac ticket: https://core.trac.wordpress.org/ticket/66113
Use of AI Tools
AI assistance: Yes
Tool(s): ChatGPT
Model(s): GPT-5.6 Luna
Used for: Debugging and test suggestions;