Skip to content
smallPict

Officiële Java en Kotlin SDK

Pakket com.smallpict:smallpict-sdk voor Spring Boot, Android en Kotlin.

Ontwikkeld voor grootschalige architecturen met uitgebreide ondersteuning voor Java 17+, Spring Boot en Kotlin coroutines.


Installatie

Maven

XML
<dependency>    <groupId>com.smallpict</groupId>    <artifactId>smallpict-sdk</artifactId>    <version>1.2.0</version></dependency>

Gradle (Kotlin DSL)

Kotlin
implementation("com.smallpict:smallpict-sdk:1.2.0")

Compleet toepassingsvoorbeeld

Java
package com.example;
import com.smallpict.SmallPictClient;import com.smallpict.model.OptimizeRequest;import com.smallpict.model.OptimizeResponse;
import java.nio.file.Files;import java.nio.file.Path;
public class Application {    public static void main(String[] args) throws Exception {        SmallPictClient client = SmallPictClient.builder()                .apiKey(System.getenv("SMALLPICT_API_KEY"))                .secretKey(System.getenv("SMALLPICT_SECRET_KEY"))                .build();
        byte[] imageData = Files.readAllBytes(Path.of("hero.jpg"));
        OptimizeResponse response = client.optimize(OptimizeRequest.builder()                .file(imageData)                .filename("hero.jpg")                .format("avif")                .quality(80)                .build());
        System.out.println("CDN-URL: " + response.getUrl());        System.out.println("Besparing: " + response.getSavingsPercentage() + "%");    }}