Skip to content

Releases: derangga/komig

v0.1.1

Choose a tag to compare

@derangga derangga released this 31 Mar 03:12
a2a74bf

What's New

Cache Result Support

CompressionResult now supports caching the compressed image to disk via
cacheResult(). Once cached, the in-memory byte array is released to reduce memory
pressure.

  • CompressionResult.cacheResult() — writes bytes to a file and releases the in-memory
    ByteArray
  • CompressionResult.cachedPath — returns the file path of the cached result, or
    null if not cached
  • CompressionResult.isBytesAvailable — indicates whether in-memory bytes are still
    held
  • Accessing .bytes after caching throws IllegalStateException with the cached file
    path for guidance

Compress from File Path

Komig.compress() now accepts a filePath: String directly.

val result = Komig.compress("/path/to/image.jpg") {
    quality(80)
    format(OutputFormat.WEBP)
}

New Exception Type

  • KomigException.FileIOException — thrown when a file cannot be read at the given
    path

Komig 0.1.0

Choose a tag to compare

@derangga derangga released this 28 Mar 03:40

Komig 0.1.0 — Initial Release

A Kotlin Multiplatform image compression library for Android and iOS.

Features

  • Coroutine-based DSL — Simple, idiomatic API for image compression
  • Multi-format support — JPEG, PNG, and WebP with automatic format detection via magic bytes
  • Quality control — Configurable compression quality (0–100)
  • Resize modesFitInside, ExactResize, and Percentage scaling
  • Max resolution — Cap output dimensions while preserving aspect ratio
  • Platform-native codecsBitmapFactory/Bitmap.compress on Android, UIImage/UIKit on iOS
  • KMP targets — Android (minSdk 26), iOS (iosX64, iosArm64, iosSimulatorArm64)

Installation

// In commonMain
implementation("io.github.derangga:komig:0.1.0")

Quick Start

val result = Komig.compress(imageBytes) {
    quality(80)
    format(OutputFormat.WEBP)
    maxResolution(1920, 1080)
}

// result.bytes → compressed ByteArray
// result.outputSizeBytes → compressed size