0

Working with Oracle SOA Suite 12c, XSLT, and Java embeddings.

I am receiving images that I am converting into Base64 and sending on for further processing. However, When I get JPEG2000 images, the receiving end of the processing doesn't function. In my middleware, I want to convert the JPEG2000 to JPEG, BMP, or PNG. If I can do that everything should work fine. For this I need to do 2 things:

1: Detect whenever an image is in JPEG2000.

2: Convert the JPEG2000 image to the required format

Does someone know how to tackle these issues?

MT0
  • 143,790
  • 11
  • 59
  • 117
Jesper Vernooij
  • 173
  • 1
  • 15
  • 1
    This may be helpful: https://github.com/Unidata/jj2000 (it's a fork of the solution mentioned here: https://stackoverflow.com/a/7094178/361842) – JohnLBevan Sep 24 '20 at 08:07
  • 1
    ImageMagick uses information in the header to detect the file type. You can do that from the "magick" value using `convert image -format "%m" info:` See https://imagemagick.org/script/escape.php. Sorry, I do not know how to do that in Java. – fmw42 Sep 24 '20 at 18:54

1 Answers1

1

Detecting the format of an image is just about possible in XSLT if you are able to use a processor that supports the EXPath Binary Module (a function library for handling binary data). Converting between image formats, however, will require calling out to an image processing library such as imagemagick.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • Thank you for your answer Michael. Would you perhaps know how to get started on the format detection when using a processor supporting EXPath Binary Module? My plan is now to find similarities in JPEG2000 images and select based on those similarities. For example, Ive found that the first 12 digits in JPEG2000 images are definitive for the format. I think i can use that to detect the format as being either JPEG2000, or not JPEG 2000 (which is the goal) – Jesper Vernooij Nov 06 '20 at 10:58
  • 1
    I'm no expert on this. There are plenty of web sites that give suggested bit patterns for file type detection, for example https://www.example-code.com/csharp/determine_file_type_from_content.asp – Michael Kay Nov 06 '20 at 12:34