## File: convert.tex

package info (click to toggle)
imagemagick 6:6.0.6.2-2.9
 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562 \title{ImageMagick - Convert an Image or Sequence of Images} \toctitle{ImageMagick - Convert an Image or Sequence of Images} \titlerunning{ImageMagick - Convert an Image or Sequence of Images} \maketitle\label{ImageMagick - Convert an Image or Sequence of Images} \section{NAME} convert - convert an image or sequence of images \section{Synopsis} {\bf convert} {\bf [} {\it options\/} {\bf ... ]} {\it input\_file output\_file\/} \section{Description} {\bf Convert} converts an input file using one image format to an output file with a differing image format. In addition, various types of image processing can be performed on the converted image during the conversion process. {\bf Convert} recognizes the image formats listed in {\it ImageMagick(1)\/}. \section{Examples} To make a thumbnail of a JPEG image, use: \begin{verbatim} convert -size 120x120 cockatoo.jpg -resize 120x120 +profile "*" thumbnail.jpg \end{verbatim} In this example, {\tt '-size 120x120'} gives a hint to the JPEG decoder that the image is going to be downscaled to 120x120, allowing it to run faster by avoiding returning full-resolution images to ImageMagick for the subsequent resizing operation. The {\tt '-resize 120x120'} specifies the desired dimensions of the output image. It will be scaled so its largest dimension is 120 pixels. The {\tt '+profile "*"'} removes any ICM, EXIF, IPTC, or other profiles that might be present in the input and aren't needed in the thumbnail. To convert a {\it MIFF\/} image of a cockatoo to a SUN raster image, use: \begin{verbatim} convert cockatoo.miff sun:cockatoo.ras \end{verbatim} To convert a multi-page {\it PostScript\/} document to individual FAX pages, use: \begin{verbatim} convert -monochrome document.ps fax:page \end{verbatim} To convert a TIFF image to a {\it PostScript\/} A4 page with the image in the lower left-hand corner, use: \begin{verbatim} convert -page A4+0+0 image.tiff document.ps \end{verbatim} To convert a raw Gray image with a 128 byte header to a portable graymap, use: \begin{verbatim} convert -depth 8 -size 768x512+128 gray:raw image.pgm \end{verbatim} In this example, raw" is the input file. Its format is "gray'' and it has the dimensions and number of header bytes specified by the -size option and the sample depth specified by the -depth option. The output file is image.pgm". The suffix ".pgm'' specifies its format. To convert a Photo CD image to a TIFF image, use: \begin{verbatim} convert -size 1536x1024 img0009.pcd image.tiff convert img0009.pcd[4] image.tiff \end{verbatim} To create a visual image directory of all your JPEG images, use: \begin{verbatim} convert 'vid:*.jpg' directory.miff \end{verbatim} To annotate an image with blue text using font 12x24 at position (100,100), use: \begin{verbatim} convert -font helvetica -fill blue -draw "text 100,100 Cockatoo" bird.jpg bird.miff \end{verbatim} To tile a 640x480 image with a JPEG texture with bumps use: \begin{verbatim} convert -size 640x480 tile:bumps.jpg tiled.png \end{verbatim} To surround an icon with an ornamental border to use with Mosaic(1), use: \begin{verbatim} convert -mattecolor "#697B8F" -frame 6x6 bird.jpg icon.png \end{verbatim} To create a MNG animation from a DNA molecule sequence, use: \begin{verbatim} convert -delay 20 dna.* dna.mng \end{verbatim} \section{Options} Options are processed in command line order. Any option you specify on the command line remains in effect for the set of images that follows, until the set is terminated by the appearance of any option or {\bf -noop}. Some options only affect the decoding of images and others only the encoding. The latter can appear after the final group of input images. For a more detailed description of each option, see {\it ImageMagick(1)\/}. \subsubsection{-adjoin} join images into a single multi-image file \subsubsection{-affine $<$matrix$>$} drawing transformation matrix \subsubsection{-antialias} remove pixel aliasing \subsubsection{-append} append a set of images \subsubsection{-authenticate $<$string$>$} decrypt image with this password \subsubsection{-average} average a set of images \subsubsection{-background $<$color$>$} the background color \subsubsection{-blue-primary $<$x$>$,$<$y$>$} blue chromaticity primary point \subsubsection{-blur $<$radius$>$\{x$<$sigma$>$\}} blur the image with a Gaussian operator \subsubsection{-border $<$width$>$x$<$height$>$} surround the image with a border of color \subsubsection{-bordercolor $<$color$>$} the border color \subsubsection{-box $<$color$>$} set the color of the annotation bounding box \subsubsection{-channel $<$type$>$} Red, Green, Blue, Opacity, Index, Cyan, Yellow, Magenta, Black, or All. Use this option to apply an image-processing option to a particular {\it channel\/} from the image. To specify more than one channel, separate them by commas (e.g. -channel red,green). \subsubsection{-charcoal $<$factor$>$} simulate a charcoal drawing \subsubsection{-clone $<$index$>$} clone an image. \subsubsection{-chop $<$width$>$x$<$height$>$\{+-\}$<$x$>$\{+-\}$<$y$>$\{\%\}} remove pixels from the interior of an image \subsubsection{-clip} clip along the first path from the 8BIM profile if present. Use +clip to reset the clipping path. \subsubsection{-clip-path $<$id$>$} clip along the named paths from the 8BIM profile, if present. Later operations take effect inside the path. Id may be a number if preceded with #, to work on a numbered path, e.g., $-clip-path \#1$ to use the first path. \subsubsection{-coalesce} merge a sequence of images \subsubsection{-colorize $<$value$>$} colorize the image with the pen color \subsubsection{-colors $<$value$>$} preferred number of colors in the image \subsubsection{-colorspace $<$value$>$} the type of colorspace \subsubsection{-comment $<$string$>$} annotate an image with a comment \subsubsection{-compose $<$operator$>$} the type of image composition \subsubsection{-compress $<$type$>$} the type of image compression \subsubsection{-contrast} enhance or reduce the image contrast \subsubsection{-convolve $<$kernel$>$} convolve image with the specified convolution kernel \subsubsection{-crop $<$width$>$x$<$height$>$\{+-\}$<$x$>$\{+-\}$<$y$>$\{\%\}} preferred size and location of the cropped image \subsubsection{-cycle $<$amount$>$} displace image colormap by amount \subsubsection{-debug $<$events$>$} enable debug printout \subsubsection{-deconstruct} break down an image sequence into constituent parts \subsubsection{-delay $<$1/100ths of a second$>$} display the next image after pausing \subsubsection{-delete $<$index$>$} delete image from the image sequence. \subsubsection{-density $<$width$>$x$<$height$>$} vertical and horizontal resolution in pixels of the image \subsubsection{-depth $<$value$>$} depth of the image \subsubsection{-despeckle} reduce the speckles within an image \subsubsection{-display $<$host:display[.screen]$>$} specifies the X server to contact \subsubsection{-dispose $<$method$>$} GIF disposal method \subsubsection{-dither} apply Floyd/Steinberg error diffusion to the image \subsubsection{-draw $<$string$>$} annotate an image with one or more graphic primitives \subsubsection{-edge $<$radius$>$} detect edges within an image \subsubsection{-emboss $<$radius$>$} emboss an image \subsubsection{-encoding $<$type$>$} specify the text encoding \subsubsection{-endian $<$type$>$} specify endianness (MSB or LSB) of output image \subsubsection{-enhance} apply a digital filter to enhance a noisy image \subsubsection{-equalize} perform histogram equalization to the image \subsubsection{-extract $<$width$>$x$<$height$>$\{+-\}$<$x$>$\{+-\}$<$y$>$\{\%\}\{@\} \{{!}\}\{$<$\}\{$>$\}} extract an area from the image while decoding \subsubsection{-fill $<$color$>$} color to use when filling a graphic primitive \subsubsection{-filter $<$type$>$} use this type of filter when resizing an image \subsubsection{-flatten} flatten a sequence of images \subsubsection{-flip} create a mirror image'' \subsubsection{-flop} create a mirror image'' \subsubsection{-font $<$name$>$} use this font when annotating the image with text \subsubsection{-frame $<$width$>$x$<$height$>$+$<$outer bevel width$>$+$<$inner bevel width$>$} surround the image with an ornamental border \subsubsection{-fuzz $<$distance$>$\{\%\}} colors within this distance are considered equal % Utilities: ImageMagick apps=convert,mogrify \subsubsection{-fx $<$expression$>$} apply the mathematical expression an image or image channels. For example, to extract the matte channel of the image (this is the negative to what is commonly thought of as the alpha channel mask of the image), use: convert drawn.png -fx 'a' +matte matte.png Mathematic operators include constants MaxRGB, Opaque, Transparent, Pi standard operators: +, -, *, etc. math function name: abs(), acos(), asin(), atan(), cos(), exp(), log(), ln(), max(), min(), rand(), sin(), sqrt(), tan() symbols: u = first image in sequence v = second image in sequence p = pixel to use (absolute or relative to current pixel) w = width of this image h = height of this image r = red value (from RGBA), of a specific or current pixel g = green '' b = blue '' a = alpha '' c = cyan value of CMYK color of pixel y = yellow '' m = magenta '' k = black '' Specify the image source using an image index represented by u', starting at zero for the first image, (eg: u[3]' is the fourth image in the image sequence). A negative image index counts images from the end of the current image sequence, therefore u[-1]' refers to the last image in the sequence. Without an index u' or v' represent the first and second image of the sequence. If no image is specified, the u' image is used. For example to reduce the intensity of the red channel by 50%, use convert image.png -channel red -fx 'u/2.0' image.jpg The pixels are processed one at a time, but a different pixel of a image can be specified with a pixel index represented by p'. For example, p[-1].g Green value of pixel to the immediate left of current p[-1,-1].r Red value, diagonally left and up from current pixel To specify an absolute position, use braces, rather than brackets p{12,34}.b is the blue pixel at image location 12,34 The other symbols specify the value you wish to retrieve. A pixel outside the boundary of the image has a value dictated by the -virtual-pixel option setting. The -channel setting can be used to specify the output channel of the result. If no output channel is given the result is set over all RGBA channels. For example, suppose you want to replace the red channel of alpha.png with the average of the green channels from the images alpha.png and beta.png, use: convert alpha.png beta.png -channel red \\ -fx '(u.g+v.g)/2' gamma.png Note that all the original images in the current image sequence are replaced by the updated alpha.png' image. \subsubsection{-gamma $<$value$>$} level of gamma correction \subsubsection{-Gaussian $<$radius$>$\{x$<$sigma$>$\}} blur the image with a Gaussian operator \subsubsection{-geometry $<$width$>$x$<$height$>$\{+-\}$<$x$>$\{+-\}$<$y$>$\{\%\}\{@\} \{{!}\}\{$<$\}\{$>$\}} preferred size and location of the Image window. \subsubsection{-gravity $<$type$>$} direction primitive gravitates to when annotating the image. \subsubsection{-green-primary $<$x$>$,$<$y$>$} green chromaticity primary point \subsubsection{-help} print usage instructions \subsubsection{-implode $<$factor$>$} implode image pixels about the center \subsubsection{-innsert $<$index$>$} insert last image into the image sequence \subsubsection{-intent $<$type$>$} use this type of rendering intent when managing the image color \subsubsection{-interlace $<$type$>$} the type of interlacing scheme \subsubsection{-label $<$name$>$} assign a label to an image \subsubsection{-lat $<$width$>$x$<$height$>$\{+-\}$<$offset$>$\{\%\}} perform local adaptive thresholding \subsubsection{-level $<$black\_point$>$\{,$<$white\_point$>$\}\{\%\}\{,$<$gamma$>$\}} adjust the level of image contrast \subsubsection{-limit $<$type$>$ $<$value$>$} Disk, File, Map, or Memory resource limit \subsubsection{-list $<$type$>$} the type of list \subsubsection{-log $<$string$>$} \subsubsection{-loop $<$iterations$>$} add Netscape loop extension to your GIF animation \subsubsection{-map $<$filename$>$} choose a particular set of colors from this image \subsubsection{-mask $<$filename$>$} Specify a clipping mask \subsubsection{-matte} store matte channel if the image has one \subsubsection{-mattecolor $<$color$>$} specify the color to be used with the {\bf -frame} option \subsubsection{-median $<$radius$>$} apply a median filter to the image \subsubsection{-modulate $<$value$>$} vary the brightness, saturation, and hue of an image \subsubsection{-monochrome} transform the image to black and white \subsubsection{-morph $<$frames$>$} morphs an image sequence \subsubsection{-mosaic} create a mosaic from an image or an image sequence \subsubsection{-negate} replace every pixel with its complementary color \subsubsection{-noise $<$radius$|$type$>$} add or reduce noise in an image \subsubsection{-noop} NOOP (no option) \subsubsection{-normalize} transform image to span the full range of color values \subsubsection{-opaque $<$color$>$} change this color to the pen color within the image \subsubsection{-page $<$width$>$x$<$height$>$\{+-\}$<$x$>$\{+-\}$<$y$>$\{\%\}\{{!}\}\{$<$\}\{$>$\}} size and location of an image canvas \subsubsection{-paint $<$radius$>$} simulate an oil painting \subsubsection{-pen $<$color$>$} (This option has been replaced by the -fill option) \subsubsection{-ping} efficiently determine image characteristics \subsubsection{-pointsize $<$value$>$} pointsize of the PostScript, OPTION1, or TrueType font \subsubsection{-preview $<$type$>$} image preview type \subsubsection{-process $<$command$>$} process a sequence of images using a process module. The command argument has the form $module=arg1,arg2,arg3,...,argN$ where $module$ is the name of the module to invoke (e.g. "analyze") and arg1,arg2,arg3,...,argN are an arbitrary number of arguments to pass to the process module. The sequence of images is terminated by the appearance of any option. If the $-process$ option appears after all of the input images, all images are processed. \subsubsection{-profile $<$filename$>$} add ICM, IPTC, or generic profile to image \subsubsection{-quality $<$value$>$} JPEG/MIFF/PNG compression level \subsubsection{-raise $<$width$>$x$<$height$>$} lighten or darken image edges \subsubsection{-red-primary $<$x$>$,$<$y$>$} red chromaticity primary point \subsubsection{-region $<$width$>$x$<$height$>$\{+-\}$<$x$>$\{+-\}$<$y$>$} apply options to a portion of the image \subsubsection{-render} render vector operations \subsubsection{-resample $<$width$>$x$<$height$>$} change the resolution of an image \subsubsection{-resize $<$width$>$x$<$height$>$\{\%\}\{@\}\{{!}\}\{$<$\}\{$>$\}} resize an image \subsubsection{-roll \{+-\}$<$x$>$\{+-\}$<$y$>$} roll an image vertically or horizontally \subsubsection{-rotate $<$degrees$>$\{$<$\}\{$>$\}} apply Paeth image rotation to the image \subsubsection{-sample $<$geometry$>$} scale image with pixel sampling \subsubsection{-sampling-factor $<$horizontal\_factor$>$x$<$vertical\_factor$>$} sampling factors used by JPEG or MPEG-2 encoder and YUV decoder/encoder. \subsubsection{-scale $<$geometry$>$} scale the image. \subsubsection{-scene $<$value$>$} set scene number \subsubsection{-seed $<$value$>$} pseudo-random number generator seed value \subsubsection{-segment $<$cluster threshold$>$x$<$smoothing threshold$>$} segment an image \subsubsection{-shade $<$azimuth$>$x$<$elevation$>$} shade the image using a distant light source \subsubsection{-sharpen $<$radius$>$\{x$<$sigma$>$\}} sharpen the image \subsubsection{-shave $<$width$>$x$<$height$>$\{\%\}} shave pixels from the image edges \subsubsection{-shear $<$x degrees$>$x$<$y degrees$>$} shear the image along the X or Y axis \subsubsection{-size $<$width$>$x$<$height$>$\{+offset\}} width and height of the image \subsubsection{-solarize $<$factor$>$} negate all pixels above the threshold level \subsubsection{-spread $<$amount$>$} displace image pixels by a random amount \subsubsection{-stroke $<$color$>$} color to use when stroking a graphic primitive \subsubsection{-strokewidth $<$value$>$} set the stroke width \subsubsection{-swap $<$index,index$>$} swap two images in the image sequence. \subsubsection{-swirl $<$degrees$>$} swirl image pixels about the center \subsubsection{-texture $<$filename$>$} name of texture to tile onto the image background \subsubsection{-threshold $<$value$>$\{$<$green$>$,$<$blue$>$,$<$opacity$>$\}\{\%\}} threshold the image \subsubsection{-tile $<$filename$>$} tile image when filling a graphic primitive \subsubsection{-tint $<$value$>$} tint the image with the fill color. Tint applies a color vector to each pixel in the image. The length of the vector is 0 for black and white and at its maximum for the midtones. The vector weighting function in between is f(x) = (1-(4.0*((x-0.5)*(x-0.5)))). The dynamic weighting can be controlled by a constant percentage (0..100) given as a value to tint. \subsubsection{-transform} transform the image \subsubsection{-transparent $<$color$>$} make this color transparent within the image \subsubsection{-treedepth $<$value$>$} tree depth for the color reduction algorithm \subsubsection{-trim} trim an image \subsubsection{-type $<$type$>$} the image type \subsubsection{-units $<$type$>$} the type of image resolution \subsubsection{-unsharp $<$radius$>$\{x$<$sigma$>$\}\{+$<$amount$>$\}\{+$<$threshold$>$\}} sharpen the image with an unsharp mask operator \subsubsection{-use-pixmap} use the pixmap \subsubsection{-verbose} print detailed information about the image \subsubsection{-version} print ImageMagick version string \subsubsection{-view $<$string$>$} FlashPix viewing parameters \subsubsection{-virtual-pixel $<$method$>$} specify contents of virtual pixels'' \subsubsection{-wave $<$amplitude$>$x$<$wavelength$>$} alter an image along a sine wave \subsubsection{-white-point $<$x$>$,$<$y$>$} chromaticity white point \subsubsection{-write $<$filename$>$} write an image sequence [{\it convert, composite\/}] For a more detailed description of each option, see {\it ImageMagick(1)\/}. \section{Segmentation} Use {\bf -segment} to segment an image by analyzing the histograms of the color components and identifying units that are homogeneous with the fuzzy c-means technique. The scale-space filter analyzes the histograms of the three color components of the image and identifies a set of classes. The extents of each class is used to coarsely segment the image with thresholding. The color associated with each class is determined by the mean color of all pixels within the extents of a particular class. Finally, any unclassified pixels are assigned to the closest class with the fuzzy c-means technique. The fuzzy c-Means algorithm can be summarized as follows: {\begin{description} \item{ Build a histogram, one for each color component of the image.} \item{ For each histogram, successively apply the scale-space filter and build an interval tree of zero crossings in the second derivative at each scale. Analyze this scale-space fingerprint'' to determine which peaks or valleys in the histogram are most predominant.} \item{ The fingerprint defines intervals on the axis of the histogram. Each interval contains either a minima or a maxima in the original signal. If each color component lies within the maxima interval, that pixel is considered classified'' and is assigned an unique class number.} \item{ Any pixel that fails to be classified in the above thresholding pass is classified using the fuzzy c-Means technique. It is assigned to one of the classes discovered in the histogram analysis phase.} \end{description}} The fuzzy c-Means technique attempts to cluster a pixel by finding the local minima of the generalized within group sum of squared error objective function. A pixel is assigned to the closest class of which the fuzzy membership has a maximum value. For additional information see: {\it Young Won Lim, Sang Uk Lee\/}, {\bf On The Color Image Segmentation Algorithm Based on the Thresholding and the Fuzzy c-Means Techniques}'', Pattern Recognition, Volume 23, Number 9, pages 935-952, 1990. \section{Environment} \subsubsection{DISPLAY} To get the default host, display number, and screen. \section{Authors} {\it John Cristy, ImageMagick Studio LLC,\newline{} Glenn Randers-Pehrson, ImageMagick Studio LLC. \/}