• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question AlmaLinux php 5.6 support

Can you test this version of your code:

Code:
<?php

declare(strict_types=1);

// Error reporting
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

/**
 * Check if GD and FreeType are available
 *
 * @return void
 * @throws RuntimeException if GD or FreeType are not available
 */
function checkRequirements(): void
{
    if (!extension_loaded('gd') || !function_exists('gd_info')) {
        throw new RuntimeException("GD library is not enabled.");
    }

    $gdInfo = gd_info();
    if (!isset($gdInfo['FreeType Support']) || !$gdInfo['FreeType Support']) {
        throw new RuntimeException("FreeType support is not enabled.");
    }
}

/**
 * Generate an image with text
 *
 * @param string $text
 * @param string $fontPath
 * @return GdImage
 * @throws RuntimeException if image creation fails
 */
function generateImage(string $text, string $fontPath): GdImage
{
    if (!file_exists($fontPath) || !is_readable($fontPath)) {
        throw new RuntimeException("Font file not found or not readable: $fontPath");
    }

    $width = 400;
    $height = 200;
    $im = imagecreatetruecolor($width, $height);

    if ($im === false) {
        throw new RuntimeException("Failed to create image");
    }

    $white = imagecolorallocate($im, 255, 255, 255);
    $red = imagecolorallocate($im, 255, 0, 0);

    imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $white);

    // Calculate text position to center it
    $fontSize = 20;
    $bbox = imagettfbbox($fontSize, 0, $fontPath, $text);
    $x = ceil(($width - $bbox[2]) / 2);
    $y = ceil(($height - $bbox[5]) / 2);

    imagettftext($im, $fontSize, 0, $x, $y, $red, $fontPath, $text);

    return $im;
}

try {
    checkRequirements();

    $fontPath = __DIR__ . '/calibrib.ttf';
    $text = 'Testing...';

    $image = generateImage($text, $fontPath);

    header('Content-Type: image/jpeg');
    imagejpeg($image);
} catch (Exception $e) {
    header("HTTP/1.1 500 Internal Server Error");
    echo "An error occurred: " . $e->getMessage();
} finally {
    if (isset($image) && $image instanceof GdImage) {
        imagedestroy($image);
    }
}
 
I mean i already told my Hosting guys to fix php with GD 2.33
=========== Testimg.php
<?php
ob_clean();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
ini_set('display_errors', 1);
try{
$gd_info = gd_info();
if (extension_loaded('gd') && function_exists('gd_info')) {
// echo "It looks like GD is installed";
// exit();
}
// echo "GD Info: <pre>" . print_r($gd_info, true) . "</pre>";
if (function_exists('gd_info')) {
//echo "GD library is enabled.<br>";
} else {
echo "GD library is not enabled.<br>";
exit();
}
if (isset($gd_info['FreeType Support']) && $gd_info['FreeType Support']) {
//echo "FreeType support is enabled.<br>";
} else {
echo "FreeType support is not enabled.<br>";
exit();
}
$basedir=__DIR__."/resources/certifcateresources/";
$im =imagecreatetruecolor(400, 200);
$bg = imagecolorallocate($im, 255, 255, 0); // White background
$text_color = imagecolorallocate($im, 0, 0, 0); // Black text
$white =imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 0xFF, 0x00, 0x00);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);
//imagefilledrectangle($im, 0, 0, 400, 200, $bg);
imagefilledrectangle($im, 0, 0, 399, 200, $white);
$font_path = './arial.ttf';
$font_path = getcwd().'/calibrib.ttf';
// Check if the font file exists and is accessible
if (!file_exists($font_path)) {
// die('Error: Font file not found');
// exit();
}
// Check if we have write permission to the directory
if (!is_readable($font_path)) {
// die('Error: Font file is not readable');
// exit();
}
$text = 'Testing...';
//imagestring($im, 10, 10, 10, $text, $text_color);
imagettftext($im, 40 , 0, 50, 60, $red, $font_path, " @@@@@ ");
//p($bbox);
header('Content-Type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
}
catch(Exception $e)
{
echo $e;
exit();
}
?>
=============
you need to find arial.ttf from internet to see it. its freely available . i tested in local pc with laragon and old server. it works
 
The problem us he php 5.6.4 come with plesk has old gd library version 2.1 instead of 2.33. Why ? Because we had plesk with centos in mediatemple with php 5.6 which had gd version 2.33

Now i have almalinux , the php version do not have gd version 2.33

Now i am looking for how to find and install. Remi dont have php 5.6 anymore
 
Back
Top