gd

Efficient JPEG Image Resizing in PHP

What's the most efficient way to resize large images in PHP? I'm currently using the GD function imagecopyresampled to take high resolution images, and cleanly resize them down to a size for web viewing (roughly 700 pixels wide by 700 pixels tall). This works great on small (under 2 MB) photos and the entire resize operation takes less...

How do i resize and convert an uploaded image to a PNG using GD

I want to allow users to upload avatar-type images in a variety of formats (GIF,JPEG,PNG at least), but to save them all as PNG database BLOBs. If the images are oversize, pixelwise, i want to resize them before DB-insertion. What is the best way to use GD to do the resizing and PNG conversion? Edit: Sadly, only GD is available on the ...

Embedding IPTC image data with PHP GD

I'm trying to embed a IPTC data onto a JPEG image using iptcembed() but am having a bit of trouble. I have verified it is in the end product: // Embed the IPTC data $content = iptcembed($data, $path); // Verify IPTC data is in the end image $iptc = iptcparse($content); var_dump($iptc); Which returns the tags entered. However when I...

Can PNG image transparency be preserved when using PHP's GDlib imagecopyresampled?

The following PHP code snippet uses GD to resize a browser-uploaded PNG to 128x128. It works great, except that the transparent areas in the original image are being replaced with a solid color- black in my case. Even though imagesavealpha is set, something isn't quite right. What's the best way to preserve the transparency in the res...

PHP GD, imagecreatefromstring( ); how to get the image dimensions?

Normally I used imagecreatefromjpeg and then getimagesize(), but with firefox 3 I need to go round this different. So now im using imagecreatefromstring( ), but how do I retreive the images dimesions now ? ...

Generated image using PHP and GD is being cut off

This is only happening on the live server. On multiply development servers the image is being created as expected. LIVE: Red Hat $ php --version PHP 5.2.6 (cli) (built: May 16 2008 21:56:34) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies GD Support => enabled GD Version => bundled...

How to perform seam carving on an image using PHP's GD library?

I am working on a project that resizes images using PHP's GD library. I would like to be able to add the option to use seam carving to resize images but don't want to require something like ImageMagick (which can do seam carving with its liquid rescale feature) to accomplish this. Since there are no built-in seam carving functions in GD...

PHP function imagettftext() and unicode

I'm using the PHP function imagettftext() to convert text into a GIF image. The text I am converting has Unicode characters including Japanese. Everything works fine on my local machine (Ubuntu 7.10), but on my webhost server, the Japanese characters are mangled. What could be causing the difference? Everything should be encoded as UTF-8...

BiCubic Shaper PHP Image Resize

Photoshop has that great: BiCube Shaper option for resizing. However I cannot find an equivalent. I've seen various code using GD that used imagecopyresampled and custom unsharp mask, but no where near the quality I am expecting. Any help? ...

PHP Replace Images with GD Library Resampled Images in Joomla

I am the tech intern for an online independent newspaper, and the writers on the staff are not tech-savvy. They don't quite understand how web pages work, and often they upload and include images straight from their digital cameras, or scanned from original media. These images become a burden when there are 10 images on the front page ...

Making an Image Greyscale with GD Library

My mission is to create a little app where you can upload a picture, and the app will turn it into ASCII art. I'm sure these exist already but I want to prove that I can do it myself. This would involve taking an image, making it greyscale and then matching each pixel with a character depending on how dark the picture is and how full th...

How do I resize pngs with transparency in PHP?

I'm attempting to resize pngs with transparent backgrounds in PHP and the code samples I've found online don't work for me. Here's the code I'm using, advice will be much appreciated! $this->image = imagecreatefrompng($filename); imagesavealpha($this->image, true); $newImage = imagecreatetruecolor($width, $height); // Make a new trans...

Can I detect animated gifs using php and gd?

Hi all, I'm currently running into some issues resizing images using GD. Everything works fine until i want to resize an animated gif, which delivers the first frame on a black background. I've tried using getimagesize but that only gives me dimensions and nothing to distinguish between just any gif and an animated one. Actual resizi...

Auto Font Size For Text (GD via PHP)

There is a space of x*y for text to go on $im (GD Image Resource) how can I choose a font size (or write text such that) it does not overflow over that area? ...

Having problem with GD thumbnail generator [PHP]

Well I'm using PHP to generate thumbnails. The problem is that I have a set width and height the thumbnails need to be and often times the images are stretched. What I'd like is the image to remain at the same proportions and just have black filler (or any color) either on the left & right for tall images or top & bottom for wide image...

How does libgd stack up against the competition?

I'm curious as to what type of experiences people have had with libgd. I am looking for an alternative to GDI+ (something faster). I have tried ImageMagick, but can't get the performance out of it i need. I have heard that ligd is fast, but less feature rich, and that ImageMagick is slow, but more feature rich. I only need very simple ...

Why this PHP code not generating a valid PNG image?

$c = $record['corrects']; $i = $record['incorrects']; if($c == 0 && $i == 0) { $image = imagecreatetruecolor(200,80); $white = imagecolorallocate($image,255,255,255); $red = imagecolorallocate($image,255,0,0); imagefilledrectangle($image,0,0,199,79,$white); $text = 'Quiz cancelled!'; $box = imageftbbox(10,0,'verdana.ttf',$text...

sIFR or FLIR?

I've recently bumped into facelift, an alternative to sIFR and I was wondering if those who have experience with both sIFR and FLIR could shed some light on their experience with FLIR. For those of you who've not yet read about how FLIR does it, FLIR works by taking the text from targeted elements using JavaScript to then make calls to ...

PHP Pull Image And Display

I have a PHP file which I have used mod rewrite to make a .jpg extension. I want to grab an image from a url example: http://msn.com/lol.gif take the data and then display it in my .jpg with jpeg headers, so as far as the user is concerned it is a normal image. Is this possible and if so can anyone give me some pointers? ...

How can I modify this image manipulation function done in codeigniter to be more efficient

I think this function isn't as efficient as it should be. I'd appreciate some suggestions on how I can structure it to be faster and take less memory. This is what the code does: checks to see if the image was uploaded add details about it (tags, name, details) to the database if the variable $orientation was set, rotate the image if...