Jump to content

[Solved] GD functions are needed to process images, please ensure your PHP install is compiled with GD enabled. Freetype (in GD...


Recommended Posts

Posted (edited)
I installed a php script on my site but this was not found so I can install this
"GD functions are needed to process images, please ensure your PHP install is compiled with GD enabled.
Freetype (in GD) is required to use ttf fonts within images. "

 

Any solution?

 

email: bielsilva1cba@gmail.com

Edited by bielsilvah
Link to comment
Share on other sites

That just needs to be installed yet. PHP is installed without most of its extensions when a server is rebuilt.

 

What PHP version is this needed for?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Similar Content

    • By abdoudzg
      Hello can you please enable intl extension on php 7.3 ?
        
    • By bca
      how to enable php errors in johnny server
      pls i have check many things but cant find the right soluton anyone can help me ! pls
       
      i know about error_logs but i dont want that
    • By adrianol
      Hi
       
      I can't run php in a html file on johhny. What do I need to do?
    • By sagnik
      Hello again, I've got a problem with PHP GD. The problem is I'm trying to draw charts (i.e.Bar) and I'm trying to draw the Bell Curve of a data or an array with "Normal Distribution", but the problem is the chart is not fitting inside the allocated image size (1920 x 1080) so the chart is exceeding the boundaries of the image. So I've just tried a library "JpGraph" it works very well but doesn't fit my requirements, so I saw that the library is using some kind of canvas to draw the chart and then merging the image with the original one and I'm trying to do the same but I couldn't understand how. Please help me out, it's very urgent, I've to finish the project within a week.
       

      public function histogram(array $samples, int $bins, string $heading = null, string $xAxisHeading = null, string $yAxisHeading = null) { if(is_array($samples)) { $data = $_bins = $this->calculateBins($samples, $bins); /* * Chart settings and create image */ // Margin between label and axis $labelMargin = 8; $count = count($samples); // Max value on y-axis $yMaxValue = max(array_column($data, 'count')); if($yMaxValue % 2 == 1) $yMaxValue++; // Distance between grid lines on y-axis $yLabelSpan = ceil($yMaxValue / $bins); $t1 = ($yLabelSpan * $bins); if($t1 > $yMaxValue) $yMaxValue = $t1; // Bar and line width $lineWidth = 1; $barWidth = 20; // Image dimensions $imageWidthActual = round(count($data) * $barWidth * ($labelMargin / 2)); $imageHeightActual = round((count($data) / 2) * $count / 2); $imageWidth = min(1920, $imageWidthActual); $imageHeight = min(1024, $imageHeightActual); // Grid dimensions and placement within image $gridTop = 40; $gridBottom = round(($imageHeight - $gridTop)); $gridLeft = 50; $gridRight = round(($imageWidth - $gridLeft)); $gridHeight = $gridBottom - $gridTop; $gridWidth = $gridRight - $gridLeft; // Bar space $barSpacing = $gridWidth / count($data); // Font settings $font = PHPML_ROOT.'assets/fonts/OpenSans-Regular.ttf'; $headingFont = PHPML_ROOT.'assets/fonts/OpenSans-Bold.ttf'; $fontSize = 10; $headingFontSize = 12; // Init image $chart = imagecreatetruecolor($imageWidth, $imageHeight); // Setup colors $backgroundColor = imagecolorallocate($chart, 255, 255, 255); $headingColor = imagecolorallocate($chart, 0, 0, 0); $axisColor = imagecolorallocate($chart, 85, 85, 85); $gridColor = imagecolorallocate($chart, 212, 212, 212); //$barColor = imagecolorallocate($chart, 47, 133, 217); $labelColor = $axisColor; imagefill($chart, 0, 0, $backgroundColor); imagesetthickness($chart, $lineWidth); /* * Print grid lines bottom up and Y-Labels */ for($i = 0; $i <= $yMaxValue; $i += $yLabelSpan) { $y = $gridBottom - $i * $gridHeight / $yMaxValue; // draw the line imageline($chart, $gridLeft, $y, $gridRight, $y, $gridColor); // draw right aligned label $labelBox = imagettfbbox($fontSize, 0, $font, strval($i)); $labelWidth = $labelBox[4] - $labelBox[0]; $labelX = $gridLeft - $labelWidth - $labelMargin; $labelY = $y + $fontSize / 2; imagettftext($chart, $fontSize, 0, $labelX, $labelY, $labelColor, $font, strval($i)); } /* * Draw x- and y-axis */ imageline($chart, $gridLeft, $gridTop, $gridLeft, $gridBottom, $axisColor); //Left //imageline($chart, $gridRight, $gridTop, $gridRight, $gridBottom, $axisColor); //Right //imageline($chart, $gridLeft, $gridTop, $gridRight, $gridTop, $axisColor); //Top imageline($chart, $gridLeft, $gridBottom, $gridRight, $gridBottom, $axisColor); //Bottom $headingBox = $this->getTextBoundingBox($chart, $headingFontSize, $headingFont, strval($heading), 0); $xAxisHeadingBox = $this->getTextBoundingBox($chart, $fontSize, $font, strval($xAxisHeading), 0); $yAxisHeadingBox = $this->getTextBoundingBox($chart, $fontSize, $font, strval($yAxisHeading), 90); if(!empty($heading)) imagettftext($chart, $headingFontSize, 0, $headingBox['x']['center'], $headingBox['y']['top'], $headingColor, $headingFont, $heading); if(!empty($xAxisHeading)) imagettftext($chart, $fontSize, 0, $xAxisHeadingBox['x']['center'], $xAxisHeadingBox['y']['bottom'], $headingColor, $font, $xAxisHeading); if(!empty($yAxisHeading)) imagettftext($chart, $fontSize, 90, $yAxisHeadingBox['x']['left'], $yAxisHeadingBox['y']['middle'], $headingColor, $font, $yAxisHeading); /* * Draw the bars with X-labels */ $itemX = $gridLeft + $barSpacing / 2; $canvasWidth = ($imageWidth * 2); $canvasHeight = ($imageHeight * 2); $canvas = imagecreatetruecolor($canvasWidth, $canvasHeight); $canvasBackgroundColor = imagecolorallocate($canvas, 255, 255, 255); $labelColor = imagecolorallocate($canvas, 85, 85, 85); $barColor = imagecolorallocate($canvas, 47, 133, 217); imagefill($canvas, 0, 0, $canvasBackgroundColor); foreach($data as $key => $bin) { // Draw the label $labelBox = imagettfbbox($fontSize, 0, $font, $key); $labelWidth = $labelBox[4] - $labelBox[0]; $labelX = $itemX - $labelWidth / 2; $labelY = $gridBottom + $labelMargin + $fontSize; imagettftext($canvas, $fontSize, 0, $labelX, $labelY, $labelColor, $font, $key); foreach($bin as $k=>$value) { // Draw the bar $x1 = $itemX - $barWidth / 2; $y1 = $gridBottom - $value / $yMaxValue * $gridHeight; $x2 = $itemX + $barWidth / 2; $y2 = $gridBottom - 1; imagefilledrectangle($canvas, $x1, $y1, $x2, $y2, $barColor); } $itemX += $barSpacing; } $resized = $this->resize($canvas, $imageWidth, $imageHeight); imagealphablending($canvas, false); imagesavealpha($canvas, true); //imagecopyresampled($chart, $canvas, 0, 0, 0, 0, $canvasWidth, $canvasHeight, $imageWidth, $imageHeight); imagecopymerge($chart, $resized, 0, 0, 0, 0, $canvasWidth, $canvasHeight, 100); //imagecopyresized($chart, $canvas, 10, 10, 0, 0, $canvasWidth, $canvasHeight, $imageWidth, $imageHeight); /* * Output image to browser */ //header('Content-Type: image/png'); ob_start(); imagepng($chart); $outBlob = ob_get_contents(); ob_end_clean(); imagedestroy($canvas); imagedestroy($chart); $outImg = "data: image/png;base64,".base64_encode($outBlob); /* * Output image to file */ //imagepng($chart, 'chart.png'); return $outImg; } return false; }
×
×
  • Create New...