搜索插件、代码仓与 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

所属分类

源码仓库

使用此插件的项目