FLUTTER ECOSYSTEM

zsoerenm/fast_image_resizer

zsoerenm/fast_image_resizer open-source repository details.

fast_image_resizer 프로젝트 이미지
Stars
0
Forks
3
최근 푸시(UTC)
2022. 8. 4.
프로젝트 상태
활성
Soeren Schoenbrod GitHub avatar
GITHUB User

Soeren Schoenbrod ↗

RWTH Aachen UniversityAachen
언어Dart

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 3 개
  • flutter{"sdk":"flutter"}
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^1.0.0

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

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