/**
  * Resized a given image
  * @param string file (path) pointing to the image
  * @param int width to resize to
  * @param int height to resize to
  * @return Image resized image
  */
 function generate_resized_image($file, $width, $height)
 {
     $image_info = getimagesize($file);
     // Make sure, the image does not become bigger than the original
     if ($width > $image_info[0]) {
         $width = $image_info[0];
     }
     if ($height > $image_info[1]) {
         $height = $image_info[1];
     }
     if ($width && $height) {
         // Final dimensions are already set
     } else {
         if ($width) {
             // Width set
             $height = round($width / ($image_info[0] / $image_info[1]));
         } else {
             if ($height) {
                 // Height set
                 $width = round($height * ($image_info[0] / $image_info[1]));
             } else {
                 // Nothing set
                 $width = $image_info[0];
                 $height = $image_info[1];
             }
         }
     }
     $create_function_name = wpws_ImageUtils::get_create_function_name($file);
     $original_image = $create_function_name($file);
     $resized_image = imagecreatetruecolor($width, $height);
     $white = imagecolorallocate($resized_image, 255, 255, 255);
     imagefill($resized_image, 0, 0, $white);
     imagesavealpha($resized_image, true);
     imagealphablending($resized_image, true);
     imageantialias($resized_image, true);
     imagecopyresampled($resized_image, $original_image, 0, 0, 0, 0, $width, $height, $image_info[0], $image_info[1]);
     imagedestroy($original_image);
     return $resized_image;
 }