FLUTTER ECOSYSTEM

brendan-duncan/image

विभिन्न छवि फ़ाइल प्रारूपों को खोलने, संशोधित करने और सहेजने के लिए डार्ट छवि पुस्तकालय।

छवि प्रोजेक्ट कवर
Stars
1.3 हज़ार
Forks
306
अंतिम पुश (UTC)
17 सित॰ 2026
प्रोजेक्ट स्थिति
सक्रिय
Brendan Duncan GitHub avatar
GITHUB User

Brendan Duncan ↗

Graphics engineer who loves working on side projects to continue learning. Everything here is for my personal amusement.

Santa Fe, NM
भाषाएँDartCSSHTMLJavaScriptBatchfile

तकनीकी विषय

इस रिपॉज़िटरी के पैकेज

उपयोग की गई निर्भरताएँ

निर्भरता सूची 8 आइटम
  • archive^4.0.9
  • build_runnerडेवलपमेंट^2.15.0
  • build_testडेवलपमेंट^3.5.15
  • httpडेवलपमेंट^1.6.0
  • intlडेवलपमेंट^0.20.2
  • lintsडेवलपमेंट^6.1.0
  • testडेवलपमेंट^1.31.1
  • webडेवलपमेंट^1.1.1

रैंकिंग

मूल README

यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।

README खोलें / बंद करें

Dart Image Library

Dart CI pub package

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.

Documentation

Supported Image Formats

Read/Write

  • JPG
  • PNG / Animated PNG
  • GIF / Animated GIF
  • BMP
  • TIFF
  • TGA
  • PVR
  • ICO
  • WebP / Animated WebP (lossless and lossy)

Read Only

  • PSD
  • EXR
  • PNM (PBM, PGM, PPM)

Write Only

  • CUR

Examples

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();
}