Dart 이미지 라이브러리는 서버 및 웹 애플리케이션에서 여러 형식의 이미지를 로드하고 조작하며 저장할 수 있도록 합니다. 크기 조정, 자르기, 색상 조정 및 포맷 변환과 같은 일반적인 작업을 지원하여 원본 플랫폼 도구에 의존하지 않고 이미지 처리 작업에 적합합니다. 이 라이브러리는 가볍고 Android, iOS, Web, macOS, Windows, Linux에서 Flutter 앱 사용을 위해 설계되었습니다. 백엔드 이미지 변환 또는 동적으로 썸네일 생성에 특히 유용합니다.
사용 사례
이미지 크기 조정 및 자르기
미리보기 생성
이미지 형식 변환
서버 측 이미지 처리
웹 앱에서의 동적 이미지 조작
주요 기능
여러 이미지 형식을 지원합니다
크로스 플랫폼 호환성
가볍고 빠름
내장 이미지 필터
확장 가능한 이미지 처리 파이프라인
적합한 대상
백엔드 이미지 처리
웹 기반 이미지 도구
이미지 조작이 필요한 Flutter 앱
자동화된 이미지 워크플로우
이미지 편집 기능을 구축하는 개발자
고려 사항
실시간 UI 렌더링에 최적화되지 않음
고급 이미지 효과에 대한 제한된 지원
큰 파일의 수동 처리가 필요합니다
내장 캐시 없음
비상호작용 이미지 작업에 가장 적합
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Dart Image Library
Overview
The Dart Image Library provides the ability to load, save, and
manipulate images
in a variety of image file formats.
The library can be used with both dart:io and dart:html, for command-line, Flutter, and
web applications.
NOTE: 4.0 is a major revision from the previous version of the library.
Create an image, set pixel values, save it to a PNG.
import'dart:io';
import'package:image/image.dart'as img;
voidmain() async {
// Create a 256x256 8-bit (default) rgb (default) image.final image = img.Image(width: 256, height: 256);
// Iterate over its pixelsfor (var pixel in image) {
// Set the pixels red value to its x position value, creating a gradient.
pixel..r = pixel.x
// Set the pixels green value to its y position value.
..g = pixel.y;
}
// Encode the resulting image to the PNG image format.final png = img.encodePng(image);
// Write the PNG formatted data to a file.awaitFile('image.png').writeAsBytes(png);
}
To asynchronously load an image file, resize it, and save it as a thumbnail:
import'package:image/image.dart'as img;
voidmain(List<String> args) async {
final path = args.isNotEmpty ? args[0] : 'test.png';
final cmd = img.Command()
// Decode the image file at the given path
..decodeImageFile(path)
// Resize the image to a width of 64 pixels and a height that maintains the aspect ratio of the original.
..copyResize(width: 64)
// Write the image to a PNG file (determined by the suffix of the file path).
..writeToFile('thumbnail.png');
// On platforms that support Isolates, execute the image commands asynchronously on an isolate thread.// Otherwise, the commands will be executed synchronously.await cmd.executeThread();
}