SDK officiel pour Java et Kotlin
Paquet com.smallpict:smallpict-sdk pour Spring Boot, Android et Kotlin.
Optimisé pour les infrastructures d'entreprise avec support complet de Java 17+, Spring Boot et coroutines Kotlin.
Installation
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")Exemple complet d'utilisation
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("URL CDN : " + response.getUrl()); System.out.println("Gain de poids : " + response.getSavingsPercentage() + "%"); }}