Repository navigation
Commit 39b25ce
committed
Media: Use
`WP_Image_Editor_GD::flip()` and the deprecated `_flip_image_resource()` mirrored images by copying them with `imagecopyresampled()` and negative source dimensions. With the GD 2.4.0 bundled in PHP 8.6, this produces an all-black image. It affects flips in the image editor, and also JPEG uploads with an EXIF orientation of 2, 3 or 4, which `WP_Image_Editor::maybe_exif_rotate()` flips.
Both functions now flip the image in place with `imageflip()`, and the output stays the same as before. Palette images are still converted to truecolor, alpha blending is turned off and alpha saving on, and the resolution and interlacing are reset to GD's defaults of 96 DPI and off. This matches what `rotate()`, `crop()` and `resize()` produce. Whether every operation should keep the source image's resolution and interlacing will be decided in a follow-up ticket.
When no valid image is loaded, `flip()` now returns a `WP_Error` instead of throwing a `TypeError`.
Props sanjith2023, rumancodes, arshidkv12, dhruvang21, abhishekfdd, desrosj.
Fixes #66113.
git-svn-id: https://develop.svn.wordpress.org/trunk@65367 602fd350-edb4-49c9-b593-d223f7449a82imageflip() to flip images with GD.1 parent 055b013 commit 39b25ce
4 files changed
Lines changed: 766 additions & 29 deletions
File tree
- src
- wp-admin/includes
- wp-includes
- tests/phpunit/tests/image
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
565 | 565 | | |
566 | 566 | | |
567 | 567 | | |
| 568 | + | |
568 | 569 | | |
569 | 570 | | |
570 | 571 | | |
| |||
577 | 578 | | |
578 | 579 | | |
579 | 580 | | |
580 | | - | |
581 | | - | |
582 | | - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
583 | 584 | | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
589 | 589 | | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
594 | 593 | | |
595 | | - | |
596 | | - | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
597 | 606 | | |
598 | 607 | | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
599 | 618 | | |
600 | 619 | | |
601 | 620 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| 435 | + | |
435 | 436 | | |
436 | 437 | | |
437 | 438 | | |
438 | 439 | | |
439 | 440 | | |
440 | 441 | | |
441 | | - | |
442 | | - | |
443 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
444 | 445 | | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
450 | 455 | | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
455 | 463 | | |
456 | | - | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
457 | 473 | | |
458 | | - | |
459 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
460 | 488 | | |
461 | 489 | | |
462 | 490 | | |
| |||
0 commit comments