Skip to content

Repository files navigation

imageboss-java

Java URL builder for ImageBoss, with Java 17+ and Kotlin support.

Installation

Add the dependency

Gradle (Kotlin DSL)

dependencies {
implementation("me.imageboss:imageboss-java:1.0.0")
}

Maven

<dependency>
<groupId>me.imageboss</groupId>
<artifactId>imageboss-java</artifactId>
<version>1.0.0</version>
</dependency>

Basic usage (Java)

importme.imageboss.ImageBossClient;
importme.imageboss.Operation;
importme.imageboss.Option;
ImageBossClientclient = ImageBossClient.newBuilder("mywebsite-images").build();
Stringurl = client.createUrl(
"examples/02.jpg",
Operation.cover(300, 300),
Option.formatAuto()
);
// https://img.imageboss.me/mywebsite-images/cover/300x300/format:auto/examples/02.jpg

Signed URLs

ImageBossClientclient = ImageBossClient.newBuilder("mysecureimages")
.secret("<YOUR_SECRET>")
.build();
Stringurl = client.createUrl("width/500/01.jpg", Operation.cdn());
// https://img.imageboss.me/mysecureimages/cdn/width/500/01.jpg?bossToken=...

Expiring URLs:

longexpires = /* unix timestamp (seconds) */;
Stringurl = client.createSignedUrl(
"width/500/01.jpg",
Operation.cdn(),
expires,
null
);
// https://img.imageboss.me/mysecureimages/cdn/width/500/01.jpg?bossToken=...&expires=...

Srcset generation

Fixed-dimension (DPR) srcset:

Stringsrcset = client.createDprSrcset(
"examples/02.jpg",
Operation.cover(300, 300),
true// variable quality
);

Fluid-width srcset:

Stringsrcset = client.createWidthSrcset(
"examples/02.jpg",
Operation.cdn(),
300,
1600,
0.08
);

Kotlin usage

val client =ImageBossClient.newBuilder("mywebsite-images")
.secret("my-secret")
.build()
val url = client.createUrl(
"examples/02.jpg",
Operation.cdn(),
Option.formatAuto()
)

Playground

There is a small Java playground you can use to experiment with URLs and srcsets:

# Compile and run tests/build first (so classes are on the classpath)
gradle test# Then run the playground from your IDE, or from the CLI, e.g.:
java -cp build/classes/java/main:build/classes/java/test me.imageboss.Playground

Edit src/test/java/me/imageboss/Playground.java to try different sources, operations, options, and custom domains (e.g. baseUrl("https://images.example.com")), and inspect the printed URLs/srcsets.

Releasing a new version

See RELEASING.md for detailed instructions and the one-command release script.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages