/** * 跳转图片裁剪处理 * * @author wqtan */ @RequestMapping(value = "/cutImage") public String goCutImage(ModelMap model, HttpServletRequest request) { String status = "success"; String imgPath = paramUtils.getParameter(request, "imgPath", ""); model.addAttribute("imgPath", imgPath); File imgFile = new File(stringUtil.parseToPath(CommonConstants.ROOTPATH + "/" + imgPath)); if (imgFile.isFile() && imgFile.exists()) { Image image = null; try { image = ImageTools.readImage(imgFile.getPath()); } catch (UtilException e) { status = "error"; return "/admin/cutImage"; } int imgWidth = image.getWidth(null); int imgHeight = image.getHeight(null); model.addAttribute("imgWidth", imgWidth); model.addAttribute("imgHeight", imgHeight); } else { status = "error"; return "/admin/qmt/magzine/cutImage"; } model.addAttribute("status", status); int width = paramUtils.getIntParameter(request, "width", 0); model.addAttribute("width", width); int height = paramUtils.getIntParameter(request, "height", 0); model.addAttribute("height", height); // 回调只需要传函数名,参数为filepath String call = paramUtils.getParameter(request, "call", ""); model.addAttribute("call", call); // 截取宽高 String sw = paramUtils.getParameter(request, "sw", ""); model.addAttribute("sw", sw); String sh = paramUtils.getParameter(request, "sh", ""); model.addAttribute("sh", sh); // 图片存储类型 String imgType = paramUtils.getParameter(request, "imgType", ""); model.addAttribute("imgType", imgType); return "/admin/cutImage"; }
public Image dealImage(String imageFile) throws FileNotFoundException, IOException { Image image = ImageTools.readImage(imageFile); return this.dealImage(image); }