Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
data class ImageSize(val width: Int, val height: Int)

Pixel dimensions of a decoded image.

Link copied to clipboard
data class PickedImage(val bytes: ByteArray, val mimeType: String)
Link copied to clipboard
data class PixelRect(val x: Int, val y: Int, val width: Int, val height: Int)

A pixel rectangle within a source image.

Link copied to clipboard

Public URLs on the Skimbyte project website (the MkDocs site deployed to GitHub Pages by .github/workflows/deploy-site.yml). These ship in release builds, so they live in a committed constant rather than the local.properties-backed BackendConfig.

Properties

Link copied to clipboard
const val AVATAR_ASPECT: Float = 1.0f

Common aspect ratios used by the profile images.

Link copied to clipboard
const val BANNER_ASPECT: Float = 3.0f
Link copied to clipboard

Upload ceiling for profile/banner images: the result of compressForUpload fits within this.

Functions

Link copied to clipboard
actual fun authRedirectUri(): String

The OAuth redirect URI this platform can actually receive, passed to the auth server's /start endpoint (which validates it against its exact-match allowlist).

expect fun authRedirectUri(): String

The OAuth redirect URI this platform can actually receive, passed to the auth server's /start endpoint (which validates it against its exact-match allowlist).

actual fun authRedirectUri(): String

The OAuth redirect URI this platform can actually receive, passed to the auth server's /start endpoint (which validates it against its exact-match allowlist).

actual fun authRedirectUri(): String

The OAuth redirect URI this platform can actually receive, passed to the auth server's /start endpoint (which validates it against its exact-match allowlist).

actual fun authRedirectUri(): String

RFC 8252 §7.3 loopback redirect for desktop: a JVM process can't register a custom URL scheme with the OS (the system browser would dead-end on skimbyte://… with "address is invalid"), so the browser is redirected to this localhost listener instead, which forwards the full callback URL — token query params included — into the shared GoogleAuthCallback bridge.

actual fun authRedirectUri(): String

The OAuth redirect URI this platform can actually receive, passed to the auth server's /start endpoint (which validates it against its exact-match allowlist).

Link copied to clipboard
fun centerCropRect(sourceWidth: Int, sourceHeight: Int, targetAspect: Float): PixelRect

The centered crop rectangle that trims a sourceWidth x sourceHeight image to targetAspect (width / height). Pure, so the platform crop codecs share one definition and it can be unit-tested.

Link copied to clipboard
fun PixelRect.clampedTo(sourceWidth: Int, sourceHeight: Int): PixelRect?

Clamps this rectangle to lie within a sourceWidth x sourceHeight image, or null if it doesn't overlap the image at all (degenerate). Keeps the platform crop codecs from throwing on an off-image or oversized rect produced by gesture rounding.

Link copied to clipboard
actual suspend fun compressForUpload(image: PickedImage, maxBytes: Int): PickedImage

Ensures image is at most maxBytes by re-encoding it as JPEG, stepping the quality down and then repeatedly downscaling and re-compressing until it fits (not a single pass — it keeps shrinking and re-encoding each cycle until the output is within maxBytes). Returns image unchanged when it is already within the limit, or when it cannot be decoded. Backed per-platform because only the native image codecs can resize and re-encode bitmaps; the crop step still emits large PNGs, so this is the common chokepoint that keeps avatar and banner uploads small.

expect suspend fun compressForUpload(image: PickedImage, maxBytes: Int = MAX_UPLOAD_IMAGE_BYTES): PickedImage

Ensures image is at most maxBytes by re-encoding it as JPEG, stepping the quality down and then repeatedly downscaling and re-compressing until it fits (not a single pass — it keeps shrinking and re-encoding each cycle until the output is within maxBytes). Returns image unchanged when it is already within the limit, or when it cannot be decoded. Backed per-platform because only the native image codecs can resize and re-encode bitmaps; the crop step still emits large PNGs, so this is the common chokepoint that keeps avatar and banner uploads small.

actual suspend fun compressForUpload(image: PickedImage, maxBytes: Int): PickedImage

Ensures image is at most maxBytes by re-encoding it as JPEG, stepping the quality down and then repeatedly downscaling and re-compressing until it fits (not a single pass — it keeps shrinking and re-encoding each cycle until the output is within maxBytes). Returns image unchanged when it is already within the limit, or when it cannot be decoded. Backed per-platform because only the native image codecs can resize and re-encode bitmaps; the crop step still emits large PNGs, so this is the common chokepoint that keeps avatar and banner uploads small.

