Skip to content

Instantly share code, notes, and snippets.

@beck03076
Created October 8, 2015 11:18
Show Gist options
  • Save beck03076/f0eb7011f729fc149eea to your computer and use it in GitHub Desktop.
Save beck03076/f0eb7011f729fc149eea to your computer and use it in GitHub Desktop.
private UpdateImageDTO generateOtherImages(UpdateImageDTO imgDto) {
try {
String thumb = "c_fit,w_72";
String medium = "c_fit,w_560";
String delimiter = "(?<=/upload/)|(?<=/fetch/)";
String originalImageUrl = imgDto.getOriginal();
String[] subStrings = originalImageUrl.split(delimiter,2);
imgDto.setMedium(subStrings[0] + medium + "/" + subStrings[1]);
imgDto.setMediumWidth(560);
int mediumHeight = (int) (((float) imgDto.getOriginalHeight() / imgDto.getOriginalWidth()) * imgDto.getMediumWidth());
imgDto.setMediumHeight(mediumHeight);
imgDto.setThumb(subStrings[0] + thumb + "/" + subStrings[1]);
imgDto.setThumbWidth(72);
int thumbHeight = (int) (((float) imgDto.getOriginalHeight() / imgDto.getOriginalWidth()) * imgDto.getThumbWidth());
imgDto.setThumbHeight(thumbHeight);
logger.info("NEW_IMAGE_DTO: " + imgDto.toString());
return imgDto;
}
catch (Exception ex) {
logger.error("Error occoured :" +ex.getMessage(),ex);
logger.error("GENERATE_OTHER_IMAGES_ERROR: " + imgDto.toString());
return imgDto;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment