Questions tagged [gd]

GD Library is used to dynamically create and manipulate image files.

GD is an acronym for GIF Draw, GD is an open source code library for the dynamic creation of images by programmers. GD is written in , and "wrappers" are available for Perl, PHP and other languages. GD creates , and images, among other formats. GD is commonly used to generate charts, graphics, thumbnails, and most anything else, on the fly. While not restricted to use on the web, the most common applications of GD involve website development.

2961 questions
42
votes
8 answers

imagecreatefrompng() Makes a black background instead of transparent?

I make thumbnails using PHP and GD library but my code turn png transparency into a solid black color, Is there a solution to improve my code? this is my php thumbnail maker code: function cropImage($nw, $nh, $source, $stype, $dest) { $size =…
Emily
  • 905
  • 3
  • 10
  • 13
41
votes
4 answers

Install GD library and freetype on Linux

I'm trying to use imagefttext. And I need to have GD library and/or freetype installed. I'm new to this kind of stuffs, How can I install GD library and freetype in Linux ?
C A Mc
  • 449
  • 1
  • 4
  • 7
41
votes
7 answers

Detect main colors in an image with PHP

I am trying to replicate the functionality that Dribbble.com does with detecting the predominant colors in an Image. In the image below you can see a screenshot from Dribbble.com that shows the 8 predominant colors in the image to the left. Here is…
JasonDavis
  • 48,204
  • 100
  • 318
  • 537
40
votes
3 answers

I have a base64 encoded png, how do I write the image to a file in PHP?

What's the proper way in PHP to create an image file (PNG), when I have the base64 encoding? I've been playing around with: file_put_contents('/tmp/'. $_REQUEST['id'].'.png', $_REQUEST['data']); do I need to decode? should I be using the gd…
mmattax
  • 27,172
  • 41
  • 116
  • 149
40
votes
9 answers

Creating a thumbnail from an uploaded image

I'm wanting to create a thumbnail from a user uploaded image so the image doesn't look squashed. But also would like a copy of the original image.. So I would like the original image to send the original image to my server and also create a thumb…
dave
  • 1,009
  • 5
  • 15
  • 26
38
votes
6 answers

How to install Imagick/imagemagick PHP extension on windows 7

How to install image magic in Windows 7. I followed these instruction To install IMagick on Windows XP (php 5.2.x) download and install ImageMagick-6.5.8-7 Q16-windows-dll.exe http://www.imagemagick.org/download/binaries/…
DEVOPS
  • 18,190
  • 34
  • 95
  • 118
35
votes
9 answers

Compare 2 images in PHP

Comparing two images to see if they are both the same files is easy: throw the files MD5. But is it possible or even plausible to determine if two images are same by using PHP GD to get the difference of the two images? If we were to get the…
Joseph
  • 383
  • 2
  • 4
  • 5
34
votes
3 answers

PHP GD: How to get imagedata as binary string?

I'm using a solution for assembling image files to a zip and streaming it to browser/Flex application. (ZipStream by Paul Duncan, http://pablotron.org/software/zipstream-php/). Just loading the image files and compressing them works fine. Here's the…
Cambiata
  • 3,705
  • 9
  • 35
  • 45
31
votes
6 answers

What's the math behind CSS's background-size:cover

I'm creating an "image generator" where users can upload an image and add text and/or draw on it. The outputted image is a fixed size (698x450). On the client side, when the user uploads their image it is set as the background of a div that's…
antriver
  • 848
  • 1
  • 10
  • 21
30
votes
2 answers

Heroku - how to enable gd on heroku php application?

Heroku said: The following built-in extensions have been built “shared” and can be enabled through composer.json (internal identifier names given in parentheses): But it doesn't give an example, I tried with the following composer.json: { …
Jeff Tian
  • 5,210
  • 3
  • 51
  • 71
30
votes
3 answers

How to find out if I have gd library or imagemagick installed?

This might seem a really stupid question. I am new php image processing. I assume there are only two imageprocessing libraries in php. They are called GD/GD2 and Imagemagick. How do I know which I have installed? or if I have installed any? I have…
odbhut.shei.chhele
  • 5,834
  • 16
  • 69
  • 109
30
votes
8 answers

Crop whitespace from image in PHP

Is it possible to remove the whitespace surrounding an image in PHP? NOTE: to clarify I mean something like photoshops trim feature. Thanks.
usertest
  • 27,132
  • 30
  • 72
  • 94
29
votes
8 answers

How do I install GD on my windows server version of PHP

I am running Windows Server 2003 and need to install a version of GD. Can anyone point out some instructions or advice?
Mazatec
  • 11,481
  • 23
  • 72
  • 108
29
votes
5 answers

Combine 2-3 transparent PNG images on top of each other with PHP

I am working on a custom avatar system for a project, but I have never really done much with the image side of PHP. I assume I need to use GD in some way, but I have no idea where to even start. Basically, there are a bunch of pre-made transparent…
James Simpson
  • 13,488
  • 26
  • 83
  • 108
27
votes
2 answers

Convert GD output to base64

Well, my question is very simple, i just wanna convert the output of imagepng/imagejpg to base64, how i can do this ? the correctly way is with capturing output buffer ? thanks.
user862010