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
51
votes
4 answers

Yosemite / El Capitan php-gd + mcrypt installation

How to install/enable php-gd and mcrypt in Yosemite 10.10 - PHP 5.5.14 build? note that following steps install newest PHP 5.5.x To check if you have gd and mcrypt installed use $ php -m to display compiled in modules, continue if you are missing…
Kyslik
  • 8,217
  • 5
  • 54
  • 87
49
votes
4 answers

Troubles with Docker + PHP7 + GD resulting in "Call to undefined function imagecreatefromjpeg()"

I'm having troubles when trying to create an image using imagecreatefromjpeg using this Dockerfile to generate the container: FROM php:7.1-apache RUN apt-get update && \ apt-get install -y -qq git \ libjpeg62-turbo-dev \ …
John Murowaniecki
  • 613
  • 1
  • 5
  • 9
37
votes
5 answers

PHP Fatal error: Call to undefined function imagettftext()

Why am I getting the error PHP Fatal error: Call to undefined function imagettftext() on line 29?
Jess McKenzie
  • 8,345
  • 27
  • 100
  • 170
22
votes
4 answers

Trying to add freetype to php-gd in Docker official image

I'm trying to add some features to PHP GD installation. I'm using Docker PHP "Official" release as base (php:7.1.15-fpm-jessie). My current production environment uses CentOS, which GD module comes with FreeType, JPEG and PNG support, as you can see…
otaviofcs
  • 785
  • 2
  • 6
  • 16
21
votes
1 answer

Docker Alpine - Enable GD JPEG support

I'm having a problem getting GD Jpeg support through the Alpine image for PHP-FPM. I've tried every combination I can think of to get this working. Below is a snippet from my Dockerfile: FROM php:7.1-fpm-alpine RUN apk update \ && apk upgrade…
maGz
  • 787
  • 3
  • 8
  • 25
19
votes
5 answers

PHP wrong result for imagetruecolortopalette with PNG with transparency

I'm trying to write a PHP script that resizes a PNG image and then converts it to PNG-8 bit mode. So the size of the resulting file will be smaller but without too much quality loss. The resize works perfectly, preserving also image…
user2342558
  • 5,567
  • 5
  • 33
  • 54
18
votes
3 answers

After upgrade, PHP no longer supports PNG operations

After updating to Mac OS X 10.10 (Yosemite) and starting Apache with PHP support, everything works as before except for any image operations on PNG files. I get a Call to undefined function imagecreatefrompng(), while any operation on JPEG files…
Rainer Mohr
  • 536
  • 1
  • 3
  • 10
16
votes
6 answers

How to install PHP extensions on nginx?

I recently discovered NginX, and decided to try it out on my server. I have NginX running and able to serve PHP and HTML files. But now I want to try to install drupal. When trying to install it and check the requirements, I am stopped by one…
samwell
  • 2,757
  • 9
  • 33
  • 48
16
votes
8 answers

How to check if a PNG image has transparency using GD?

How do I check if a PNG image has transparent pixels using PHP's GD extension?
HappyDeveloper
  • 12,480
  • 22
  • 82
  • 117
16
votes
2 answers

PHP GD: How to get dimensions of image resource in memory without writing to file?

I just loaded an image into memory via $img = imagecreatefromjpeg($filename); Then, I applied a rotation to the image: $r_img = imagerotate($img, $angle, 0); Per the docs, imagerotate() may change the dimensions of the image. An example is…
Ryan Griggs
  • 2,457
  • 2
  • 35
  • 58
14
votes
2 answers

Unable to locate package php7.3-gd

I get the error from my cakephp 2.x project: The PHP GD extension is required, but is not installed. I use php7.3 with apache on debian I search and find apt-get install php7.3-gd I tried this but i only get following error: E: Unable to locate…
andre.hey
  • 199
  • 1
  • 2
  • 13
13
votes
3 answers

PHP GD imagecreatefromstring discards transparency

I've been trying to get transparency to work with my application (which dynamically resizes images before storing them) and I think I've finally narrowed down the problem after much misdirection about imagealphablending and imagesavealpha. The…
meustrus
  • 6,637
  • 5
  • 42
  • 53
9
votes
2 answers

PHP recursive function return value

I have written a recursive function in PHP to crop text. The cropped text will have ... attached to the end. Non-cropped text will be returned in its original state. It works if the text fits the maximum width. However, if it does not fit in the…
user1029650
9
votes
3 answers

how to pass php generated image into html meta tag

Im trying to pass a merged image from php into a html meta tag (for a twitter summary card if you're wondering) but the data of the image is not being passed. When I run this code I get no errors from html or php: PHP $dest =…
Garret Kaye
  • 2,412
  • 4
  • 21
  • 45
9
votes
2 answers

imagecreatefrompng is not working at all

I already checked the file with mime type. If it is jpg or gif it is working perfectly with $src = imagecreatefromjpeg($tmpName); and $src = imagecreatefromgif($tmpName); but if the image is png $src = imagecreatefrompng($tmpName); src variable…
user2679683
  • 91
  • 1
  • 1
  • 4
1
2 3
24 25