Package org.libheiffx

Class LibheifImage

java.lang.Object
org.libheiffx.LibheifImage

public class LibheifImage extends Object
Loads the native libheif lib and process the image in the native space. This is the entry point of the whole libheif lib to be used
Author:
Clemens Lanthaler
  • Constructor Details

    • LibheifImage

      public LibheifImage(String imageFile)
  • Method Details

    • loadLibs

      public static void loadLibs(String tempDir) throws IOException
      Unpacks all native libs and places them in a temp directory and include them in the directory
      Parameters:
      tempDir - directory where the native libs are placed
      Throws:
      IOException - if it is not possible to load/unpack the native libs into a temp directory
    • readPixelDataFromStream

      public byte[] readPixelDataFromStream(byte[] sourceFileAsByteArray) throws IOException
      Loading the native image from the given stream and give it as byte array back
      Parameters:
      sourceFileAsByteArray - the stream as array of bytes (raw bytes)
      Returns:
      an array of rgb bytes of the image which can be feed to the image class
      Throws:
      IOException - if the given byte array cannot be read
    • readPixelData

      public int[] readPixelData() throws IOException
      Reads from give URL as string the file. Please use before constructor LibrawImage(String imageFile)
      Returns:
      int array of RGB values which can be further processed
      Throws:
      IOException - if the given file cannot be read
    • getMetaData

      public HashMap<String,String> getMetaData() throws IOException
      Retrievs for the given file in the constructor the metadata Important: The timestamps are in EpocheInSeconds and not milliseconds
      Returns:
      Hashmap of all meta data
      Throws:
      IOException
    • getImageFileURL

      public String getImageFileURL()
      URL of the given file
      Returns:
      the URL to be read by readPixelData
    • getImageWidth

      public int getImageWidth()
      Gets the width of the native image
      Returns:
      width as short (int) of the native image
    • getImageHeight

      public int getImageHeight()
      Gets the height of the given image
      Returns:
      height as short (int) of the given image
    • getImageBits

      public int getImageBits()
      Image bit depth (e.g. 16bit, 8 bit, ...)
      Returns:
      the image bits
    • getImageColors

      public int getImageColors()
      Image colors
      Returns:
      if RGB or ARGB (3 or 4 color model)
    • getStride

      public int getStride()
      One line of the native image
      Returns:
      line of the image
    • getNumBands

      public int getNumBands()
      same as getStride but without the including the width of the image
      Returns:
      numBands
    • getCameraModel

      public String getCameraModel()
    • getShootingDateTime

      public LocalDateTime getShootingDateTime()
    • toString

      public String toString()
      String representation of the image
      Overrides:
      toString in class Object
      Returns:
      debug string which values are stored in the class