image_ffi 0.5.1 copy "image_ffi: ^0.5.1" to clipboard
image_ffi: ^0.5.1 copied to clipboard

Fast native image resize, thumbnail and JPEG/PNG encode for Dart over FFI. Several times quicker than the pure-Dart image package; stb-backed, no prebuilt binary.

0.5.1 #

  • Fix a native buffer leak: decodeImage, resizePixels, encodeJpeg, and encodePng freed the native output buffer only after copying it into a Dart Uint8List. If that copy threw (out of memory on a large image), the native buffer was never freed. Each free now runs in a finally around the copy, so it happens whether the copy succeeds or throws.
  • Fix a silent truncation risk: resizePixels takes srcWidth, srcHeight, dstWidth, and dstHeight as Dart int, but crosses the FFI boundary as a 32-bit native Int. A caller passing a dimension above 2^31-1 got it silently wrapped at the boundary instead of an error. These now throw ArgumentError before the call.

0.5.0 #

  • Add thumbnailJpegBatch and thumbnailPngBatch for processing a folder. Running Future.wait over thumbnailJpegAsync spawned one isolate per image at once, each holding a full decoded buffer, which ran a real directory out of memory. The batch calls run the same per-image work off the main isolate but cap how many isolates are live at once to concurrency, defaulting to Platform.numberOfProcessors, using a semaphore over the existing async calls. Each thumbnail is emitted from the returned stream as it finishes, so results arrive in completion order rather than input order. maxDimension and quality match the async variants. The README now points at these for a folder and example/no_jank.dart shows the batch path.

0.4.4 #

  • Install instructions now say pub add instead of pinning a version. The pinned number was stale by several releases and would have been stale again after the next one: the README ships frozen in the archive, so a hand-edited version line is wrong the moment anything is published. This one cannot go out of date.

0.4.3 #

  • Widen the native-toolchain constraints so the package can be installed in a Flutter app at all. hooks 2.1.0 and native_toolchain_c 0.19.3 raised their meta floor to ^1.19.0, and Flutter's SDK pins meta to 1.17.0, so flutter pub add failed at version solving with "flutter from sdk is incompatible". Allowing hooks >=2.0.2 and native_toolchain_c >=0.19.2 lets the solver pick a version that works with the pinned meta, while a pure-Dart project still resolves to the newest. No API or behaviour change.

0.4.2 #

  • example/no_jank.dart measures what the async variants are for. It builds a 4000x3000 JPEG so no file is needed, makes eight thumbnails on the main isolate and eight with thumbnailJpegAsync, and runs a 16 ms timer alongside to report the longest gap between two ticks. On this machine: 413 ms of silence, about 25 frames, against 18 ms and one. The work takes the same time either way, which is the point; what moves is where it happens.
  • example/README.md says which call to reach for and why the thumbnail functions exist at all, given the three-step version crosses the FFI boundary three times and holds the full-size pixel buffer in Dart in between.

0.4.1 #

  • Declare the benchmark chart in pubspec.yaml so pub.dev renders it on the package page. The chart was already in the repository and the README, but pub.dev shows only what the screenshots: field points at, so the page a reader lands on from search opened with text where the measurement should have been.

0.4.0 #

  • Add thumbnailJpegAsync and thumbnailPngAsync. They take the same arguments as the synchronous versions and return a Future, running the whole decode, resize and encode on a background isolate with Isolate.run so a large image doesn't block the calling isolate. In a Flutter app this keeps the UI responsive while a picked photo is turned into a thumbnail, which neither the pure-Dart image package nor a synchronous FFI call can do on the main isolate. An ImageFfiException raised in the worker surfaces from the future.

0.3.0 #

  • Add thumbnailPng, a one-call decode, resize, and PNG encode that keeps the alpha channel. Reach for it on logos, icons, screenshots, and anything with transparency, where thumbnailJpeg would flatten the transparent areas onto a background.

0.2.1 #

  • Docs: sharpen the pub.dev description to lead with the value and the terms people search.

0.2.0 #

  • resizePixels now takes a colorSpace (ResizeColorSpace.srgb by default, or .linear). sRGB is right for photographic and UI images; linear is for masks and data pixels where an sRGB curve would distort the values.
  • Fix: 2-channel input is now resampled as grayscale + alpha (STBIR_RA) instead of two colour channels, so edges against transparency stay clean for gray+alpha images. Previously a 2-channel resize let transparent pixels bleed into the colour.

0.1.0 #

  • Initial release.
  • Decode PNG, JPEG, BMP, GIF, PSD, TGA, HDR and PIC from memory (decodeImage), with an optional forced channel count.
  • Read dimensions and channel count without decoding pixels (imageInfo).
  • High-quality, sRGB-correct resize (resizePixels).
  • JPEG and PNG encoding to memory (encodeJpeg, encodePng).
  • One-call thumbnail generation (thumbnailJpeg): decode, aspect-preserving downscale and JPEG encode.
  • Native stb sources compiled from source by a Dart build hook; no prebuilt binaries.
0
likes
0
points
1.27k
downloads

Publisher

verified publisherdeveloperyusuf.com

Weekly Downloads

Fast native image resize, thumbnail and JPEG/PNG encode for Dart over FFI. Several times quicker than the pure-Dart image package; stb-backed, no prebuilt binary.

Repository (GitHub)
View/report issues

Topics

#image #resize #jpeg #thumbnail #ffi

License

unknown (license)

Dependencies

code_assets, ffi, hooks, native_toolchain_c

More

Packages that depend on image_ffi