Hey Guys-
I'm resizing an image using GD. This was the best place I could find to post this. My images come out totally weird and lacking in colors. I dont know whether it's my code or my GD library.
Here's the code I'm using, to create one medium sized image and one thumbnail:
function MBResizeImg() {
$thisImage = "tmp/" . uniqid("");
move_uploaded_file($_FILES['propimg']['tmp_name'],$thisImage);
$imageInfo = getimagesize($thisImage);
$src_width = $imageInfo[0];
$src_height = $imageInfo[1];
$src_img = imagecreatefromjpeg($thisImage);
$dst_img = imagecreate(300,225);
imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, 300, 225, $src_width, $src_height);
imagejpeg($dst_img, $thisImage);
$imageBin[1] = addslashes(file_get_contents($thisImage));
$dst2_img = imagecreate(136,102);
imagecopyresized($dst2_img, $src_img, 0, 0, 0, 0, 136, 102, $src_width, $src_height);
imagejpeg($dst2_img, $thisImage);
$imageBin[2] = addslashes(file_get_contents($thisImage));
return $imageBin;
}
Thanks in advance for any suggestions you may have!
[edit]Yes, I am really trying to return the raw image binary, not write it to a file. The images are retreived from an SQL database; it's a low-volume site with a low number of images, and this is the easiest way for the client to manage them regardless of server setup.