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
1
vote
1 answer

Testing image-rendering PHP script on shared hosting with JMeter

I'm testing two versions of the same script. Each script does the same operation but they differ in how they output the result. Each script: Loads a local image using imagecreatefrompng() Adds text to image using imagettftext() The first script…
Alex E
  • 735
  • 2
  • 7
  • 15
1
vote
1 answer

Using Google Font in PHP GD

I am trying to use a custom font in an image made with PHP GD. I intend to call int imageloadfont(string $file), but I'm not sure what $file to give if I want to get a Google Font directly from their website. Do I need to download the font or is…
SteeveDroz
  • 6,006
  • 6
  • 33
  • 65
1
vote
2 answers

How to extract possibly corrupt image blobs from a mysql database in PHP and save to files

I have a database table which contains receipt images, encoded into BLOB data in PHP. The table has the following columns and data: id | ownerid | file | filename | size | type |…
Tim Ogilvy
  • 1,923
  • 1
  • 24
  • 36
1
vote
2 answers

Unable to use imagecopyresized in amazon ec2 linux server

I am trying to upload and re-size images on amazon linux server with the below code. It works fine in my local system. But not on server. I get Server error 500. Error occurs only on this line if(!imagecopyresized($new_image, $old_image, 0, 0, 0,…
1
vote
0 answers

I get the error 'imagettfbbox() Unable to find a CharMap that I can handle' when trying to generate text in PHP 5.6

I've been trying to use the following PHP code to generate a imagettfbbox: $font_path = "/var/www/lib/fonts/Arial.ttf"; $rect = imagettfbbox(10,0,$font_path,"Hello world!"); However each time I try I get the following error: Warning (2):…
1
vote
1 answer

adding multiple pngs to image php

I am adding a line of text onto an image. Is it possible to overlay multiple lines (line2.png & line3.png) onto the same image? $stamp = imagecreatefrompng('img/line1.png'); $im = imagecreatefromjpeg('tom.jpg'); // Set the margins for the stamp and…
LeBlaireau
  • 17,133
  • 33
  • 112
  • 192
1
vote
1 answer

Can't use variable outside function even after setting it global

I have made a script to generate thumbnails using PHP's GD library. The thing is that the original images are in their respective directories that are assigned to 'gallery/'.$section;and the thumbs will go in the directory 'gallery/thumbs/'.$section…
Nishant Dixit
  • 543
  • 1
  • 4
  • 12
1
vote
1 answer

PHP - Image editing with jQuery ajax not working

I am trying to add some text on my image with jQuery ajax but getting some strange text on ajax response and not getting proper image. jQuery Ajax Code: $(document.body).on('click', '.certificate_tab .tab-content li a' ,function(){ var data_did…
Mr.Happy
  • 2,639
  • 9
  • 40
  • 73
1
vote
1 answer

PHP Convert POST image to PNG

I am trying to convert a JPG (well any image) to PNG. I have an HTML form that posts the image just fine to the server. I need to rename that file and also convert it to PNG. Later in my code after I do a related table database insert I rename the…
mreynol
  • 309
  • 3
  • 17
1
vote
2 answers

PHP GD Set image behind transparent image

I need to put one image behind another image which is transparent. Another way of explaining this is changing the priority of what is shown first. Perhaps a layer? My code puts background (bg.png) on top/in front of the transparent image…
notperfect
  • 11
  • 2
1
vote
0 answers

How to undo image_filter from php gd?

I am using the following code. $im = imagecreatefrompng('1.png'); imagefilter($im, IMG_FILTER_GRAYSCALE); imagefilter($im, IMG_FILTER_CONTRAST, -40); .... imagedestroy($im); Now, I have to create the image again to apply different filter. $im =…
Mahesh
  • 1,503
  • 3
  • 22
  • 33
1
vote
1 answer

Image Color Change After Watermark Apply in PHP

Developed Watermark Script,but on adding water mark the image color changes. // merge the source image and the watermark imagecopy($image, $watermark, $watermark_pos_x, $watermark_pos_y, 0, 0, imagesx($watermark), imagesy($watermark)); Change…
Flexforce PRO
  • 49
  • 1
  • 1
  • 8
1
vote
1 answer

Recognizing the Serbian Alphabet in PHP GD

I am trying to use some siberian alphabet name with PHP gd, but each time, I am getting error with ambigious letter. Below is my code :- function properText($text){ $text = mb_convert_encoding($text, "HTML-ENTITIES", "UTF-8"); $text…
John Cargo
  • 1,839
  • 2
  • 29
  • 59
1
vote
1 answer

Get stream from imagecopyresampled

I need to create thumbnails from blob and stored in database, so I have the following function function createSquareImage($imgResource, $square_size = 96) { // get width and height of original image $originalWidth =…
Cristhian Boujon
  • 4,060
  • 13
  • 51
  • 90
1
vote
1 answer

circleci: Fatal error: Call to undefined function imagettftext()

This post is meant to help those using CircleCI as current posts on SO just say "recompile with freetype" and don't provide any details for CircleCI. Our unit tests use PHP GD and the PHP binary on the circleci servers has not been compiled with…
redgeoff
  • 3,163
  • 1
  • 25
  • 39