Forum Moderators: coopster

Message Too Old, No Replies

phpthumb strange black line appearing occasionally

         

terrybarnes

11:26 pm on Feb 17, 2009 (gmt 0)

10+ Year Member



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)

WebmasterWorld Senior Member 10+ Year Member



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)

10+ Year Member



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:

<img src="../phpthumb.php?src=cms/[image]&q=60&wl=640&hp=500">

whoisgregg

7:10 pm on Feb 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You would need to look in the source code of phpthumb.php to find where it handles resizing.