Skip to main content

xcfkit 0.1.1 copy "xcfkit: ^0.1.1" to clipboard
xcfkit: ^0.1.1 copied to clipboard

A pure Dart reader and writer for layered GIMP XCF documents, pixels, masks, and metadata.

example/xcfkit_example.dart

import 'dart:io';
import 'dart:typed_data';

import 'package:xcfkit/xcfkit.dart';

/// Inspects a layered document and optionally writes a reconstructed copy.
Future<void> main(List<String> arguments) async {
  if (arguments.isEmpty) {
    stdout.writeln('Usage: dart run example/xcfkit_example.dart input.xcf [output.xcf]');
    return;
  }
  final XcfDocument document = XcfCodec.decode(await File(arguments.first).readAsBytes());
  stdout.writeln('${document.width} × ${document.height}, ${document.precision.name}, ${document.layers.length} layers');
  for (final XcfLayer layer in document.layers) {
    stdout.writeln('${layer.isGroup ? 'Group' : 'Layer'}: ${layer.name}, offset (${layer.x}, ${layer.y}), mode ${layer.mode}');
    if (!layer.isGroup && layer.raster != null) {
      final Uint8List rgba = XcfPixels.rgba8(document, layer);
      stdout.writeln('  ${rgba.length} RGBA8 preview bytes in the source profile and transfer encoding');
    }
  }
  if (arguments.length > 1) {
    await File(arguments[1]).writeAsBytes(XcfCodec.encode(document));
  }
}
0
likes
160
points
65
downloads
screenshot

Documentation

API reference

Publisher

verified publisherfocale-editor.app

Weekly Downloads

A pure Dart reader and writer for layered GIMP XCF documents, pixels, masks, and metadata.

Repository (GitHub)
View/report issues
Contributing

Topics

#gimp #xcf #image-processing #codec #file-format

License

MIT (license)

Dependencies

xml, zcodec

More

Packages that depend on xcfkit