actual suspend fun compressForUpload(image: PickedImage, maxBytes: Int): PickedImage

Ensures image is at most maxBytes by re-encoding it as JPEG, stepping the quality down and then repeatedly downscaling and re-compressing until it fits (not a single pass — it keeps shrinking and re-encoding each cycle until the output is within maxBytes). Returns image unchanged when it is already within the limit, or when it cannot be decoded. Backed per-platform because only the native image codecs can resize and re-encode bitmaps; the crop step still emits large PNGs, so this is the common chokepoint that keeps avatar and banner uploads small.

actual suspend fun compressForUpload(image: PickedImage, maxBytes: Int): PickedImage

Ensures image is at most maxBytes by re-encoding it as JPEG, stepping the quality down and then repeatedly downscaling and re-compressing until it fits (not a single pass — it keeps shrinking and re-encoding each cycle until the output is within maxBytes). Returns image unchanged when it is already within the limit, or when it cannot be decoded. Backed per-platform because only the native image codecs can resize and re-encode bitmaps; the crop step still emits large PNGs, so this is the common chokepoint that keeps avatar and banner uploads small.

actual suspend fun compressForUpload(image: PickedImage, maxBytes: Int): PickedImage

Ensures image is at most maxBytes by re-encoding it as JPEG, stepping the quality down and then repeatedly downscaling and re-compressing until it fits (not a single pass — it keeps shrinking and re-encoding each cycle until the output is within maxBytes). Returns image unchanged when it is already within the limit, or when it cannot be decoded. Backed per-platform because only the native image codecs can resize and re-encode bitmaps; the crop step still emits large PNGs, so this is the common chokepoint that keeps avatar and banner uploads small.

Link copied to clipboard
fun computeCropRect(frameW: Float, frameH: Float, srcW: Int, srcH: Int, userScale: Float, panX: Float, panY: Float): PixelRect

The source-pixel rectangle currently inside the crop frame, given the cover-fit base plus the user's userScale and pan offsets (frame pixels, measured from the frame centre). Pure, so the interactive cropper's gesture mapping is unit-testable independent of Compose.

Link copied to clipboard
fun coverBaseScale(frameW: Float, frameH: Float, srcW: Int, srcH: Int): Float

The scale that makes a srcWxsrcH image just cover a frameWxframeH crop frame.

Link copied to clipboard
actual suspend fun cropToAspect(image: PickedImage, targetAspect: Float): PickedImage

Center-crops image to targetAspect (width / height) on-device and returns the cropped bytes. Real on Android and JVM; a no-op passthrough on iOS/JS/Wasm until a platform image codec is wired there. Returns the original image unchanged if it can't be decoded.

expect suspend fun cropToAspect(image: PickedImage, targetAspect: Float): PickedImage

Center-crops image to targetAspect (width / height) on-device and returns the cropped bytes. Real on Android and JVM; a no-op passthrough on iOS/JS/Wasm until a platform image codec is wired there. Returns the original image unchanged if it can't be decoded.

actual suspend fun cropToAspect(image: PickedImage, targetAspect: Float): PickedImage

Center-crops image to targetAspect (width / height) on-device and returns the cropped bytes. Real on Android and JVM; a no-op passthrough on iOS/JS/Wasm until a platform image codec is wired there. Returns the original image unchanged if it can't be decoded.

actual suspend fun cropToAspect(image: PickedImage, targetAspect: Float): PickedImage

Center-crops image to targetAspect (width / height) on-device and returns the cropped bytes. Real on Android and JVM; a no-op passthrough on iOS/JS/Wasm until a platform image codec is wired there. Returns the original image unchanged if it can't be decoded.

actual suspend fun cropToAspect(image: PickedImage, targetAspect: Float): PickedImage

Center-crops image to targetAspect (width / height) on-device and returns the cropped bytes. Real on Android and JVM; a no-op passthrough on iOS/JS/Wasm until a platform image codec is wired there. Returns the original image unchanged if it can't be decoded.

actual suspend fun cropToAspect(image: PickedImage, targetAspect: Float): PickedImage

Center-crops image to targetAspect (width / height) on-device and returns the cropped bytes. Real on Android and JVM; a no-op passthrough on iOS/JS/Wasm until a platform image codec is wired there. Returns the original image unchanged if it can't be decoded.

