platform_image_converter 2.4.0
platform_image_converter: ^2.4.0 copied to clipboard
A high-performance Flutter plugin for cross-platform image format conversion using native APIs.
2.4.0 #
- Raise the minimum
jniversion to 1.1.0 (previously 1.0.0). The Android bindings are regenerated withjnigen1.0.1, which requiresjni1.1. - Regenerate the bindings with
jnigen1.0.1 andffigen23.0.0, configured from Dart scripts (ffigen.dart,ffigen_linux.dart,jnigen.dart) instead ofjnigen.yaml.
2.3.0 #
- Add
OutputFormat.aviffor AVIF output on iOS/macOS, Android, Windows and Linux. iOS/macOS encode it with ImageIO, Windows with the WIC HEIF encoder set to AV1 compression, and Linux through GdkPixbuf'savifformat (glycin with a libheif AV1 encoder such aslibheif-plugin-aomenc, or a loader module such aslibavif-gdk-pixbuf). Where the encoder is missing, AVIF throwsUnsupportedFormatExceptionwith reasoncodecUnavailable; Web throwsplatformUnsupported. On iOS/macOS, quality 100 is encoded at 0.99, since ImageIO's AVIF encoder fails at 1.0. - Android encodes AVIF on Android 14+ (API 34) with the platform's AV1 encoder (
MediaCodec) andMediaMuxer, storing the image as a HEIF grid of AV1 tiles. Below Android 14, and on Android 16 before QPR2 (SDK 36.0), whoseMediaMuxerwrites no AVIF image items, it throwscodecUnavailable. Android AVIF output has no alpha channel: AVIF stores alpha as a monochrome AV1 image, which Android's AV1 encoders cannot produce, so transparent pixels are composited onto black. Use it with care: handlecodecUnavailableand fall back to another format, and expect output size, quality and encoding time to depend on the device's AV1 encoder. - Reject unsupported output on iOS/macOS before decoding the input: WebP output with invalid input now throws
UnsupportedFormatExceptioninstead ofImageDecodingException.
2.2.1 #
- Fix JPEG output on Linux from a source with an alpha channel. The RGBA pixbuf was handed to the JPEG encoder as is, which either rejected it (throwing
ImageEncodingException) or dropped the alpha channel and kept the colour of transparent pixels, depending on the installed GdkPixbuf encoder. The source is now composited onto opaque black before encoding, in the same pass as any resize, so transparent pixels become black. - Pass
qualityto the Linux encoder only when its GdkPixbuf loader supports thequalitysave option (gdk_pixbuf_format_is_save_option_supported). Otherwise it has no effect on the output, as for PNG. - Report the HRESULT when no WIC decoder can be created for the input on Windows. The
ImageDecodingExceptionmessage was a fixed "Invalid image data."; it now includes the code, which tells invalid data apart from a format that no installed decoder supports. - Correct the Linux HEIC output documentation: it requires a writable
heifGdkPixbuf loader, and the libheif GdkPixbuf loader only decodes, so it does not enable HEIC output. - Correct outdated API documentation: the Web backend decodes with
createImageBitmap(not anHTMLImageElement), the Darwin backend encodes JPEG, PNG and HEIC with quality for JPEG/HEIC (not WebP), and the Android backend decodes withImageDecoderorBitmapFactory. - Rework the integration tests: platforms are selected with
skipinstead of branching inside test bodies, and output is checked by its detected format, decodability, size and pixels instead of by file sizes.
2.2.0 #
- Decode with
ImageDecoderon Android 9+ (API 28) whenExifOrientationPolicy.applyis in effect.setTargetSizein the header callback scales during the decode, so a resize no longer materializes the full-resolution bitmap beforeBitmap.createScaledBitmapshrinks it, andImageDecoderbakes in the EXIF orientation itself. TheBitmapFactorypath is unchanged and still used below API 28 and forExifOrientationPolicy.ignore, whichImageDecodercannot express; the plugin'sminSdkis unchanged. - Use the explicit
WEBP_LOSSY/WEBP_LOSSLESScompress formats for WebP output on Android 11+ (API 30), where the combinedWEBPformat is deprecated. Aqualityof 100 selectsWEBP_LOSSLESSand anything lowerWEBP_LOSSY, which is whatWEBPitself did, so the output is unchanged. - Free the Android JNI output buffer deterministically.
JByteArray.getRangetook its native buffer frommallocwith aNativeFinalizerattached, so a buffer as large as the encoded output stayed alive until the Dart GC ran that finalizer. It now comes from the surrounding arena and is freed when the conversion scope ends. - Regenerate the bindings with
jnigen0.17.0 andffigen21.0.0. - Add host-runnable unit tests for the EXIF orientation transforms on the Darwin and Windows backends. The pure transform functions are exposed via
@visibleForTestingand covered by tests that pin the CoreGraphics affine matrix (all eight orientations, plus a scaled case) and the WICWICBitmapTransformOptionsmapping, so a regression in that math is caught on the unit-test runner without a device or simulator. No behavior change.
2.1.3 #
- Fix a memory leak on iOS/macOS: the
CFDictionaryholding the JPEG/HEIC compression quality was created but never released, leaking one dictionary per lossy conversion. It is now released together with the surrounding arena. - Guarantee resize output is at least 1x1px. An extreme aspect ratio could round a dimension down to 0 (for example fitting a 4000x3 image to width 5), producing a zero-sized surface that the native encoders reject;
ResizeMode.calculateSizenow clamps both dimensions to a minimum of 1px across every resize mode and platform.
2.1.2 #
- Restore the
jnidependency to^1.0.0(and the Android bindings generated withjnigen0.16.0), reverting the temporary downgrade shipped in 2.1.1. Projects that also depend on packages still onjni0.15.x (such ascronet_http) will keep resolving to 2.1.1 automatically until those packages migrate.
2.1.1 #
- Downgrade the
jnidependency to^0.15.0(and regenerate the Android bindings withjnigen0.15.0) so this package can be used alongside packages that still depend onjni0.15.x, such ascronet_http. This is a temporary compatibility release; a future release will return tojni1.0.0 once the ecosystem has migrated.
2.1.0 #
- Add EXIF orientation handling via a new
orientationparameter onImageConverter.convert, controlled by theExifOrientationPolicyenum.apply(the default) bakes the source's EXIF orientation into the output pixels so the result is upright on every platform;ignoreencodes the decoded buffer as-is. Implemented on every backend: Darwin (CoreGraphics CTM), Android (ExifInterface+Matrix), Windows (IWICBitmapFlipRotator+ metadata query reader), Linux (gdk_pixbuf_apply_embedded_orientation), and Web (createImageBitmapimageOrientation). - Behavior change: because
applyis the default, the output of EXIF-tagged sources (typically camera JPEG/HEIC) now reflects the orientation tag instead of the raw decoded buffer. For a 90°/270° tag the output width and height swap, and the resize mode is evaluated against the oriented (display) dimensions. Passorientation: ExifOrientationPolicy.ignoreto keep the previous raw-buffer behavior.
2.0.0 #
- Breaking: unsupported-output and unsupported-platform conditions now throw exceptions from the
ImageConversionExceptionhierarchy instead of thedart:coreUnsupportedError, so a singleon ImageConversionExceptionclause catches every conversion failure and these recoverable conditions are no longer modelled as un-catchableErrors. A format that the platform cannot produce throwsUnsupportedFormatException, whosereasondistinguishes a permanent platform limitation (platformUnsupported, e.g. WebP on iOS/macOS/Windows or HEIC on Android/Web) from a codec that the user could install (codecUnavailable, e.g. Windows HEIC without the HEVC/HEIF codec). Running on a platform with no backend throwsUnsupportedPlatformException. Code that caughtUnsupportedErrormust now catch these types. - Add Windows support via the Windows Imaging Component (WIC), bound directly with
dart:ffi(no native build step). JPEG and PNG output are supported with the same resizing modes and quality control as the other platforms. HEIC output is also supported where the OS ships the HEVC/HEIF codec (Windows 11 22H2+ out of the box; older Windows via the Store "HEVC Video Extensions") — when absent, HEIC throwsUnsupportedFormatException. WebP output is not supported (Windows has a WebP decoder but no encoder). As on the Darwin backend, every source is normalized to a fixed 8-bit surface before encoding. - Add Linux support via GdkPixbuf (the GLib/GTK imaging stack the Flutter Linux embedder already links), bound directly with
dart:ffi(no native build step). JPEG and PNG output are always available; WebP and HEIC output require a writable GdkPixbuf loader module (e.g.webp-pixbuf-loader; the libheif loader only decodes, so it does not enable HEIC output), which varies by distribution — when none is installed, output throwsUnsupportedFormatExceptionwith reasoncodecUnavailable. Resizing uses high-quality (GDK_INTERP_HYPER) resampling and quality control matches the other platforms.
1.2.1 #
- Web: render resizes with
imageSmoothingQuality = 'high'so downscaled output quality matches the iOS/macOS (kCGInterpolationHigh) and Android (filter: true) backends.
1.2.0 #
- Upgrade the
jnidependency to^1.0.0and regenerate the Android bindings withjnigen0.16.0. The minimumjniversion is now 1.0.0 (previously 0.15.2); this major bump of a direct dependency may affect dependency resolution for consumers that also depend onjni.
1.1.0 #
- Fix iOS/macOS crash when resizing 16-bit, grayscale, CMYK, or indexed images (#36).
- Normalize iOS/macOS output to 8-bit sRGB. 16-bit and wide-gamut (e.g. Display P3) sources are no longer preserved, and output no longer depends on whether a resize occurred (behavior change).
- Drop the
objective_cdependency on iOS/macOS; the native backend now binds CoreFoundation/CoreGraphics/ImageIO directly viadart:ffi.
1.0.6 #
- Fix lint rule.
1.0.5 #
- Fix exclude rule.
1.0.4 #
- Fix lint rules.
- Fix documentations.
- Fix resource management.
1.0.3 #
- Fix support flutter version constraint.
- Fix documentations.
- Update integration test.
1.0.2 #
- dart format applied to all files.
1.0.1 #
- Fix pubspec.ymml and .metadata files.
1.0.0 #
- Initial stable release.
- Add
ImageConversionExceptionfor better error handling. - Improve documentation and add usage examples.
0.2.0 #
- Support resized image output.
- Refactor codebase for better maintainability.
0.1.0 #
- Initial release of platform_image_converter.
- Support Android, iOS, macOS, and Web.
- Add
convertmethod for image format conversion.