From 3c3404f72ed69a28ca66aa9876d0b7afa028db09 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Wed, 16 Sep 2026 09:42:05 +0530 Subject: [PATCH 1/4] GD: Use imageflip() for flipping images --- src/wp-includes/class-wp-image-editor-gd.php | 29 +++++++------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/wp-includes/class-wp-image-editor-gd.php b/src/wp-includes/class-wp-image-editor-gd.php index 34c0453ff693a..fb17b8512415e 100644 --- a/src/wp-includes/class-wp-image-editor-gd.php +++ b/src/wp-includes/class-wp-image-editor-gd.php @@ -438,28 +438,19 @@ public function rotate( $angle ) { * @return true|WP_Error */ public function flip( $horz, $vert ) { - $w = $this->size['width']; - $h = $this->size['height']; - $dst = wp_imagecreatetruecolor( $w, $h ); - - if ( is_gd_image( $dst ) ) { - $sx = $vert ? ( $w - 1 ) : 0; - $sy = $horz ? ( $h - 1 ) : 0; - $sw = $vert ? -$w : $w; - $sh = $horz ? -$h : $h; - - if ( imagecopyresampled( $dst, $this->image, 0, 0, $sx, $sy, $w, $h, $sw, $sh ) ) { - if ( PHP_VERSION_ID < 80000 ) { // imagedestroy() has no effect as of PHP 8.0. - imagedestroy( $this->image ); - } - - $this->image = $dst; + if ( ! is_gd_image( $this->image ) ) { + return new WP_Error( 'image_flip_error', __( 'Image flip failed.' ), $this->file ); + } - return true; - } + if ( $horz && $vert ) { + return imageflip( $this->image, IMG_FLIP_BOTH ); + } elseif ( $horz ) { + return imageflip( $this->image, IMG_FLIP_VERTICAL ); + } elseif ( $vert ) { + return imageflip( $this->image, IMG_FLIP_HORIZONTAL ); } - return new WP_Error( 'image_flip_error', __( 'Image flip failed.' ), $this->file ); + return true; } /** From 2de0263a3473098130fe5096c8898688a8a8069f Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Wed, 16 Sep 2026 09:55:41 +0530 Subject: [PATCH 2/4] GD: Use imageflip() for flipping images --- src/wp-includes/class-wp-image-editor-gd.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-image-editor-gd.php b/src/wp-includes/class-wp-image-editor-gd.php index fb17b8512415e..5bd845457f0e4 100644 --- a/src/wp-includes/class-wp-image-editor-gd.php +++ b/src/wp-includes/class-wp-image-editor-gd.php @@ -435,7 +435,7 @@ public function rotate( $angle ) { * * @param bool $horz Flip along Horizontal Axis. * @param bool $vert Flip along Vertical Axis. - * @return true|WP_Error + * @return bool|WP_Error */ public function flip( $horz, $vert ) { if ( ! is_gd_image( $this->image ) ) { From f2fd54258e67227b42bab9a995cf1c54b15f4971 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Wed, 16 Sep 2026 09:58:45 +0530 Subject: [PATCH 3/4] GD: Use imageflip() for flipping images --- src/wp-includes/class-wp-image-editor-gd.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-image-editor-gd.php b/src/wp-includes/class-wp-image-editor-gd.php index 5bd845457f0e4..4aac6e1cd38cb 100644 --- a/src/wp-includes/class-wp-image-editor-gd.php +++ b/src/wp-includes/class-wp-image-editor-gd.php @@ -445,9 +445,9 @@ public function flip( $horz, $vert ) { if ( $horz && $vert ) { return imageflip( $this->image, IMG_FLIP_BOTH ); } elseif ( $horz ) { - return imageflip( $this->image, IMG_FLIP_VERTICAL ); - } elseif ( $vert ) { return imageflip( $this->image, IMG_FLIP_HORIZONTAL ); + } elseif ( $vert ) { + return imageflip( $this->image, IMG_FLIP_VERTICAL ); } return true; From 21690f71dbba4ac7b9f00882977b8f259958228c Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Wed, 16 Sep 2026 10:18:29 +0530 Subject: [PATCH 4/4] GD: Use imageflip() for flipping images --- src/wp-includes/class-wp-image-editor-gd.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-image-editor-gd.php b/src/wp-includes/class-wp-image-editor-gd.php index 4aac6e1cd38cb..5bd845457f0e4 100644 --- a/src/wp-includes/class-wp-image-editor-gd.php +++ b/src/wp-includes/class-wp-image-editor-gd.php @@ -445,9 +445,9 @@ public function flip( $horz, $vert ) { if ( $horz && $vert ) { return imageflip( $this->image, IMG_FLIP_BOTH ); } elseif ( $horz ) { - return imageflip( $this->image, IMG_FLIP_HORIZONTAL ); - } elseif ( $vert ) { return imageflip( $this->image, IMG_FLIP_VERTICAL ); + } elseif ( $vert ) { + return imageflip( $this->image, IMG_FLIP_HORIZONTAL ); } return true;