joeynelson
joeynelson

Reputation: 405

PHP GD 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 created 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:

alt text http://jnjnjn.com/images/codeigniter_bad_thumb.jpg

This only seems to happen in production (this site is being hosted on a super lame shared host). Thumbnails are created just fine on my OS X dev machine and my Ubuntu machine on Slicehost.

The code is pretty boilerplate, and from what I can tell the image library doesn't have a whole lot of options to screw up.

The options look like this:

$this->Image_Resize['image_library'] = 'gd2';
$this->Image_Resize['thumb_marker'] = 'thumb_';
$this->Image_Resize['create_thumb'] = TRUE;
$this->Image_Resize['maintain_ratio'] = TRUE;
$this->Image_Resize['width'] = 200;
$this->Image_Resize['height'] = 200;

And then the image is processed like this:

$this->Image_Resize['source_image'] = 'images/news/'.$image['file_name'];
$this->image_lib->initialize($this->Image_Resize);
$this->image_lib->resize();

Has anyone run into this issue before? Google & SO searches aren't getting me anywhere. These pixels are driving me nuts.

Update: As I was afraid, this didn't have anything to do with CodeIgniter. Something is screwy with the host's GD library and they don't support anything else. It's just weird that I can't find anyone else in the world who's had this problem.

Anyway my advice is to never, ever, ever use Doteasy. They are a nightmare.

Upvotes: 0

Views: 1625

Answers (4)

someguy
someguy

Reputation: 1

.$image['file_name'];
^---- see period

Upvotes: -2

Marlon Creative
Marlon Creative

Reputation: 3846

I had the same thing, seems to happen only with PNG32 format - try exporting your image in PNG24 or PNG8 and see if that helps, worked for me.

Upvotes: 1

aron.duby
aron.duby

Reputation: 2281

I'm running into the same issue, and after some digging here's what I've come up with for my situation. I figured I would share it with everyone else incase there's something useful. Keep in mind, this is straight PHP not code ignitor, but this is one of the first responses when you do a google search.

This appears to only happen for me with a 24bit transparent png, when resized and then sharpened using imageconvolution function. As soon as I comment out the portion of code which is applying the convolution, the black pixel disappears.

Upvotes: 1

Matthew
Matthew

Reputation: 15652

If it's the host that's causing it, maybe it's their image library that's having problems. The codeigniter Image Manipulation class is really just abstracted above that level, so you can actually choose what image library to use. Find out what ones are available from your host and maybe try a different one and see if the results are the same. Possible options for the ['image_library'] are:

  1. GD
  2. GD2
  3. ImageMagick
  4. NetPBM

Image Manipulation Class - Codeigniter Documentation

Upvotes: 1

Related Questions