Hi,
THIS IS MY QUESTION: how can I set the resolution of an image file before it is generated by the Upload / Receiver component in a path on the server, even if the component automatically calls the mobile phone camera ???
thanks in advance for support, someone can help me please?
this is the situation
i use your Upload.class(java) and receiver TO MAKE files from Camera mobile Phones component,
but the image is written(mkdirs) on server side in defined class path,
the file is produced as .jpg BUT the pixels resolution is too large (due to the megapixel of the new smartphone / mobile phones) at least 3000px with and 4000px height, average size between each file 3/5Mbyte
i wrote a class to resize images file and work fine, but I can’t integrate it because the component Upload writes the file into the path on server BEFORE i can call Java Resize class, **and so I can’t get the advantage of a faster webapp UI:
- to upload faster (smaller size, not 3MByte but 150KByte for example)
- to show image into image obj on UI session**
@Override
public OutputStream receiveUpload(String filename, String mimeType) {
FileOutputStream fos = null;
try {
String newFileName = filename;
File file = new File(path, newFileName);
new File(path).mkdirs();
file.createNewFile();
fos = new FileOutputStream(file);
String relativePath = file.getAbsolutePath().replace(path, "");
if (relativePath.startsWith(System.getProperty("file.separator"))) {
relativePath = relativePath.substring(1);
}
I attach the image UI in layout than the file was created and Uploaded into path on server…
upload = new DocUpload(getRefDoc()) {
...
@Override
protected void newFileUploaded(File file) throws IOException {
String newFileName = "nameFile.jpg";
File newFile = new FileEncoded(file.getParent(), newFileName);
file.renameTo(newFile);
// Resizing Image too big (.jpg file)
// JImgResizer resizing = new JImgResizer(newFile);
// File fileResized = resizing.resizeOne(newFile);
addFile(fileResized);
image.setSource(new FileResource(fileResized));
image.setWidth("100%");
.......
}
};
upload.setImmediate(true);
.....
image = new Image();
.....