Clerezza
  1. Clerezza
  2. CLEREZZA-716

Support alternate image processing libraries for reading image data

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.2-incubating
    • Fix Version/s: None
    • Component/s: platform, rdf.utils
    • Labels:
      None

      Description

      Currently clerezza uses Java Image IO to read images and create BufferedImages. This is done in various places such as the ImageMetaDataGenerator and the AlternativeRepresentationGenerator. However the Java ImageIO implementation can fail with some JPEGs that have certain meta data stored that does not conform exactly to JPEG specification. In order to handle such cases there should be a possibility register other libraries or implementations that generate BufferedImages and handle these cases.

      I suggest to create a BufferedImageProvider OSGi service and use it in the meta data generators mentioned above. There should also be a default implementation of this service that uses Java ImageIO. Clients should then be able to register services that override this service and may have different implementations that return BufferedImages. I think it might work with the service-ranking property but I am not sure.

        Activity

        Hide
        Daniel Spicar added a comment -

        Basic wiki documentation available here: http://wiki.apache.org/clerezza/ImageReaderService

        Show
        Daniel Spicar added a comment - Basic wiki documentation available here: http://wiki.apache.org/clerezza/ImageReaderService
        Hide
        Daniel Spicar added a comment -

        Now there can be several ImageReader services present.

        An ImageReader simply provides methods to get BufferedImages from different input sources (Files, InputStreams, URLs).

        Services can implement the ImageReader interface to provide Buffered Images using various methods and libraries.

        By default there is an ImageReader service which uses javax.imageio (ImageIO.read) to implement the functionality. This service is called ImageIOImageReader and has a service.ranking of 0.

        There is another service: ImageReaderService. This service provides a method to dynamically obtain the ImageReader with the highest service.ranking value. Additionally this service implements the ImageReader interface as well and delegates the calls to the highest ranking ImageReader service. However it is not registered in the OSGI SCR as offering the ImageReader service so one has to bind it as ImageReaderService.

        I tried to replace all instances where ImageIO.read is used by usage of ImageReaderService.

        Thus now it is possible to implement and register additional ImageReaders that provide BufferedImages in a different way (e.g. using JAI - Java Advanced Imaging). By setting their service ranking property to a higher value than the default 0, they will be used over the default ImageIO service. By declaring the property explicitly not private one can even change the service ranking via the config admin at runtime.

        Show
        Daniel Spicar added a comment - Now there can be several ImageReader services present. An ImageReader simply provides methods to get BufferedImages from different input sources (Files, InputStreams, URLs). Services can implement the ImageReader interface to provide Buffered Images using various methods and libraries. By default there is an ImageReader service which uses javax.imageio (ImageIO.read) to implement the functionality. This service is called ImageIOImageReader and has a service.ranking of 0. There is another service: ImageReaderService. This service provides a method to dynamically obtain the ImageReader with the highest service.ranking value. Additionally this service implements the ImageReader interface as well and delegates the calls to the highest ranking ImageReader service. However it is not registered in the OSGI SCR as offering the ImageReader service so one has to bind it as ImageReaderService. I tried to replace all instances where ImageIO.read is used by usage of ImageReaderService. Thus now it is possible to implement and register additional ImageReaders that provide BufferedImages in a different way (e.g. using JAI - Java Advanced Imaging). By setting their service ranking property to a higher value than the default 0, they will be used over the default ImageIO service. By declaring the property explicitly not private one can even change the service ranking via the config admin at runtime.

          People

          • Assignee:
            Daniel Spicar
            Reporter:
            Daniel Spicar
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0h
              0h
              Logged:
              Time Spent - 12.5h
              12.5h

                Development