Skip to Main Content
  • Questions
  • how get width and height image in BLOB

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Francesco.

Asked: January 19, 2025 - 2:16 pm UTC

Last updated: January 22, 2025 - 2:12 am UTC

Version: 22.1

Viewed 100+ times

You Asked

Hi Team,
I use ApEx 22.1 and SQL Developer.
In an ApEx page, users have to upload 4 photos of their workstation. Then with PL/PDF I generate the PDF containing texts, photos and ID number.
I have no control over the uploaded photos. The aspect ratio of the images can be 16:9 or 4:3, portrait or landscape orientation, JPEG, PNG or TIFF.
The columns of the table are: ID, NAMEFILE, MIME, BLOB, WH but I don't know how to get the WH data (= Width x Height) of the image.
Is it possible to know the dimensions of the image before uploading it or after, in reading the BLOB?

and Connor said...

Unfortunately in 19c we have desupported the multimedia option, so the database no longer has direct APIs to do that.

I found a potential option here

https://stackoverflow.com/questions/68273962/pl-sql-get-dimensions-of-jpeg-image

where someone is reading the binary files directly, but that seems fraught with danger to me.

Since you're using APEX there's a number of potential ways to get access to multimedia APIs covered in this blog post

https://blogs.oracle.com/apex/post/alternatives-for-oracle-multimedia

I have also have a *basic* mechanism of getting access to the OS level tools for multimedia via external tables, eg



That example uses ffmpeg which has a partner program ffprobe which returns attributes about images, video etc


Rating

  (3 ratings)

Comments

A lot of information

Francesco, January 22, 2025 - 8:40 am UTC

Tank’s Connor,
You have given me a lot of information.
For my question I found a Javascript function that read images but I can’t use it when I upload with item “File Browse” (Blob don’t exist before submit)
I waiting for the DBAs to upgrade ApEx to use MLE.

A reader, January 29, 2025 - 3:52 pm UTC

You're right to explore options for extracting image dimensions from a BLOB in ApEx, and Connor's points about Oracle 19c dropping multimedia support make this a bit trickier. That Stack Overflow thread provides a method for reading binary files directly, but as you said, it's not the most reliable approach.

Since you're using ApEx, an alternative could be leveraging external tools like ImageMagick via an external table or a PL/SQL web service to process the images before inserting them into the database. Another option is using Java stored procedures to extract metadata.

More to Explore

CLOB/BLOB/etc

Complete documentation on Securefiles and Large Objects here