Example #1
0
  /** 修改头像 */
  @RequestMapping(value = "/avatar/mod", method = RequestMethod.POST)
  public ResponseMessage modAvatar(
      HttpServletRequest request, long uid, @RequestParam(value = "img") MultipartFile file)
      throws Exception {
    // save the source avatar image file, 原始尺寸
    String filename = ImageController.uploadImg(request, file).getValue();
    AvatarDetail origin = new AvatarDetail();
    origin.setPhoto(filename);
    origin.setUserId(uid);
    origin.setTime(new Timestamp(System.currentTimeMillis()));
    avatarDetailRepository.save(origin);

    // generate image of the specified size and save,指定尺寸
    String avatar =
        ThumbnailGen.getInstance(request)
            .setUploadPath(FilenameUtils.concat(ConfigManager.get("upload.basePath"), "avatar"))
            .setUid(String.valueOf(uid))
            .gen(FilenameUtils.concat(ServerHelper.getContextPath(request), filename));

    AvatarDetail thumbnail = new AvatarDetail();
    thumbnail.setPhoto(avatar);
    thumbnail.setUserId(uid);
    thumbnail.setTime(new Timestamp(System.currentTimeMillis()));
    avatarDetailRepository.save(thumbnail);

    User user = userRepository.findById(uid);
    user.setAvatar(avatar);
    userRepository.save(user);
    return new ResponseMessage().set("filename", avatar).set("url", WebMvcConfig.getUrl(avatar));
  }
 protected void updateHistogram() {
   if (contrastPanel_ != null) {
     contrastPanel_.setImagePlus(getImagePlus(), contrastSettings8_, contrastSettings16_);
   }
 }