image
Dart 이미지 라이브러리는 서버 및 웹 앱에서 다양한 이미지 파일 형식의 이미지를 로드하고 조작하며 저장할 수 있는 기능을 제공합니다.
다양한 이미지 파일 형식을 열고 조작하고 저장하기 위한 Dart 이미지 라이브러리입니다.
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
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.
Read/Write
Read Only
Write Only
Create an image, set pixel values, save it to a PNG.
import 'dart:io';
import 'package:image/image.dart' as img;
void main() async {
// Create a 256x256 8-bit (default) rgb (default) image.
final image = img.Image(width: 256, height: 256);
// Iterate over its pixels
for (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.
await File('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;
void main(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();
}
의존성 목록 8 개
^4.0.9^2.15.0^3.5.15^1.6.0^0.20.2^6.1.0^1.31.1^1.1.1사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