v7.1.2-34 Latest Stable Release

Command-line Tools: Stream

Stream one or more pixel components of the image or portion of the image to your choice of storage formats

quickstart.sh
# Install via your favorite Package Manager
$ brew install imagemagick
# Convert PNG to WebP with compression
$ magick input.png -quality 85 output.webp
# Resize image maintaining aspect ratio
$ magick input.jpg -resize 800x600^ output.jpg

stream is a lightweight tool to stream one or more pixel components of an image or portion of an image to your choice of storage formats. It writes pixel components as they are read from the input image a row at a time, making it ideal when working with large images or when raw pixel components are required.

Example Usage

Below are practical examples demonstrating how to use the stream command. To get started, let's stream the red, green, and blue components of a 640x480 JPEG image to disk as unsigned characters:

stream-rgb.sh
# Stream RGB pixels to raw unsigned character data
$ magick stream -map rgb -storage-type char image.jpg pixels.dat
# Display the generated raw pixel file
$ magick display -depth 8 -size 640x480 rgb:pixels.dat

Here we extract a 100x100 region from a TIFF image in grayscale format as double-precision floating-point numbers:

stream-extract.sh
# Extract 100x100 region with offsets X=30, Y=40
$ magick stream -map i -storage-type double -extract 100x100+30+40 image.tif gray.raw

You can also associate the region to extract directly within the input image filename:

stream-inline.sh
# Inline geometry selection
$ magick stream -map i -storage-type double 'image.tif[100x100+30+40]' gray.raw

Option Summary

The stream command recognizes the following options. Select an option link for detailed documentation.

Option Description
-authenticate value Decrypt image with this password
-channel type Apply option to select image channels
-colorspace type Set image colorspace
-debug events Display copious debugging information
-define format:option Define one or more image format options
-density geometry Horizontal and vertical density of the image
-depth value Image depth
-extract geometry Extract area from image
-help Print program options
-interlace type Type of image interlacing scheme
-interpolate method Pixel color interpolation method
-limit type value Pixel cache resource limit
-list type Color, Configure, Delegate, Format, Magic, Module, Resource, or Type
-log format Format of debugging information
-map components Store pixels in this format
-monitor Monitor progress
-quantize colorspace Reduce image colors in this colorspace
-quiet Suppress all warning messages
-regard-warnings Pay attention to warning messages
-respect-parentheses Settings remain in effect until parenthesis boundary
-sampling-factor geometry Horizontal and vertical sampling factor
-seed value Seed a new sequence of pseudo-random numbers
-set attribute value Set an image attribute
-size geometry Width and height of image
-storage-type type Store pixels with this storage type
-synchronize Synchronize image to storage device
-taint Mark the image as modified
-transparent-color color Transparent color
-verbose Print detailed information about the image
-version Print version information
-virtual-pixel method Access method for pixels outside the boundaries of the image