Link copied to clipboard
actual suspend fun cropToRect(image: PickedImage, rect: PixelRect): PickedImage

Crops image to the source-pixel rect and returns the cropped bytes (PNG). Powers the interactive cropper, which computes rect from the user's pan/zoom. Returns the original image unchanged if it can't be decoded or the rect is degenerate.

expect suspend fun cropToRect(image: PickedImage, rect: PixelRect): PickedImage

Crops image to the source-pixel rect and returns the cropped bytes (PNG). Powers the interactive cropper, which computes rect from the user's pan/zoom. Returns the original image unchanged if it can't be decoded or the rect is degenerate.

actual suspend fun cropToRect(image: PickedImage, rect: PixelRect): PickedImage

Crops image to the source-pixel rect and returns the cropped bytes (PNG). Powers the interactive cropper, which computes rect from the user's pan/zoom. Returns the original image unchanged if it can't be decoded or the rect is degenerate.

actual suspend fun cropToRect(image: PickedImage, rect: PixelRect): PickedImage

Crops image to the source-pixel rect and returns the cropped bytes (PNG). Powers the interactive cropper, which computes rect from the user's pan/zoom. Returns the original image unchanged if it can't be decoded or the rect is degenerate.

actual suspend fun cropToRect(image: PickedImage, rect: PixelRect): PickedImage

Crops image to the source-pixel rect and returns the cropped bytes (PNG). Powers the interactive cropper, which computes rect from the user's pan/zoom. Returns the original image unchanged if it can't be decoded or the rect is degenerate.

actual suspend fun cropToRect(image: PickedImage, rect: PixelRect): PickedImage

Crops image to the source-pixel rect and returns the cropped bytes (PNG). Powers the interactive cropper, which computes rect from the user's pan/zoom. Returns the original image unchanged if it can't be decoded or the rect is degenerate.

Link copied to clipboard
Link copied to clipboard
actual fun decodeImageSize(bytes: ByteArray): ImageSize?

Decodes just the pixel dimensions of bytes without loading the full bitmap, or null if the bytes can't be decoded. Lets the interactive cropper map on-screen gestures back to source pixels.

expect fun decodeImageSize(bytes: ByteArray): ImageSize?

Decodes just the pixel dimensions of bytes without loading the full bitmap, or null if the bytes can't be decoded. Lets the interactive cropper map on-screen gestures back to source pixels.

actual fun decodeImageSize(bytes: ByteArray): ImageSize?

Decodes just the pixel dimensions of bytes without loading the full bitmap, or null if the bytes can't be decoded. Lets the interactive cropper map on-screen gestures back to source pixels.

actual fun decodeImageSize(bytes: ByteArray): ImageSize?

Decodes just the pixel dimensions of bytes without loading the full bitmap, or null if the bytes can't be decoded. Lets the interactive cropper map on-screen gestures back to source pixels.

actual fun decodeImageSize(bytes: ByteArray): ImageSize?

Decodes just the pixel dimensions of bytes without loading the full bitmap, or null if the bytes can't be decoded. Lets the interactive cropper map on-screen gestures back to source pixels.

actual fun decodeImageSize(bytes: ByteArray): ImageSize?

Decodes just the pixel dimensions of bytes without loading the full bitmap, or null if the bytes can't be decoded. Lets the interactive cropper map on-screen gestures back to source pixels.

Link copied to clipboard
fun estimateReadingMinutes(text: String, wordsPerMinute: Int = 200): Int

Estimates how many minutes it takes to read text, used for the "N min read" badge on a story card. Counts whitespace-separated tokens and divides by wordsPerMinute (200 is a common average for adult silent reading of prose), rounding up. Always returns at least 1 so even a one-line summary reads as "1 min read" rather than "0".

Link copied to clipboard

Whether this device can capture a photo from a camera — checked before offering the "Take photo" option so it never appears where it can't work (a desktop with no webcam, say). Gallery/file picking is always available and is offered regardless.

Whether this device can capture a photo from a camera — checked before offering the "Take photo" option so it never appears where it can't work (a desktop with no webcam, say). Gallery/file picking is always available and is offered regardless.

Whether this device can capture a photo from a camera — checked before offering the "Take photo" option so it never appears where it can't work (a desktop with no webcam, say). Gallery/file picking is always available and is offered regardless.

Whether this device can capture a photo from a camera — checked before offering the "Take photo" option so it never appears where it can't work (a desktop with no webcam, say). Gallery/file picking is always available and is offered regardless.

Whether this device can capture a photo from a camera — checked before offering the "Take photo" option so it never appears where it can't work (a desktop with no webcam, say). Gallery/file picking is always available and is offered regardless.

Whether this device can capture a photo from a camera — checked before offering the "Take photo" option so it never appears where it can't work (a desktop with no webcam, say). Gallery/file picking is always available and is offered regardless.

Link copied to clipboard
fun maxPan(frameSize: Float, sourceSize: Int, totalScale: Float): Float

The furthest the scaled image can pan on one axis while still fully covering the frame.

Link copied to clipboard
actual fun openUrl(url: String)
expect fun openUrl(url: String)
actual fun openUrl(url: String)
actual fun openUrl(url: String)
actual fun openUrl(url: String)
actual fun openUrl(url: String)
Link copied to clipboard
actual fun rememberCameraLauncher(onResult: (PickedImage?) -> Unit): () -> Unit

Returns a zero-arg launch function; calling it opens the camera to capture a photo. onResult receives the captured image, or null if the user cancelled or capture failed. Mirrors rememberImagePickerLauncher so the edit sheet treats camera and gallery the same way.

expect fun rememberCameraLauncher(onResult: (PickedImage?) -> Unit): () -> Unit

Returns a zero-arg launch function; calling it opens the camera to capture a photo. onResult receives the captured image, or null if the user cancelled or capture failed. Mirrors rememberImagePickerLauncher so the edit sheet treats camera and gallery the same way.

actual fun rememberCameraLauncher(onResult: (PickedImage?) -> Unit): () -> Unit

Returns a zero-arg launch function; calling it opens the camera to capture a photo. onResult receives the captured image, or null if the user cancelled or capture failed. Mirrors rememberImagePickerLauncher so the edit sheet treats camera and gallery the same way.

actual fun rememberCameraLauncher(onResult: (PickedImage?) -> Unit): () -> Unit

Returns a zero-arg launch function; calling it opens the camera to capture a photo. onResult receives the captured image, or null if the user cancelled or capture failed. Mirrors rememberImagePickerLauncher so the edit sheet treats camera and gallery the same way.

actual fun rememberCameraLauncher(onResult: (PickedImage?) -> Unit): () -> Unit

Returns a zero-arg launch function; calling it opens the camera to capture a photo. onResult receives the captured image, or null if the user cancelled or capture failed. Mirrors rememberImagePickerLauncher so the edit sheet treats camera and gallery the same way.

actual fun rememberCameraLauncher(onResult: (PickedImage?) -> Unit): () -> Unit

Returns a zero-arg launch function; calling it opens the camera to capture a photo. onResult receives the captured image, or null if the user cancelled or capture failed. Mirrors rememberImagePickerLauncher so the edit sheet treats camera and gallery the same way.

Link copied to clipboard
actual fun rememberImagePickerLauncher(onResult: (PickedImage?) -> Unit): () -> Unit

Returns a zero-arg launch function; calling it opens the platform's native image picker. onResult receives the picked image, or null if the user cancelled.

expect fun rememberImagePickerLauncher(onResult: (PickedImage?) -> Unit): () -> Unit

Returns a zero-arg launch function; calling it opens the platform's native image picker. onResult receives the picked image, or null if the user cancelled.

actual fun rememberImagePickerLauncher(onResult: (PickedImage?) -> Unit): () -> Unit

Returns a zero-arg launch function; calling it opens the platform's native image picker. onResult receives the picked image, or null if the user cancelled.

actual fun rememberImagePickerLauncher(onResult: (PickedImage?) -> Unit): () -> Unit

Returns a zero-arg launch function; calling it opens the platform's native image picker. onResult receives the picked image, or null if the user cancelled.

actual fun rememberImagePickerLauncher(onResult: (PickedImage?) -> Unit): () -> Unit

Returns a zero-arg launch function; calling it opens the platform's native image picker. onResult receives the picked image, or null if the user cancelled.

actual fun rememberImagePickerLauncher(onResult: (PickedImage?) -> Unit): () -> Unit

Returns a zero-arg launch function; calling it opens the platform's native image picker. onResult receives the picked image, or null if the user cancelled.

Link copied to clipboard
fun Instant.toDisplayDate(timeZone: TimeZone = TimeZone.currentSystemDefault()): String