Questions tagged [php-gd]

The PHP GD class contains built in image manipulation for PHP versions 4.3 and up.

The PHP GD class contains built in image manipulation for versions 4.3 and up. This class is commonly used for:

  • Adding filters to images
  • Adding watermarks to images
  • Changing image size for upload
  • Outputting an image to the buffer
  • Creating images on the fly (e.g. captcha verification)

A download of the library can be found at https://bitbucket.org/pierrejoye/gd-libgd/downloads

370 questions
9
votes
4 answers

displaying axis from min to max value - calculating scale and labels

Writing a routine to display data on a horizontal axis (using PHP gd2, but that's not the point here). The axis starts at $min to $max and displays a diamond at $result, such an image will be around 300px wide and 30px high, like this: (source:…
michi
  • 6,565
  • 4
  • 33
  • 56
8
votes
2 answers

how to draw semi-transparent rectangle in php?

Here is an example what I would like to do: Here is the result: function red_rectangle($img_src,$x1,$y1,$x2,$y2,$tr = 50) { // Load image $img = imagecreatefromjpeg($img_src); // Transparent red $red = imagecolorallocatealpha($img,…
user669677
8
votes
3 answers

How to add php gd extension to Dockerfile

I'm getting this error when trying to deploy using alpine: phpoffice/phpspreadsheet 1.2.1 requires ext-gd * -> the requested PHP extension gd is missing from your system. Here's my Dockerfile: FROM php:7.2-alpine RUN apk update RUN apk add…
mikelovelyuk
  • 4,042
  • 9
  • 49
  • 95
8
votes
5 answers

Send string to php gd through ajax request

I try to create a captcha code image with php gd : $im = imagecreatetruecolor(100, 25); $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29,…
Petru Lebada
  • 2,167
  • 8
  • 38
  • 59
7
votes
2 answers

imagecreatefromwebp() -> imagejpeg() results in blue channel missing

I am losing color information, seemingly the blue channel, from an image after using GD to read from the WebP version and output a JPEG. Why does this happen and how can I fix it? Original Image Code $pic =…
emtecif
  • 195
  • 2
  • 9
7
votes
3 answers

php resize image without loss quality

i've implement this method (by following php tutorial) for create preview of an images: function createPreview($image_path, $filename) { header('Content-Type: image/jpeg'); $thumb = imagecreatetruecolor(350, 350); $source =…
giozh
  • 9,868
  • 30
  • 102
  • 183
6
votes
2 answers

Convert HTML to image in php

I have to create a PNG / JPEG image from PHP script .. Briefly The code will create a html table and will include an image in that page. I need to save this entire page as an image , save that image in my server and return the path of the image (…
ramesh
  • 4,008
  • 13
  • 72
  • 117
6
votes
4 answers

PHP: Determine Visually Corrupted Images (yet valid) downloaded via Curl with GD/Imagemagick

I'm using Curl via Proxies to download images with a scraper I have developed. Unfortunately, it gets the odd image which looks like these and the last one is completely blank :/ When I test the images via imagemagick (using identify) it tells…
PaulM
  • 3,281
  • 3
  • 28
  • 38
6
votes
2 answers

Crop a png image with PHP, remove empty transparency

I'm currently trying to work with pictures and PHP, thanks to GD functions. Now I would like to modify the size of PNG pictures. Here is an example of a PNG I'd like to resize : The dotted line represent the border of the PNG, the background is…
saperlipopette
  • 1,603
  • 12
  • 26
6
votes
3 answers

imagecreatefrompng (and imagecreatefromstring) causes to unrecoverable fatal error

When I'm trying use php-gd functions on incorrect png images, I have Fatal PHP error. It seems to be some kind of bug, because accordingly to the functions documentation (imagecreatefrompng, for example): * @return resource an image resource…
SeRRgIO
  • 167
  • 2
  • 12
6
votes
1 answer

How to account for font swash with PHP and GD

I have the following code to print text on an image. I am also adding a debug box around the text. However, I noticed the text on the left lies outside of the box that PHP gives me with imagettfbbox. This looks like an issue with the font swash. Is…
Aydin Hassan
  • 1,465
  • 2
  • 20
  • 41
6
votes
2 answers

How to make the code written for image-resizing workable and optimized for all kinds of image extensions?

Basically, I'm using PHP and HTML for my website. I'm a newbie to PHP. So I request you to please correct me if I've made any mistake in my code or approach. I've written code for re-sizing the image uploaded by user to specific size(i.e. specific…
PHPLover
  • 1
  • 51
  • 158
  • 311
6
votes
7 answers

Apache Cannot load modules/libphp5.so into server: when I installed php5-gd

I was trying to install php5-gd but after ran this command: yum install php-gd php-tidy and tried to restart apache: httpd -k restart I got the following error: httpd: Syntax error on line 56 of /etc/httpd/conf/httpd.conf: Syntax error on line 6…
user2924482
  • 8,380
  • 23
  • 89
  • 173
6
votes
1 answer

PHP GD-library installed but not functioning on CentOS 6.4

I've installed php 5.5.6 from remi repo, bun phpinfo() shows no GD library and gd_info() function does not exist. Extension is enabled in /etc/php.d/gd.ini, but still nothing. I've also tried to reinstall php-gd library and it reinstalled…
kovpack
  • 4,905
  • 8
  • 38
  • 55
6
votes
1 answer

How to fix my radon transformation?

I'm building a radon transformation after this article in PHP. But my output is not of the expected result. Input: Expected Result: Actual Result: ... I'm deliberately working with RGB instead of grayscale, because I want to use this method for…
Cobra_Fast
  • 15,671
  • 8
  • 57
  • 102
1
2
3
24 25