346 | | $transparency = imagecolorallocatealpha( $this->image, 255, 255, 255, 127 ); |
347 | | $rotated = imagerotate( $this->image, $angle, $transparency ); |
| 346 | // Set the background fill color when an image is partially rotated ($angle is not 90, 180, or 270). |
| 347 | if ( 'image/png' === $this->mime_type || 'image/gif' === $this->mime_type ) { |
| 348 | $bg_color = imagecolorallocatealpha( $this->image, 255, 255, 255, 127 ); |
| 349 | } else { |
| 350 | $bg_color = imagecolorallocate( $this->image, 255, 255, 255 ); |
| 351 | } |
350 | | imagealphablending( $rotated, true ); |
351 | | imagesavealpha( $rotated, true ); |
| 356 | // Disable blending mode for images that support transparency. |
| 357 | // It "blends" the pixels and makes them opaque. |
| 358 | if ( 'image/png' === $this->mime_type || 'image/gif' === $this->mime_type ) { |
| 359 | imagealphablending( $rotated, false ); |
| 360 | } |
| 361 | |
| 362 | // Preserve trnasparency for PNGs. |
| 363 | if ( 'image/png' === $this->mime_type ) { |
| 364 | imagesavealpha( $rotated, true ); |
| 365 | } |
| 366 | |