I corrected in lower code.
function qa_image_constrain_data($imagedata, &$width, &$height, $size)
/*
Given $imagedata containing JPEG/GIF/PNG data, constrain it proportionally to fit in $size (square)
Return the new image data (will be a JPEG), and set the $width and $height variables
*/
{
$inimage=@imagecreatefromstring($imagedata);
if (is_resource($inimage)) {
$inwidth=imagesx($inimage);
$inheight=imagesy($inimage);
$outwidth=$inwidth;
$outheight=$inheight;
// always call qa_gd_image_resize(), even if the size is the same, to take care of possible PNG transparency
qa_image_constrain($outwidth, $outheight, $size);
qa_gd_image_resize($inimage, $outwidth, $outheight);
// add [start]
$width=$outwidth;
$height=$outheight;
// add [end]
}
if (is_resource($inimage)) {
$imagedata=qa_gd_image_jpeg($inimage);
imagedestroy($inimage);
return $imagedata;
}
return null;
}