Ok, I have this function that I used to resize images when they're uploaded, right. Anyways, the 100x1000 resizing works, perfect. Same code, just change the $forcedwidth to 400, and the entire image is saved as black and white. Code is as followed:
function resizeimagejpg($forcedwidth, $forcedheight, $sourcefile, $destfile) {
$g_srcfile = $sourcefile;
$g_dstfile = $destfile;
$g_fw = $forcedwidth;
$g_fh = $forcedheight;
if (file_exists($g_srcfile)){
$g_is=getimagesize($g_srcfile);
if (($g_is[0]-$g_fw)>=($g_is[1]-$g_fh)) {
$g_iw=$g_fw;
$g_ih=($g_fw/$g_is[0])*$g_is[1];
} else {
$g_ih=$g_fh;
$g_iw=($g_ih/$g_is[1])*$g_is[0];
}
$img_src = imagecreatefromjpeg($g_srcfile);
$img_dst = imagecreate($g_iw,$g_ih);
imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih, $g_is[0], $g_is[1]);
imagejpeg($img_dst, $g_dstfile, 100);
imagedestroy($img_dst);
return true;
} else return false;
}
I am using is like this (ignore the Y=1000, we want all images to have the same X, not Y):
resizeimagejpg(100,1000,$path."plates/1001_t.jpg",$path."plates/2.jpg");
resizeimagejpg(400,1000,$path."plates/1001_t.jpg",$path."plates/2_h.jpg");
Of course, it's not quite the same, more variables are used, but you get the point. Any help on this would greatly be appreciated, thanks.