I was having an issue with only certain random/jpeg files with the functions imagecreatefromjpeg imagecreatetruecolor and other related ones.
This issue was annoying basically it seems like a libgd issue/bug with newer versions of PHP and it was difficult to trace-out. One very useful thing that helped me was using "php-cgi" and passing the query string as an argument eg:
php-cgi images.php source=IMG.jpg (that way you get all the error messages wh........
error while loading shared libraries: libgd.so.2: cannot open shared object file: No such file or directory
Solution Install gd:
yum install gd
After that whatever you are compliing should be happy.........