gdlib

Find JPEG resolution with PHP

Calling all PHP gurus! I understand that you can use getimagesize() to get the actual pixel height and width of an image in PHP. However, if you open an image in photoshop and look at the image size dialog, you notice that there is a resolution value that determines the print size of the image. Given an arbitrary jpg image file, I need...

Generating thumbnails using PHP causes bad image quality

$sourcePath = 'images/'; // Path of original image $sourceUrl = ''; $sourceName = 'photo1.jpg'; // Name of original image $thumbPath = 'thumbs/'; // Writeable thumb path $thumbUrl = 'thumbs/'; $thumbName = "test_thumb.jpg"; // Tip: Name dynamically $thumbWidth = 100; // Intended dimension of thumb // Beyond this point is simply code. $s...

set background color for php gdlib imagerotate and imagecopy

I'm using PHP 5 GD Lib to do some graphic manipulations, and I can't find a way to get around the black background that shows up when you rotate an image or copy an image to another (larger) image. Assuming that I am working with a jpeg file, which of course is not transparent, how can I rotate the image using gd lib and end up with a ...

How can I prevent GD from running out of memory?

I'm not sure if memory is the culprit here. I am trying to instantiate a GD image from data in memory (it previously came from a database). I try a call like this: my $image = GD::Image->new($image_data); $image comes back as undef. The POD for GD says that the constructor will return undef for cases of insufficient memory, so that...

perl GD draw a shape

I am using GD library to draw an image. Image I am drawing is this http://i39.tinypic.com/apd1f7.png I am able to manage most of the image however, I do not know how to draw the red portion of the image. The red portion has a sideways triangle on both sides...how can I manage that using the GD lib? ...

what causes imagecreatetruecolor() to fail?

i am sure that my gdlib is enabled since the imagecreafromjpeg() function precedes the part where i call the imagecreatruecolor() and there's no error generated from that however the script breaks on the part (or rather fails with no error message and simply returns false) where imagecreatruecolor() is called.. how can i find the cause ...

How would I skew an image with GD Library?

I want to skew an image into a trapezoidal shape. The left and right edges need to be straight up and down; the top and left edges need to be angular. I have no idea what the best way to do this is. I'm using GD Library and PHP. Can anyone point me in the right direction? Thanks, Jason ...

PHP image creation from hex values in database

I've got the code below to pull hex values from a database and create an image of that colour. There's over a thousand values, so it's looping to create an image for them all. It seems to work fine except it just keeps overwriting the first image (0.jpg) instead of creating new ones 0.jpg, 1.jpg 2.jpg etc. Any idea where I'm going wrong?...

Codeigniter and uploading zip files

Hello, I am currently building a backend to a site using the codeigniter framework, I have hit a bit of a problem, I needing a way to allow the user to upload a zipped folder of images, on completing the form, zipped folder must be unzipped, and the files need to be moved to a folder else where on the server, have thumbnail version of e...

Codeignter and GD image manipulation

Hello, In codeigniter I am creating an application that allows the user to upload multiple files in one go, to this I am using this library, http://www.mitesdesign.com/blog/open-source/multi-upload-jquery-code-igniter My question is if there are multiple images that have been upload how do I define the source image in the $config, so...

PHP image color analysis with transparency

I am currently working on an application that needs to analyse a number of images and figure out what color they're closest to. Therefore I found a code snippet that does exactly that: function analyzeImageColors($im, $xCount =3, $yCount =3) { //get dimensions for image $imWidth =imagesx($im); $imHeight =imagesy($im); ...

problem with image upload class not creating img

take a look at my class below when i try to upload an image the default keeps being called within the switch statement. i cant see why it goes to that. <?php class uploadimg2folder { //create thumbnail function createImage($fieldName,$width,$height) { $thumb = $_FILES['$fieldName']['tmp_name']; $path = "../uploads/".rand(0,1000); ...

How to use/link gdLibrary (libgd) with MS Visual C++ (e.g. 2008 Express Edition)? Getting LNK2019 errors...

Hi all, I have to use the gdLibrary (http://www.libgd.org) in a C++ App on MS Windows XP Prof. SP3 32bit - and I'm trying and googleing for two days now without success. Does anyone of you use libgd with MS VC++ 200x EE? My problem: It has to to compile with MS Visual C++ (e.g. the 2008 Express Edition - fixed 3rd party condition)... b...

Detect the location of an image within a larger image.

How do you detect the location of an image within a larger image? I have an unmodified copy of the image. This image is then changed to an arbitrary resolution and placed randomly within a much larger image which is of an arbitrary size. No other transformations are conducted on the resulting image. Python code would be ideal, and it...

Problem with imagecreatefrompng (PHP)

Hey guys, in one of my PHP projects, imagecreatefrompng complains, that the image "is not a valid PNG file". Warning: imagecreatefrompng() [function.imagecreatefrompng]: '/.../...png' is not a valid PNG file in /.../...php on line ... I'm pretty sure, the file is valid, because I can open it in any program. So I was wondering what e...

Using PHP to recreate something similar to VistaPrint / CafePress / Zazzle. Any Ideas?

I am working on a website in which the client wishes to have users upload background images to a printable design, crop to size, add text. Do this to multiple pages then generate a pdf of the 'book' I am running into the following issues/questions and just need to see where I can start Are there any PHP developer packages that can do ...

When dealing with GD Library unwantedly altering colors

I'm merging multiple small images into a rectangular mosaic.. When dealing with a small number of source images it turns out fine: grab.by/2Y4W (sorry, I'm new and am not allowed to post multiple hyperlinks) But when dealing with a larger number of sources it turns out a sepia like effect: http://grab.by/2Y4P Is there any technique I ...

In CakePHP, whats the best Image Upload / Resizing component you've used?

Im looking for somthing that can belong to many many models and, hopfully, has all the resizing functionality built in too. Wondering if there's any good suggestions out there, I don't want to pick the wrong one. Or is it just worth building my own? ...

echo is not working in my php-gdlibrary page

Hi, i am trying to create an ellipse using php gd library; also i want to display something under the ellipse. but the usual echo will not work with this. somebody please help me to find the reason and suggest a solution. this is my php code header('Content-type: image/png'); $handle = imagecreate(100, 100); $background = imagecoloral...

Choosing suitable background / foreground colour using PHP

I am looking to find a why to calculate a suitable background colour and a colour for the text that would go over the top, obviously I need to take into account readability and accessibility. I would need to pick the two colours from the array, the colours are stored in their hex representations. #CC9966 #996633 #FFCC99 #CCCC99 #000000...