Hey all,
Thanks for the great help with the uploading; I've just gone and revised *everything*. So now, they upload. Yay.
AND they resize, too! :tu:
...but they're black boxes.
Here's my code:
Now, I know it has something to do with imagecreatetruecolor because PHP.net says it makes a black image with those dimensions, then you "draw" over it (I assume) by doing imagecreatefromjpeg after that, then resample with the imagecopyresampled function at the end.
These come more directly from PHP.net than my last code snippets; so it's more accurate... yet I still get black boxes once resized.
ANY help appreciated. I promise.
-Matt
Thanks for the great help with the uploading; I've just gone and revised *everything*. So now, they upload. Yay.
AND they resize, too! :tu:
...but they're black boxes.
Here's my code:
PHP:
// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($uploadfile2);
if ($image === false) { die ('Unable to open image'); }
if (!imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $imgsize[0], $imgsize[1]))
{
die("Error");
}
else
{
imagejpeg($image_resized, $uploadfile2, 100);
}
Now, I know it has something to do with imagecreatetruecolor because PHP.net says it makes a black image with those dimensions, then you "draw" over it (I assume) by doing imagecreatefromjpeg after that, then resample with the imagecopyresampled function at the end.
These come more directly from PHP.net than my last code snippets; so it's more accurate... yet I still get black boxes once resized.
ANY help appreciated. I promise.
-Matt








