Supported on Android, iOS, macOS, JVM targets
Compressing Images
You can compress images to reduce their file size while maintaining acceptable quality:compressImage function provides several key features:
- Quality control: Reduces the image quality based on the
qualityparameter (0-100) - Resizing: Resizes the image if
maxWidthormaxHeightis specified, maintaining the aspect ratio - Format conversion: Converts the image to the specified format (JPEG or PNG)
- Metadata handling: On Android, automatically handles EXIF orientation metadata
Saving Images to Gallery
FileKit provides a way to save images to the device’s photo gallery:saveImageToGallery varies slightly by platform:
Saving Videos to Gallery
FileKit provides a way to save videos to the device’s gallery:saveVideoToGallery varies slightly by platform:
Encoding and Converting Images
FileKit provides utilities for encodingImageBitmap objects into byte arrays and converting PlatformFile objects into ImageBitmap instances. These methods are useful for image manipulation and storage across platforms.
Encoding an ImageBitmap to ByteArray
TheImageBitmap.encodeToByteArray method allows you to encode an ImageBitmap into a ByteArray using a specified format and quality.
Converting a PlatformFile to ImageBitmap
ThePlatformFile.toImageBitmap method converts a file into an ImageBitmap for use in Compose UI or other image operations.