dl5ark1 Posted September 27 Posted September 27 I am experiencing an issue with generating images using a PHP script from the MyBlitzortung project (https://github.com/tobiasv/MyBlitzortung/tree/master) after moving my website from the old tommy2 server to the new tommy server. The script uses the GD library to render images with text, but after the move, no text is displayed in the images. To investigate, I ran two simple test scripts: gd.php (https://dl5ark.heliohost.org/gd.php): This test creates a blank image with a black background and attempts to display text using a specific TTF font, but only a white rectangle is shown without the text. gd1.php (https://dl5ark.heliohost.org/gd1.php): Similarly, this script also fails to display the text. The PHP script in question (functions_image.inc.php) relies on the GD library with FreeType support to render the text, and the path to the TTF font seems to be correctly configured. The issue persists even though: - FreeType support is enabled on the server. - The font files are present and accessible with appropriate permissions. I kindly request your help to: 1. Verify if the GD library with FreeType is functioning correctly on the new server. 2. Check for any potential issues with the PHP configuration (e.g., paths, library versions, or limitations) that might prevent the text rendering from working properly. I appreciate your assistance in resolving this issue, as it affects the proper functioning of image generation on the website. Wolstech has also tested it and confirms the problem with PHP 6.5 and the GD library (GD is broken): https://helionet.org/index/topic/62191-tommy-upgrade/?do=findComment&comment=279291 . Thank you for your help, best regards!
wolstech Posted September 27 Posted September 27 Krydos will need to look why GD does not support using fonts/adding text on PHP 5.6. Thanks for making a separate topic for it Escalating...
Krydos Posted September 27 Posted September 27 Yep, I can confirm that GD imagettftext() function on Tommy's PHP 5.6 is broken, and I can't get it to even produce an error. I suspect it is Plesk's fault because we just use the package plesk-php56-gd.rpm and they probably made some mistake compiling it. Some options: We can report it to Plesk and see if they will fix it. We could uninstall the Plesk package, and compile GD ourself from source, but that seems like too much work and may break other things. We could use a version of PHP where GD actually works, such as 7.4, but that may not be an option if too much of the rest of the code requires 5.6. We could move your website to Lily where I think PHP 5.6 has GD and it actually works. We could move you to a VPS which start at $4 per month https://heliohost.org/vps/ You could use Image Magick instead of GD. Example code below: <?php // font size and colors $fontsize = 53; $width = 800; $height = 200; $bg = "#fbfbfb"; $fg = "#000000"; $text = "Hallo, Welt!"; // initialize the imagick stuff $image = new Imagick(); $draw = new ImagickDraw(); $pixel = new ImagickPixel($bg); // load font $draw->setFont("./DejaVuSansMono-Oblique.ttf"); $draw->setFontSize($fontsize); $draw->setFillColor($fg); // make background $image->newimage($width, $height, $pixel); // add text to background $image->annotateImage($draw, 100, 150, 0, $text); $image->setImageFormat("png"); header("Content-Type: image/png"); echo $image; Example using the above Image Magick code on PHP 5.6: Example using your GD code on PHP 7.4:
dl5ark1 Posted September 27 Author Posted September 27 48 minutes ago, Krydos said: Yep, I can confirm that GD imagettftext() function on Tommy's PHP 5.6 is broken, and I can't get it to even produce an error. I suspect it is Plesk's fault because we just use the package plesk-php56-gd.rpm and they probably made some mistake compiling it. Some options: We can report it to Plesk and see if they will fix it. We could uninstall the Plesk package, and compile GD ourself from source, but that seems like too much work and may break other things. We could use a version of PHP where GD actually works, such as 7.4, but that may not be an option if too much of the rest of the code requires 5.6. We could move your website to Lily where I think PHP 5.6 has GD and it actually works. We could move you to a VPS which start at $4 per month https://heliohost.org/vps/ You could use Image Magick instead of GD. Example code below: <?php // font size and colors $fontsize = 53; $width = 800; $height = 200; $bg = "#fbfbfb"; $fg = "#000000"; $text = "Hallo, Welt!"; // initialize the imagick stuff $image = new Imagick(); $draw = new ImagickDraw(); $pixel = new ImagickPixel($bg); // load font $draw->setFont("./DejaVuSansMono-Oblique.ttf"); $draw->setFontSize($fontsize); $draw->setFillColor($fg); // make background $image->newimage($width, $height, $pixel); // add text to background $image->annotateImage($draw, 100, 150, 0, $text); $image->setImageFormat("png"); header("Content-Type: image/png"); echo $image; Example using the above Image Magick code on PHP 5.6: Example using your GD code on PHP 7.4: 1. We can report it to Plesk and see if they will fix it. This seems like the best idea for now, as others might be affected by the problem as well. If Plesk acknowledges the problem and fixes it, it will benefit everyone. 2. We could uninstall the Plesk package, and compile GD ourself from source, but that seems like too much work and may break other things. We should wait with that. Depending on how 1. turns out. 3. We could use a version of PHP where GD actually works, such as 7.4, but that may not be an option if too much of the rest of the code requires 5.6. This code would run with 7.4 if necessary, but other code on my site still requires 5.6. If you could choose PHP per application instead of for the whole homepage that would be an option, unfortunately not. 4. We could move your website to Lily where I think PHP 5.6 has GD and it actually works. Hm, I would wait and see 1. 5. We could move you to a VPS which start at $4 per month https://heliohost.org/vps/ That's “a little” too expensive for me. 6. You could use Image Magick instead of GD. Example code below: Since the Blitzortung project is not my project, the outcome of rewriting possibly many files seems too uncertain to me.
Krydos Posted September 27 Posted September 27 14 minutes ago, dl5ark1 said: If you could choose PHP per application instead of for the whole homepage that would be an option, unfortunately not. You can have up to 10 domains or subdomains on your account, and each one can have a different PHP version. For instance you could do blitz.dl5ark.heliohost.org, anotherproject.dl5ark.heliohost.org, etc
dl5ark1 Posted September 27 Author Posted September 27 21 minutes ago, Krydos said: You can have up to 10 domains or subdomains on your account, and each one can have a different PHP version. For instance you could do blitz.dl5ark.heliohost.org, anotherproject.dl5ark.heliohost.org, etc I wasn't aware of that. I can probably look it up in the manual to set it up correctly. I can give it a try over the next week. Reporting the problem to Plesk is still a good idea.
dl5ark1 Posted September 28 Author Posted September 28 10 hours ago, Krydos said: You can have up to 10 domains or subdomains on your account, and each one can have a different PHP version. For instance you could do blitz.dl5ark.heliohost.org, anotherproject.dl5ark.heliohost.org, etc Please create a subdomain “mybo” for me, I want to test with this. So I will have an additional mybo.dl5ark.heliohost.org, which points to the (existing) directory mybo under public_html, right? From there I can presumably also access the databases as normal, but configure the settings for this subdomain (such as PHP) differently. If I understand everything correctly, I can use any name server.
Krydos Posted September 28 Posted September 28 10 hours ago, dl5ark1 said: Please create a subdomain “mybo” for me Created. 10 hours ago, dl5ark1 said: So I will have an additional mybo.dl5ark.heliohost.org, which points to the (existing) directory mybo under public_html, right? I believe it will be /home/dl5ark.heliohost.org/mybo.dl5ark.heliohost.org/ 10 hours ago, dl5ark1 said: configure the settings for this subdomain (such as PHP) differently. Yes, each subdomain can have a different PHP version.
dl5ark1 Posted September 29 Author Posted September 29 21 hours ago, Krydos said: Created. I believe it will be /home/dl5ark.heliohost.org/mybo.dl5ark.heliohost.org/ Yes, each subdomain can have a different PHP version. Thank you. The result looks good.
Recommended Posts