gdlib

PHP Color Manipulation

I am currently looking into color manipulation / selection etc and have come across the following piece of code. I was wondering of someone could tell me what the following piece of code is doing and break it down for me thanks! $newVal = round(round(($rgb['red'] / 0x33)) * 0x33); In particluar what is the 0x33 Thanks in adavnce ...

php gdlib angle problem

I'm using php gd lib 5.2.13 and tried to make a picture with imagettftext ($image, $color and $font are defined of course). imagettftext($image, 12, 90, 10, 20, $black, $font, "This.is_a test 123"); //image, font size, angle, x value, y value, color, font, text As you can see I want the angle to be 90°. The problem is that the text is...

In PHP, imagepng() accepts a filter parameter. How do these filters affect the function's output?

How do these filters affect the output of imagepng() in PHP? PNG_NO_FILTER PNG_FILTER_NONE PNG_FILTER_SUB PNG_FILTER_UP PNG_FILTER_AVG PNG_FILTER_PAETH PNG_ALL_FILTERS The documentation simply says, "A special PNG filter, used by the imagepng() function" for each of them. It seems that using PNG_NO_FILTER will reduce the filesize of...

How can i calculate where the non transparent part of an image starts and ends with PHP?

Hi people, Here's a question: let's say we have a png image 200x200 that is transparent and there is a shape that starts at x,y (50,50) and has a width of 50px and height 20px. Is there any way with PHP (gdlib or imagemagick) that i could get the position of the shape relative to the image size? For the example given the script should ...

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 ...

PHP+GD: imagecopymerge not retaining PNG transparencies

I have two PNG files, "red.png" and "blue.png"; they are both mostly transparent, but there is a few pixels of red or blue splotches in various places. I want to make a PHP script that merges the two; it should be as simple as something like: $original = getPNG('red.png'); $overlay = getPNG('blue.png'); imagecopymerge($original, $over...

PHP Image Resize Classes

My website allows uploading of images. I limit images to 10 megapixel or less JPEG images, all images get stored in a directory. Now I want the images resized on the fly and I am looking for a PHP class/library that can do that for me. While I can write (and I have written) gd-library code for resizing images I want something that's stab...

Estimate required memory for libGD operation

Before attempting to resize an image in PHP using libGD, I'd like to check if there's enough memory available to do the operation, because an "out of memory" completely kills the PHP process and can't be catched. My idea was that I'd need 4 byte of memory for each pixel (RGBA) in the original and in the new image: // check available me...

Resize image using PHP if it's too small

I'm allowing user uploads, and I want to scale their images up if they're too small (low quality is a non-issue). I need to make the smallest side become 150px and have the other dimension scale up to keep the aspect ratio. I need to make it work for .jpg, .gif and .png files. Any pointers would be greatly appreciated, I'm struggling to...

Captcha Help please ?

I got this simple captcha script from online. I like it, and I edited it to suit my site, but was wondering if someone could edit it to add some random lines on the captcha itself as it is somewhat too simple. I did find tutorials on how to do it but it was not working for me in. Here is the simple captcha script; I would love to modif...

OpenSource Script To Crop, Resize, Thumbnail, Convert Images.

I want to have a section where people after uploading their profile information can draw a square around the part that they want from the picture to be the thumbnail and all that. I'm wondering if there is anything out their with the client side (javascript) and server-side (php) so that I don't have to start from scratch! ...

Resizing images with GD Library - setting start x & y coordinates

Okay, I'm over my head and fumbling in the dark here. I'm trying to modify a class to crop an image by setting the height, width and starting x & y positions. The class I'm using handles everything but the starting x & y, and try as I might all I can do is blow it up. Can someone help me with this?? the relevant function is listed be...

Help to add error checking to this function

I need to add some error checking to this function to make sure that the imagegif() and imagecolorset() functions are successful. The usual cause for failure is a permissions issue where the spot2.gif file is not writable. However, when I change the spot2.gif to read only, a condition that should trigger the "else" conditions, the echo...

Is there a way to output html div to an image using php?

Hi. I have a div on my page which I want to output to a jpeg file. Is this possible using PHP? I know there's the GD library for creating images in PHP but I'm not sure if it can do what I want. Because I also want to put a barcode on the image (I used a jQuery plugin to do this on the html page) . Is this possible (if it's possible ...