I have been trying to simply resize an image that is stored on my webhost for about a week now. Every example i try to implement does not work, even if I copy and paste them directly.
I developed my own code for it from scratch, and after running, I get a resized image saved on my webhost, but the image is completely black. I cannot figure out why.
Here is my code:
---------------------------------------------------
$oldsize=getimagesize($uploadFilename);
$oldwidth=$oldsize[0];
$oldheight=$oldsize[1];
$scale=$oldwidth/50;
$new_width=$oldwidth/$scale;
$new_height=$oldheight/$scale;
$imageResized = imagecreatetruecolor($new_width, $new_height);
$imageTmp = imagecreatefromjpeg ($uploadFilename);
imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $oldwidth, $oldheight);
imagejpeg($imageResized, $uploadsDirectory.'resized'.$now.'.jpg', 85);
// Free up memory
imagedestroy($imageResized);
---------------------------------------------------
Any help would be greatly appreciated.
I developed my own code for it from scratch, and after running, I get a resized image saved on my webhost, but the image is completely black. I cannot figure out why.
Here is my code:
---------------------------------------------------
$oldsize=getimagesize($uploadFilename);
$oldwidth=$oldsize[0];
$oldheight=$oldsize[1];
$scale=$oldwidth/50;
$new_width=$oldwidth/$scale;
$new_height=$oldheight/$scale;
$imageResized = imagecreatetruecolor($new_width, $new_height);
$imageTmp = imagecreatefromjpeg ($uploadFilename);
imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $oldwidth, $oldheight);
imagejpeg($imageResized, $uploadsDirectory.'resized'.$now.'.jpg', 85);
// Free up memory
imagedestroy($imageResized);
---------------------------------------------------
Any help would be greatly appreciated.