Created
October 8, 2015 11:18
-
-
Save beck03076/f0eb7011f729fc149eea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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