Class ImageLoader

java.lang.Object
com.digitizer.image.ImageLoader

public final class ImageLoader extends Object
Utility class for loading images from disk.

Prefer loadImage(File) which first tries JavaFX's Image to read common formats (PNG/JPG/BMP) and falls back to ImageIO for extended formats (TIFF, WebP). The utility also contains convenience methods for obtaining image dimensions.

  • Method Details

    • loadImage

      public static javafx.scene.image.Image loadImage(File file) throws IOException
      Loads an image from the specified file.
      Parameters:
      file - the image file (PNG, JPEG, BMP, TIFF, WebP, etc.)
      Returns:
      the loaded JavaFX Image
      Throws:
      IOException - if the file cannot be read or is not a valid image
    • loadImage

      public static javafx.scene.image.Image loadImage(String filePath) throws IOException
      Loads an image from the specified file path.
      Parameters:
      filePath - the path to the image file
      Returns:
      the loaded JavaFX Image
      Throws:
      IOException - if the file cannot be read or is not a valid image
    • getImageWidth

      public static int getImageWidth(javafx.scene.image.Image image)
      Gets the width of an image in pixels.
      Parameters:
      image - the image
      Returns:
      the width, or 0 if image is null
    • getImageHeight

      public static int getImageHeight(javafx.scene.image.Image image)
      Gets the height of an image in pixels.
      Parameters:
      image - the image
      Returns:
      the height, or 0 if image is null