How to Rotate image 90 Degrees – Java as an Alternative to Missing Oracle Multimedia Features

In modern database development, it's often necessary to store and manage various file types directly within the database. Oracle APEX (Application Express) provides a powerful platform for integrating images and other media seamlessly into a web application. However, a common issue arises when images uploaded to the database appear with the wrong orientation, such as being rotated 90 degrees. With Oracle 19c, there is no longer native multimedia functionality available to handle these types of image manipulations directly within the database.

The Challenge: Image Rotation in Oracle 19c

With the removal of the Oracle Multimedia option in version 19c, developers are searching for alternatives to perform image manipulations directly within the database. Rotating images is a particularly common requirement, whether to:
  • Correct Image Orientation: Often, images uploaded from smartphones may display incorrectly due to varying orientation settings on the device.
  • Ensure Visual Consistency: In applications where images need to be displayed in a specific layout, it is essential that all images have the same orientation.
  • Improve User Experience: Proper image orientation contributes significantly to user-friendliness and ensures a more professional presentation within the application.
Fortunately, there is a simple and efficient solution to this problem: using a Java class within the Oracle database.

Step 1: Storing the Java Class in the Database

The first step is to store the Java class responsible for rotating images within the database. This can be done via SQL Developer or SQL*Plus. It’s a straightforward process that ensures the class is available for processing image files later on.
 
SQL

Step 2: Compile and Deploy the Function

Once the Java class is successfully stored in the database, the next step is to create and compile a PL/SQL function that utilizes this Java class to rotate image files.
 
SQL

Step 3: Using the Function

Now that the function is compiled, it can be used to manipulate BLOB files (Binary Large Objects) within the database. The function takes the uploaded image as a BLOB object, rotates it by 90 degrees, and returns it as a BLOB. This allows for easy integration into Oracle APEX applications without the need for external tools or complex workflows.
 
SQL

Benefits of This Solution

This approach offers several advantages:
  • Integration with Existing Systems: Since all image processing takes place within the Oracle database, no external software or middleware is required.
  • Improved Performance: By processing images directly in the database, the need to transfer large files back and forth is eliminated, enhancing application performance.
  • Flexibility: The Java class can be adapted not only to rotate images but also to perform other image manipulations, such as scaling, cropping, or converting image formats.
  • Security: All processing occurs within the controlled environment of the database, ensuring the security and integrity of the image data.

Conclusion

Even though Oracle 19c no longer offers native multimedia support, there are still effective ways to address common image processing tasks. Using Java classes within the Oracle database is a powerful alternative that allows you to rotate, scale, or otherwise manipulate images directly in the database. This approach is not only practical but also contributes to the overall performance and user experience of your Oracle APEX applications.

 {fullWidth}

0 $type={blogger}:

Kommentar veröffentlichen