Pakete, Repositories und App-Kategorien suchen

Paketdetailsv1.0.1

jpeg_encode

Ein minimalistischer JPEG-Encoder.

AndroidiOSWebmacOSWindowsLinux
30-Tage-Downloads
4900
Likes
19
Pub-Punkte
120

Paket installieren

flutter pub add jpeg_encode

Paketübersicht

Aus öffentlichen Paketdaten erstellte Orientierung.

Ein minimalistischer JPEG-Encoder für Flutter, der Entwicklern die Komprimierung und Kodierung von Bildern im JPEG-Format auf mehreren Plattformen ermöglicht. Mit Fokus auf Einfachheit entwickelt, bietet er eine leichtgewichtige Lösung zur Umwandlung von Bilddaten in JPEG ohne komplexe Abhängigkeiten. Ideal für Anwendungen, die eine effiziente Bildkompression oder Speicherung von Bildern in einem weit verbreiteten Format benötigen. Das Paket unterstützt Android, iOS, Web, macOS, Windows und Linux und gewährleistet breite Kompatibilität. Besonders nützlich in Szenarien, in denen die Dateigröße kritisch ist.

Anwendungsfälle

  • Bildkompression in mobilen Apps
  • Gespeicherte Fotos als JPEG speichern
  • Verkleinerung der Bilddateigröße für Web-Uploads
  • Batch-Verarbeitung von Bilddateien
  • Integration der JPEG-Codierung in plattformübergreifende Anwendungen

Hauptmerkmale

  • Leichtgewichtiges und minimales API
  • Plattformübergreifende Unterstützung
  • Einfache Kodierung aus Bilddaten
  • Effiziente Kompression
  • Keine externen nativen Abhängigkeiten

Geeignet für

  • Entwickler, die grundlegende JPEG-Codierung benötigen
  • Auf Bildoptimierung fokussierte Apps
  • Plattformübergreifende Multimedia-Anwendungen
  • Projekte, die kleine Encoder erfordern

Hinweise

  • Nur auf JPEG-Format beschränkt
  • Keine erweiterten Kodierungsoptionen wie Qualitätsanpassung
  • Nicht geeignet für komplexe Bildverarbeitung
  • Abhängig von den Bildverarbeitungsfähigkeiten der zugrunde liegenden Plattform

Original-README

Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.

JPEG encoder

pub package

Skia, the engine behind dart:ui has no support for JPEG, only PNG and raw RGBA. And the source code comments make it clear that they don't intend to add any more formats, those should be left to external packages.

While there are packages that offer full support for image manipulation, many a time we don't need that, just to be able to convert a file to JPG for use outside of our app, maybe to send it to the web. This package does that and nothing else. It's a minimalistic JPEG encoder that doesn't offer any extra functionality but to create the simplest JPEG file. Not necessarily the best or most compressed one, although it's fairly good, nonetheless.

The code is just a straight Dart port of an existing implementation of Jon Olick from https://www.jonolick.com/code.html.

How to use

Let's suppose you have a dart:ui Image from somewhere, maybe you converted from an incoming image:

import "dart:ui" as ui;

Uint8List bytes;
final codec = await ui.instantiateImageCodec(bytes);
final frame = await codec.getNextFrame();
final image = frame.image;

And you want to convert it to JPG (quality is between 0 and 100, as usual):

final data = await image.toByteData(format: skia.ImageByteFormat.rawRgba);
final jpg = JpegEncoder().compress(data!.buffer.asUint8List(), image.width, image.height, 90);

In other words, the pixel array is expected to be in row major format (all columns of first row, then of the second row, etc), four bytes for each pixel: R, G, B and A. Alpha is ignored but the byte is expected to be there. Consequently, the length of the array has to be width * height * 4.

Before you ask, saving in Flutter is as simple as:

File(path).writeAsBytesSync(jpg); // or
await File(path).writeAsBytes(jpg);

Support

If you like this package, please consider supporting it.

Buy Me A Book

Kategorien

Quell-Repository

Projekte, die dieses Paket verwenden

Noch keine Daten verfügbar.