image_magick 1.0.0 copy "image_magick: ^1.0.0" to clipboard
image_magick: ^1.0.0 copied to clipboard

Dart client for ImageMagick process-based inspect, resize, convert, and format discovery workflows.

image_magick #

image_magick is a Dart client for running ImageMagick through dart:io process calls on macOS or Linux. It gives you a small typed API for:

  • checking whether ImageMagick is available
  • quickly checking whether a file is a readable image
  • listing supported readable image formats
  • inspecting an image
  • cropping to an exact region
  • resizing while preserving aspect ratio
  • converting into WebP or other output formats
  • rotating and flipping images
  • stripping metadata from output files

Install ImageMagick #

macOS #

With Homebrew:

brew install imagemagick

Verify the install:

magick -version

If your system exposes the legacy commands instead, these should also work:

convert -version
identify -version

Docker #

For Debian or Ubuntu based images:

RUN apt-get update && apt-get install -y imagemagick

A slightly cleaner variant is:

RUN apt-get update \
  && apt-get install -y imagemagick \
  && rm -rf /var/lib/apt/lists/*

Add The Package #

dart pub add image_magick

Usage #

import 'package:image_magick/image_magick.dart';

Future<void> main() async {
  bool supported = await ImageMagickClient.isSupported();
  if (!supported) {
    throw StateError('ImageMagick is not installed or is not on PATH.');
  }

  ImageMagickClient client = ImageMagickClient();

  List<String> formats = await client.getSupportedFormats();
  print(formats);

  ImageMagickImageInfo original = await client.inspect(
    inputPath: '/tmp/input.png',
  );
  print(original);

  ImageMagickImageInfo resized = await client.resize(
    inputPath: '/tmp/input.png',
    outputPath: '/tmp/output.webp',
    width: 1200,
    height: 1200,
    onlyShrink: true,
    quality: 82,
    format: 'webp',
  );
  print(resized);

  bool readable = await client.canRead(inputPath: '/tmp/input.png');
  print(readable);

  ImageMagickImageInfo cropped = await client.crop(
    inputPath: '/tmp/input.png',
    outputPath: '/tmp/cropped.png',
    width: 800,
    height: 800,
    x: 100,
    y: 50,
    format: 'png',
  );
  print(cropped);

  ImageMagickImageInfo converted = await client.convert(
    inputPath: '/tmp/input.png',
    outputPath: '/tmp/output.jpg',
    format: 'jpeg',
    quality: 85,
  );
  print(converted);

  ImageMagickImageInfo rotated = await client.rotate(
    inputPath: '/tmp/input.png',
    outputPath: '/tmp/rotated.png',
    degrees: 90,
    format: 'png',
  );
  print(rotated);

  ImageMagickImageInfo stripped = await client.stripMetadata(
    inputPath: '/tmp/input.png',
    outputPath: '/tmp/clean.webp',
    format: 'webp',
  );
  print(stripped);
}

API Notes #

  • ImageMagickClient.isSupported() checks for either the modern magick command or the legacy convert and identify pair.
  • canRead() is a lightweight identify -ping probe for quick validation.
  • crop() uses exact pixel bounds and resets the page with +repage.
  • resize() uses ImageMagick geometry rules, so aspect ratio is preserved automatically.
  • resize() requires at least one of width or height.
  • convert() forces the requested output format with the ImageMagick format:path syntax.
  • rotate(), flipHorizontal(), and flipVertical() are thin wrappers around stable ImageMagick transform flags.
  • stripMetadata() removes comments, EXIF, ICC profiles, and other embedded metadata with -strip.
  • inspect() returns ImageMagickImageInfo, which includes the path, format, width, height, and MIME type when ImageMagick reports one.
  • ImageMagickClient.legacy() is available if you want to explicitly target convert and identify.
0
likes
150
points
93
downloads

Documentation

API reference

Publisher

verified publisherarcane.art

Weekly Downloads

Dart client for ImageMagick process-based inspect, resize, convert, and format discovery workflows.

Repository (GitHub)
View/report issues

License

GPL-3.0 (license)

More

Packages that depend on image_magick