I have a spring2.0 application and we are using uploadify jquery plugin 2.1 version to implement the image upload functionality.
Problem is: when I am trying to upload any image in java code it is saying it's resolution is 0dpi. But i checked i was 300dpi. Why is it happening? My uploadify configuration is:
$('#imageFile1').uploadify({
'uploader' : '../uploadify/uploadify.swf',
'script' : 'images.htm',
'scriptData' : {'currentFormSpecId' : '${myCommand.formId}'},
'cancelImg' : 'cancel.png',
'auto' : false,
'multi' : true,
'wmode' : 'transparent',
'width' : 130,
'queueID' : 'fileQueue',
'queueSizeLimit' : 15,
'folder' : '../uploadify',
'fileDesc' : '*.jpg;*.jpeg;*.tif;*.tiff;*.eps',
'fileExt' : '*.jpg;*.jpeg;*.tif;*.tiff;*.eps',
'sizeLimit' : 102400000,
'onError': function(event, queueID, fileObj, errorObj) {
// Error display
},
'onComplete': function(event, queueID, fileObj, response, data) {
//success display
});
Java code
public ModelAndView uploadImagesToDisk (HttpServletRequest request,
HttpServletResponse response, Object command, BindException errors) throws Exception {
String currentFormId = request.getParameter("currentFormSpecId");
DefaultMultipartHttpServletRequest multipartHttpServletRequest =
(DefaultMultipartHttpServletRequest) request;
MultipartFile multipartFile = multipartHttpServletRequest.getFile("Filedata");
OutputStream outputStream = null;
try {
String imageFileName = multipartFile.getOriginalFilename();
String imageFileExtension = getFileExtension(multipartFile);
Image image = Image.getInstance(multipartFile.getBytes());
if ((image.getDpiX() < MINIMUM_DPI) || (image.getDpiY() < MINIMUM_DPI)) {
throw new Exception("ERROR: The image (" + multipartFile.getOriginalFilename()
+ ", " + image.getDpiX() + " dpi) " +
" your are attempting to upload does not meet the requirements " +
"for minimum resolution of 300 dpi. Please upload another image.");
}
}
in above code image.getDpiX() is always coming zero.
one more weird thing I noticed: When I checked the image resolution in my window7 machine it is saying it is 300dpi but when I am checking the same image in windows server machine(using citrix I am connecting and it has low screen resolution), it is showing 96dpi. Why is it happening?
Please let me know you want me to post anything else.
Aucun commentaire:
Enregistrer un commentaire