gd

GD lib detecting CMYK

Hi there I have some code to resize an image w/ GD and Perl sub adjust_size { my ($localfile, $ext) = @_; # need to use truecolor option to support 24 bit colors $image = GD::Image->trueColor(1); $image = new GD::Image->new($localfile); my ($w, $h) = $image->getBounds(); ... everything works properly with RGB ...

PHP: Code to check image quality/pixelation (not compression rate but real quality)?

I want to know if its possible (and how) to check for real image quality (.jpg) using the GD library. Obviously we need to check for file size, colors, image size, and number of pixels and compare between them. For example if an 1200x600px image has a size of 60kb probably its in bad quality. But if the image is in grey scale, or uses ...

PHP GD doesnt support a specifc image, any solution/workaround?

If I run $res=imagecreatefromJPEG ('http://www.theweddingoutlet.com/core/media/media.nl?id=29428&c=697473&h=8320018df7b40ec6eff8'); I get False + error : gd-jpeg: JPEG library reports unrecoverable error: (no further details). What is wrong with this specific image that makes it unsupported by GD? How can I make GD support i...

How to add cookie to request for PHP/GD imagecreatefromJPEG ?

Hello Experts, I'm using PHP GD to fetch an image from a remote server. $res=imagecreatefromJPEG ($url); I need to have a cookie set with a value along with the call to get the image. Is this possible with GD? How would I do that? Thanks ...

php gd imagesetpixel, pixels not a 1 to 1 relationship with pixels and interior model of image

<? $img_w = 800; $img_h = 600; $img = imagecreate($img_w, $img_h); $color = imagecolorallocate($img, 230, 230, 230); $imgname = "gd_img.png"; for($n=0; $n < $img_w; $n++) { plot($n , $img_h/2, imagecolorallocate($img, 200, 0, 0)); plot($n+4 , $img_h/2 + 10, imagecolorallocate($img, 0, 200, 0)...

Merging (watermark) a jpg with png while resizing the png in PHP GD

Hi everyone, I am sure I could somehow figure this out but it's just taking me way too long since I am not a PHP guy. Hopefully someone can set up the script for me in minutes... So here's what I need to do: I transmit 2 pictures from a smartphone to a webserver. These 2 images need to be merged (watermarked). They differ a little: p...

CodeIgniter creating thumbnails with one black pixel in the top left corner

Warning: I don't have much experience with CodeIgniter and I am updating a site originally create by another developer. For some reason the CodeIgniter image class is creating thumbnails with a black pixel in the top left corner. Here is an example: This only seems to happen in production (this site is being hosted on a super lame s...

how to write html on image using gd library php?

im using IMAGETTFTEXT function in php for writing text on some images.now i want to write html tags on my image,for example IMG tag. i dont know how to do that!i want help plz. here is my code : $font_file = 'times.ttf'; $font_size=15; $image_file= 'new.jpg'; $image = imagecreatefromjpeg($image_file); $font_color = imagec...

PHP GD Duplicate image from Different server

Hi there, I don't know how to do this and I was wondering if someone smart could give me an example :) I want someone to be able to post a png,jpg, or bmp image url and then id use PHP GD to duplicate the image including width and height. Could someone give me an example of this? Also id like it to support only png, jpeg, and bmp. ...

Compare 2 images in php

Comparing 2 images to see if they are both the same files are easy, threw the files MD5, but is it possible or even plausible to determine if 2 images are same by using PHP GD to get the difference of the two images. If we where to get the difference of the two, and it was all white (id assume white or even black), then we would now know...

Problem cropping an image to a perfect square with GD library

Hi, I use a class that automatically crops an image as a square based on some options. The problem is that when the image is of a certain width and height, the image is cropped but a 1px column of black pixels is added to the right of the image. I think that the problem is in the mathematics used to generate the new image size... Maybe ...

Problem to compile a C-program by GCC with GD2 library installed via MacPorts

I have successfully compiled a C-program by GCC on Mac with GD2 library installed directly from sources. Now I am trying to do that with GD2 library installed via MacPorts and have the following error message: plotgeometry.c:5:16: error: gd.h: No such file or directory plotgeometry.c: In function 'PlotGeometry': plotgeometry.c:28: erro...

Pull Remote URL for GD Generated Image in PHP

I'm generating images with PHP/GD Library for people to place on their websites. Similar to the "hit counter" services. I am not able to pull the URL from the page that the button is loaded on. The following only displays my url not theirs: $_SERVER['SERVER_NAME']; Am I going to need to pull the domain in Javascript? ...

Can anyone help me explain sourcode color histogram below using php GD

I want to take the color histogram value of sourcode below: description $ WR = array (48 reference colors r) $emin = sqrt(pow(($r - $wr[0]),2) + pow(($g - $wg[0]),2) + pow(($b -$wb[0]),2)); for($k=1;$k<48;$k++) { $e = sqrt(pow(($r - $wr[$k]),2) + pow(($g - $wg[$k]),2) + pow(($b -$wb[$k]),2)); if ($e < $emin) { $n = $k; ...

I need help compensating for the shifting of images when trying to create a grid with one image and apply it on another.

Hi I have two images of yeast plates: Permissive: Xgal: The to images should be in the same spot and roughly the same size. I am trying to use one of the images to generate a grid and then apply that grid to the other image. The grid is made by looking at the colonies on permissive plate, the plate should have 1536 colonies on it....

Making a .ico file using gd and php

Does anyone know how to make a .ico file that will work in Intenet explorer? I can't seem to get anywhere here is my gd code $im = imagecreatefromjpeg(FAVICONDIR.'normal/'.$filename ); list($width, $height) = getimagesize(FAVICONDIR.'normal/'.$filename); // get the width and height of the jpg $image_p = imagecreatetrueco...

create statistics on image (e.g. mostly used color...)

Hello, Sorry if the question is a bit vague but I'm new to gd. I'm wondering whether gd already has some built-in methods or whether PHP classes relying on gd exist that could present me with a bunch of statistics for a given image. I'm mostly interested in: Colors (nb of colors used, most used colors, even better if I can get a the n...

Emailing a dynamically created image

I need to create an image dynamically then email it to the person. Here is the image creation script: //Get the blank coupon $rImg = ImageCreateFromJPEG('coupon.jpg'); $color = imagecolorallocate($rImg, 0, 0, 0); imagestring($rImg,5,135,140,'$first_name', 'black'); imagestring($rImg,5,135,160,'$last_name', 'black'); imagestring($rImg,...

Can I programmatically determine what fonts I can use with GD?

I want to put text over an image using GD. When I use ImageTTFText($image, $fontSize, $fontRotation, 7, 22, $colorShadow, 'arial.ttf', $str); I get Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/index.php on line 17 Can I get PHP or GD to return a list of all available fonts per my s...

Can GD make text appear warped (made to look like it wraps around a curve slightly) ?

I am placing some text over an image using PHP's GD library. The background image is a ball. Ideally, the text should warp slightly to look like it is on a curved surface. It should be largest in the middle, and scale slightly smaller on each end (text is not known before hand either, but there is a maximum length of 15 chars). Is this...