搜尋套件、儲存庫與 APP 分類

套件詳情v0.0.2

fast_image_resizer

使用原生實作調整影像大小。僅支援 PNG 為輸出格式。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
2840
喜歡數
19
Pub 分數
160

安裝套件

flutter pub add fast_image_resizer

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Fast Image Resizer 是一個 Flutter 套件,可在多個平台使用原生實作來有效調整影像大小。它專注於以最小開銷實現高效率的影像縮放,提供最佳化結果。此套件僅支援 PNG 輸出格式,非常適合需要壓縮且高品質 PNG 的應用程式。專為速度與可靠性設計,可無縫整合至注重多媒體編輯、壓縮或影像處理工作流程的應用中。其跨平台相容性確保在 Android、iOS、Web、macOS、Windows 及 Linux 上行為一致。

適用情境

  • 圖像縮略圖生成
  • 優化圖像以用於網路傳輸
  • 減少圖像檔案大小以節省儲存空間
  • 預處理影像以供應用顯示
  • 批量圖像調整大小在媒體應用中

主要特色

  • 所有平台的原生效能
  • 僅 PNG 輸出格式
  • 跨平台相容性
  • 最小記憶體使用量
  • 簡單的 API 用於調整大小
  • 快速執行,低延遲

適合對象

  • 需要快速圖像處理的應用程式
  • 注重性能的開發者
  • 專注於PNG輸出的項目
  • 媒體密集型應用
  • 需要圖像優化的Web和移動應用

使用建議

  • 僅輸出 PNG 檔案
  • 僅限調整大小操作
  • 不支援其他影像格式
  • 需要仔細處理大圖像
  • 不適用於複雜的圖像變換

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

fast_image_resizer

This package uses native implementations to resize an image. It should be fast compared to the image package. It only supports PNG as output at the moment.

This package has zero dependencies.

Features

  • Supported inputs: JPEG, PNG, GIF, Animated GIF, WebP, Animated WebP, BMP, and WBMP
  • Supported outputs: PNG

Getting started

Add fast_image_resizer to your pubspec.yaml

Usage

import 'package:fast_image_resizer/fast_image_resizer.dart';
import 'dart:typed_data';
final rawImage = await rootBundle.load('assets/someImage.png');
final bytes = await resizeImage(Uint8List.view(rawImage.buffer), width: 150);
if (bytes != null) {
    final imageWidget = Image.memory(Uint8List.view(bytes.buffer));
    showDialog(
        context: context,
        builder: (BuildContext context) {
            return AlertDialog(
            title: const Text("Image"),
            content: imageWidget,
            );
        }
    );
}

or

final ImagePicker _picker = ImagePicker();
final XFile? image =
    await _picker.pickImage(source: ImageSource.gallery);
if (image != null) {
    final rawImage = await image.readAsBytes();
    final bytes = await resizeImage(Uint8List.view(rawImage.buffer), height: 250);
    if (bytes != null) {
        final testing = Image.memory(Uint8List.view(bytes.buffer));
        showDialog(
            context: context,
            builder: (BuildContext context) {
                return AlertDialog(
                    title: Text("Image"),
                    content: testing,
                );
            }
        );
    }
}

Known Issues

  • This currently does not work on web, because of this issue: https://github.com/flutter/flutter/issues/34075

所屬分類

原始碼儲存庫

使用此套件的專案