Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It seems there is an issue with it rotating each character and leaving a "mask" of sorts that isn't rotated and then obscures the text around it, causing the issue you are seeing. It is more visible when you turn off the transparent image fill.</p> <p>A workaround could be to rotate the image instead of the text. You will have to fix your coordinates but something like this seems to work:</p> <pre><code>// Add the text imagettftext($img, $font_size, 0, $x, $y, $black, $font, $text); $img = imagerotate($img, $angle, $transparentColor); imageSaveAlpha($img, true); ImageAlphaBlending($img, false); </code></pre> <p>Thus the full code would be:</p> <pre><code>$text = 'My Text Is Messed Up!!!'; $font = './fonts/arial.ttf'; $font_size = 20; $font_multiplier = 0.5; $x=10; $y=190; $angle=45.0; $width = ($font_size * $font_multiplier) * strlen($text); echo $width; $height=200; $size = imageTTFBBox($font_size, $angle, $font, $text); $img = imageCreateTrueColor($width, $height); $transparentColor = imagecolorallocatealpha($img, 200, 200, 200, 127); imagefill($img, 0, 0, $transparentColor); $white = imagecolorallocate($img, 255, 255, 255); // Add the text imagettftext($img, $font_size, 0, $x, $y, $white, $font, $text); $img = imagerotate($img, $angle, $transparentColor); imageSaveAlpha($img, true); ImageAlphaBlending($img, false); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($img, 'welcome-phrase.png'); imagedestroy($img); </code></pre> <p>I moved the imageSaveAlpha and ImageAlphaBlending to the bottom to take care of all that after the rotation has taken place. It's not the best solution but with some tweaking will provide the correct result.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload