/** * wp_crop_image() - Crop an Image to a given size. * * @package WordPress * @internal Missing Long Description * @param int $src_file The source file * @param int $src_x The start x position to crop from * @param int $src_y The start y position to crop from * @param int $src_w The width to crop * @param int $src_h The height to crop * @param int $dst_w The destination width * @param int $dst_h The destination height * @param int $src_abs If the source crop points are absolute * @param int $dst_file The destination file to write to * @return string New filepath on success, String error message on failure */ public String wp_crop_image( Object src_fileObj, int src_x, int src_y, int src_w, int src_h, int dst_w, int dst_h, boolean src_abs, String dst_file) { Object src = null; int dst = 0; String src_file; // Modified by Numiton if (is_numeric(src_fileObj)) { // Handle int as attachment ID src_file = strval( getIncluded(PostPage.class, gVars, gConsts) .get_attached_file(intval(src_fileObj), false)); } else { src_file = strval(src_fileObj); } src = wp_load_image(src_file); if (!is_resource(src)) { return strval(src); } dst = Image.imagecreatetruecolor(gVars.webEnv, dst_w, dst_h); if (src_abs) { src_w = src_w - src_x; src_h = src_h - src_y; } if (true) /*Modified by Numiton*/ { Image.imageantialias(gVars.webEnv, dst, true); } Image.imagecopyresampled( gVars.webEnv, dst, intval(src), 0, 0, src_x, src_y, dst_w, dst_h, src_w, src_h); Image.imagedestroy(gVars.webEnv, intval(src)); // Free up memory if (!booleanval(dst_file)) { dst_file = Strings.str_replace( FileSystemOrSocket.basename(src_file), "cropped-" + FileSystemOrSocket.basename(src_file), src_file); } dst_file = QRegExPerl.preg_replace("/\\.[^\\.]+$/", ".jpg", dst_file); if (Image.imagejpeg(gVars.webEnv, dst, dst_file)) { return dst_file; } else { return strval(false); } }