Rotating Image after upload

I have an option in my CUBA application to upload employee image. Surprisingly, the image is not displayed straight most of the time randomly and need to rotate to the proper direction.

Here is my code:

 //employee image
    //=======================
    employeeImageUpload.addFileUploadSucceedListener(event -> {
        FileDescriptor fd = employeeImageUpload.getFileDescriptor();
        try {
            fileUploadingAPI.putFileIntoStorage(employeeImageUpload.getFileId(), fd);
        } catch (FileStorageException e) {
            throw new RuntimeException("Error saving file to FileStorage", e);
        }

        FileDescriptor committedImage = dataSupplier.commit(fd);
        ((Employee) getItem()).setImage(committedImage);

        FileDataProvider dataProvider = new FileDataProvider(committedImage);
        employeeImage.setSource(committedImage.getId() + "." + committedImage.getExtension(), dataProvider);

        showNotification(formatMessage(getMessage("uploadSuccessMessage"), employeeImageUpload.getFileName()),
                NotificationType.HUMANIZED);
    });

How can I rotate right, left etc?

Hello @mortozakhan

What kind of problem did you encounter?

You can load a file with FileStorageService#loadFile as byte array. There are a lot of examples how to rotate image on the Internet.

Regards,
Daniil.

Hi,
It’s your browser which displays the image; not CUBA.
You can right-click and download the image from running CUBA app and check if there is something wrong with the file.

The problem that we met in our project is only if you use image transformation in your code.
Standard Java library doesn’t support some modern image rotation tags.

Regards,