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
3
votes
0 answers

Wrapping text written on a image

I want to write a wrapped text to a image with php. Here is a demo. If you copy, paste and send text below to demo you will notice that some lines are distorted and there is some paragraph spaces which must not be there. I am looking to the code for…
mcan
  • 1,914
  • 3
  • 32
  • 53
3
votes
1 answer

Find White Pixel Lines

I want to replace all white pixel from a completely white column with other color and if I have a black pixel on column don't change anything, but I don't know where is the problem... Here is the code: function findLines() { $blank = 1; …
Alex F
  • 41
  • 3
3
votes
0 answers

close font file handle after using imagettftext

I'm using imagettftext to draw text on an image using PHP GD header('Content-Type: image/png'); $im = imagecreatetruecolor(400, 30); $white = imagecolorallocate($im, 255, 255, 255); $text = 'Test'; $font = 'data/font/arial.ttf'; imagettftext($im,…
unloco
  • 6,928
  • 2
  • 47
  • 58
3
votes
1 answer

How to resize image like in google plus based on height and making it responsive

I want to make an image scalable on web across all platforms and for all resolutions. I am pretty impressed by the way google does it. For example: 1900 -…
Srikanth V M
  • 672
  • 5
  • 14
  • 31
3
votes
2 answers

rotate image with transparent color

I was going to rotate an image with transparent color using php gd. However, after the rotation, the transparent color in the image is not transparent any more, and the background is not transparent either. Here is my code. $im =…
CharlesDou
  • 347
  • 1
  • 7
  • 16
3
votes
3 answers

The code is sending 2 times without proper image

I tried this code from the post, but this code is sending two emails on a single run of file. Email file is sending email two times using php mail function Let me know what i am doing wrong -
Trialcoder
  • 5,816
  • 9
  • 44
  • 66
3
votes
1 answer

Email file is sending email two times using php mail function

My three concerns, tried different combos with no result, googled but little or no help -- I received two times the email,change myemail@emailserver.com to the email id to see the result. While executing this file I am getting image, however I want…
swapnesh
  • 26,318
  • 22
  • 94
  • 126
3
votes
1 answer

PHP imageconvolution() leaves black dot in the upper left corner

I'm trying to sharpen resized images using this code: imageconvolution($imageResource, array( array( -1, -1, -1 ), array( -1, 16, -1 ), array( -1, -1, -1 ), ), 8, 0); When the transparent PNG image is sharpened, using…
peter.o
  • 3,460
  • 7
  • 51
  • 77
3
votes
3 answers

php imagerotate() ruins alpha on png?

I've been bashing my head agains something simple.. // ....all prev code is fine.... $pasteboard =imagecreatetruecolor($imgs['bg']["width"],$imgs['bg']["height"]); imagealphablending($pasteboard, false); imagecopyresampled($pasteboard,…
Alex
  • 3,732
  • 5
  • 37
  • 59
3
votes
1 answer

imagecolortransparent() turns all black pixels transparent in PHP

Right, so I set out to build a function in PHP that could merge two images together whilst preserving the transparent background of the PNG files - which I successfully accomplished - using the code below, function imageCreateTransparent($x, $y) { …
rusty009
  • 836
  • 7
  • 16
  • 30
2
votes
1 answer

Cannot display image stored in MySQL database after connecting to database through php

I am a complete novice and have just begin working with images in PHP and MySQL database. Here is the problem: The image is being successfully stored in the database table in BLOB field. I can write that in a file(new.jpg) and display the image. Now…
shweta
  • 21
  • 4
2
votes
2 answers

PHP GD library turns merged image from green to orange

I have two gif images, one with a gray gradient background, and one image with a logo. So for example, in the images below, the green box is the logo. My problem is that when I merge the two gif files using the PHP GD library, the green some how…
user1038814
  • 9,337
  • 18
  • 65
  • 86
2
votes
1 answer

Alphabet border in transparent background image is unwanted?

I am using this code to creating images with text written in it with transparent backgrounds.
Ali Nouman
  • 3,304
  • 9
  • 32
  • 53
2
votes
0 answers

Docker: php:8.1.1-fpm-alpine Install specific GD version

Is there any way to specify installed GD extension version? Currently I have following Dockerfile: ARG PHP_VERSION=8.1.1 FROM php:${PHP_VERSION}-fpm-alpine RUN apk add --update --no-cache freetype libpng libjpeg-turbo freetype-dev libpng-dev…
rvaliev
  • 1,051
  • 2
  • 12
  • 31
2
votes
0 answers

Alpha channel overwrites underlying non transparent part after imagecopyresampled

Got a strange thing in production env. Alpha channel overwrites underlying non transparent part after imagecopyresampled. In dev it works as expected: But in prod im getting this: $bubble = imagecreatefrompng($bubblePath); …
Asgu
  • 712
  • 5
  • 15