phpthumb strange black line appearing occasionally
terrybarnes
11:26 pm on Feb 17, 2009 (gmt 0)
I use phpthumb in a basic cms I set up for my client but every now and again it add a 1 pixel horizontal black line to the bottom of the image? I've tried re-uploading it but still the same weird problem.
Any ideas?
whoisgregg
5:19 pm on Feb 18, 2009 (gmt 0)
Probably a rounding error in the resizing math. The example code on the imagecopyresampled manual page [php.net] even has the error... Basically, when you create the image it always uses an integer width and height, but when you resize one image buffer into another, you can actually provide float/decimal width and heights.
Just use ceil() when appropriate... you'll end up "losing" a row or column of pixels here or there, but that's better than the mysterious black line. :)
terrybarnes
5:44 pm on Feb 20, 2009 (gmt 0)
Hi, thanks for replying - can you please let me know how to use the ceil() code you mentioned? I'm currently using this to bring in the image using phpthumb: