Link
Skip to main content

Running JDeli in Scala

Table of contents

  1. Introduction
  2. Prerequisites
  3. Code Example

Introduction

The following tutorial shows you how to use JDeli in Scala.

Prerequisites

  • Scala installed on your machine
  • JDeli jar added to your project library

Code Example

This code snippet uses JPG to PNG conversion as an example. This example uses sbt as the build tool.

build.sbt

ThisBuild / version := "0.1.0-SNAPSHOT"

ThisBuild / scalaVersion := "3.3.6"

lazy val root = (project in file("."))
  .settings(
    name := "jdeli-scala"
  )

Main.scala

import com.idrsolutions.image.JDeli

import java.awt.image.BufferedImage
import java.io.File

object Main {
  def main(args: Array[String]): Unit = {
    val inputFile = new File("jpgFile.jpg")
    val outputFile = new File("pngFile.png")

    val bufferedImage: BufferedImage = JDeli.read(inputFile)
    JDeli.write(bufferedImage, "png", outputFile)
  }
}

Why JDeli?

  • Support image formats such as AVIF, HEIC and JPEG XL (AVIF soon) that are not supported in Java.
  • Process images up to 3x faster than ImageIO and alternative Java image libraries.
  • Prevent JVM crashes caused by native code in other image libraries such as ImageIO.
  • Handle JPEG, PNG, TIFF image file formats fully in Java.
  • Keep your Image files secure as JDeli makes no calls to any external system or third party library.

Learn more about JDeli

Start Your Free Trial