Imagecreatefromjpeg returns a black image after resize
<p>I have a script to resize an uploaded image, but when I use it, it just returns a black square. All error messages are pointing at this function:</p>

<pre><code>function resizeImage($image,$width,$height,$scale) {
    $newImageWidth = ceil($width * $scale);
    $newImageHeight = ceil($height * $scale);
    $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
    $source = imagecreatefromjpeg($image);
    imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height);
    imagejpeg($newImage,$image,90);
    chmod($image, 0777);
    return $image;
}
</code></pre>

<p>My error logs:</p>

<pre><code>PHP Warning:  imagecreatefromjpeg() [&lt;a href='function.imagecreatefromjpeg'&gt;function.imagecreatefromjpeg&lt;/a&gt;]: gd-jpeg: JPEG library reports unrecoverable error
PHP Warning:  imagecreatefromjpeg() [&lt;a href='function.imagecreatefromjpeg'&gt;function.imagecreatefromjpeg&lt;/a&gt;]: 'img/[hidden].jpg' is not a valid JPEG file
PHP Warning:  imagecopyresampled(): supplied argument is not a valid Image resource
</code></pre>
