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
2
votes
1 answer

Merge two images and round corner in PHP

I want to round first image and merge it with second. Here is a two images which I want to merge. First image which I want to round in circle. second image where I wan to merge first image Here is a code which I'm using for this purpose. …
Azeem Haider
  • 111
  • 2
  • 10
2
votes
2 answers

base64 encode PHP generated image without writing the image to disk

I'm generating an image in PHP for use in a users avatar. I start by hashing the username and then doing a hexdec() conversion on various substrings of the hash to build up a set of RGB colours. //create image $avatarImage = imagecreate(250,…
Luke
  • 3,481
  • 6
  • 39
  • 63
2
votes
1 answer

imagecreatefromjpeg not rotating image

I'm having issues with imagecreatefromjpeg and image rotation. To be more specific: Image #1 https://dl.dropboxusercontent.com/u/9271284/stackoverflow/20160124112643911541_orig.jpg is rotated properly by imagecreatefromjpeg (exif tag is honored)…
Vnuk
  • 2,673
  • 1
  • 32
  • 49
2
votes
2 answers

How to use PHP imagecopymerge() to merge the source file to the non-transparent areas only of the destination?

The following code I use is to merge a source png to a destination png with 50% opacity to make it look stitched. The code works fine but the merge function merges the file to the transparent areas of destination too. Is there any way to merge the…
arshad
  • 883
  • 7
  • 30
2
votes
1 answer

How to use PHP GD to create 1 bit bitmaps (black and white only, no gray)

My goal I have an existing PNG. It currently has anti-aliasing, or in other words, shades of gray. I want the image to be 1 bit, or in other words, only using the colors black and white. My aim is to do this with PHP GD. I have to do this with an…
Goose
  • 4,764
  • 5
  • 45
  • 84
2
votes
1 answer

Merging two PNG images with PHP imagecopy does not work

Here a simple example that I cannot make it work. I create 2 simple images of 2x2px with a dot in different coordinates and I try to merge it using imagecopy. The second image ($stamp) is created properly with a transparent background. As result, I…
elier
  • 439
  • 4
  • 12
2
votes
2 answers

Why does this script work for jpeg but not png?

Can anyone tell me why the following code doesn't work? It outputs images with ZERO bytes -- but here's the kicker: the below code works correctly (outputs images with a normal number of bytes) when I change "png" to "jpg" or "jpeg". The src file…
2
votes
1 answer

Why solution to fix png transparency issue of GD does not work?

I have this code (simplified) on render png: $this->image = imagecreatefrompng($this->file); header("Content-Type: {$this->imageInfo['mime']}"); imagepng($this->image); After I got black background, I was looked for some solutions, which didn't…
tomasr
  • 485
  • 1
  • 8
  • 24
2
votes
0 answers

convert php imagecopy to c#

I'm trying to convert the following PHP code to c# but I'm stuck with the imagecopy equivalent on c#. I used Graphics.DrawImage but seems didn't work. PHP Code that works and generates smooth waved text $xp =…
Ergec
  • 11,608
  • 7
  • 52
  • 62
2
votes
1 answer

GD apparently not bundled with TideSDK php module

I read this thread: Does TideSDK have any image manipulation capabilities? I have tried using gd functions and failed within my TideSDK application, and then I ran get_extension_funcs("gd"); to find out what gd functions were available, and I'm…
Uche
  • 105
  • 1
  • 8
2
votes
1 answer

How to add text shadow to overlay text using PHP

I want to add an overlay text with text shadow to an image. So far I have been able to achieve this // top text imagettftext($im, $font_size+2, 0, $text1_params['centered_start'], $font_size+$margin, …
Killswitch
  • 346
  • 2
  • 12
2
votes
1 answer

Saving a PNG to a variable

Is there any way to export the PNG data that's been created using the GD library's imagecreatefrompng directly to a variable, rather than echoing it or saving it to a file?
Jake Roussel
  • 631
  • 1
  • 6
  • 17
2
votes
1 answer

Resizing images with `imagecopyresampled` from PHP GD

Using the PHP GD library, I generate image resource that is opaque white, with some "holes" here and there, which are fully transparent disk shapes. I've attached it bellow, although you'll need to first save it and open it (in Windows) with the…
Andrei Oniga
  • 8,219
  • 15
  • 52
  • 89
2
votes
1 answer

Applying FXAA in PHP?

When I'm using PHP's GD image library to draw shapes it always shows hard edges. I've tried to use GD's imageantialias() function but that is for straight lines only. In order to solve the problem, I've searched some anti-aliasing algorithms and…
Licson
  • 2,231
  • 18
  • 26
2
votes
1 answer

PHP-GD Png Transparent Image turn black

I am using JCrop in a project of mine (the user have to crop his face) and send the coordinates & source image to a PHP handler. The flow should be the following: based on the coordinates received the handler crop the image and use imagecopy() to…
Daniela costina Vaduva
  • 1,857
  • 5
  • 20
  • 22