首頁文件分類網站建置CentOS使用 ImageMagick Convert 轉換功能
使用 ImageMagick Convert 轉換功能

使用轉換程序在圖像格式之間進行轉換,以及調整圖像大小,模糊,裁剪,去除斑點,抖動,繪製,翻轉,連接,重新採樣等等。

有關如何構造轉換命令的建議,請參閱命令行處理,或參見下列的命令範例用法。

/usr/local/ImageMagick/bin/magick convert -help
/usr/local/ImageMagick/bin/magick convert -list list

在此列出一些 convert 命令的範例,以說明其有用性和易用性。


首先,先將 JPEG 格式的圖片轉換為 PNG 格式:

/usr/local/ImageMagick/bin/magick convert rose.jpg rose.png

接著,再將圖片大小寫入 PNG 格式之前縮小圖片尺寸:

/usr/local/ImageMagick/bin/magick convert rose.jpg -resize 50% rose.png

再者,可以組合多個圖像處理操作用以生成複雜的結果:

/usr/local/ImageMagick/bin/magick convert -size 320x85 canvas:none -font STIX-Bold -pointsize 72 -draw "text 25,60 Magick" -channel RGBA -blur 0x6 -fill darkred -stroke magenta -draw "text 20,55 Magick" fuzzy-magick.png

或者,改善放大圖片的品質:

/usr/local/ImageMagick/bin/magick convert input.png -colorspace RGB +sigmoidal-contrast 11.6933 -define filter:filter=Sinc -define filter:window=Jinc -define filter:lobes=3 -resize 400% -sigmoidal-contrast 11.6933 -colorspace sRGB output.png

可以在 Examples of ImageMagick Usage 中找到使用 convert 的其他範例。


選項摘要

-adaptive-blur geometryadaptively blur pixels; decrease effect near edges
-adaptive-resize geometryadaptively resize image with data dependent triangulation.
-adaptive-sharpen geometryadaptively sharpen pixels; increase effect near edges
-adjoinjoin images into a single multi-image file
-affine matrixaffine transform matrix
-alphaon, activate, off, deactivate, set, opaque, copy, transparent, extract, background, or shape the alpha channel
-annotate geometry textannotate the image with text
-antialiasremove pixel-aliasing
-appendappend an image sequence
-authenticate valuedecipher image with this password
-auto-gammaautomagically adjust gamma level of image
-auto-levelautomagically adjust color levels of image
-auto-orientautomagically orient image
-auto-threshold methodautomatically perform image thresholding
-background colorbackground color
-bench iterationsmeasure performance
-bias valueadd bias when convolving an image
-black-threshold valueforce all pixels below the threshold into black
-blue-primary pointchromaticity blue primary point
-blue-shift factorsimulate a scene at nighttime in the moonlight
-blur geometryreduce image noise and reduce detail levels
-border geometrysurround image with a border of color
-bordercolor colorborder color
-brightness-contrast geometryimprove brightness / contrast of the image
-canny geometryuse a multi-stage algorithm to detect a wide range of edges in the image
-caption stringassign a caption to an image
-cdl filenamecolor correct with a color decision list
-channel typeapply option to select image channels
-charcoal radiussimulate a charcoal drawing
-chop geometryremove pixels from the image interior
-clampset each pixel whose value is below zero to zero and any the pixel whose value is above the quantum range to the quantum range (e.g. 65535) otherwise the pixel value remains unchanged.
-clipclip along the first path from the 8BIM profile
-clip-mask filenameassociate clip mask with the image
-clip-path idclip along a named path from the 8BIM profile
-clone indexclone an image
-clutapply a color lookup table to the image
-connected-components connectivityconnected-components uniquely labeled, choose from 4 or 8 way connectivity
-contrast-stretch geometryimprove the contrast in an image by `stretching' the range of intensity value
-coalescemerge a sequence of images
-colorize valuecolorize the image with the fill color
-color-matrix matrixapply color correction to the image.
-colors valuepreferred number of colors in the image
-colorspace typeset image colorspace
-combinecombine a sequence of images
-comment stringannotate image with comment
-comparecompare image
-complexoperatorperform complex mathematics on an image sequence
-compose operatorset image composite operator
-compositecomposite image
-compress typeimage compression type
-contrastenhance or reduce the image contrast
-convolve coefficientsapply a convolution kernel to the image
-copy geometry offsetcopy pixels from one area of an image to another
-crop geometrycrop the image
-cycle amountcycle the image colormap
-decipher filenameconvert cipher pixels to plain
-debug eventsdisplay copious debugging information
-define format:optiondefine one or more image format options
-deconstructbreak down an image sequence into constituent parts
-delay valuedisplay the next image after pausing
-delete indexdelete the image from the image sequence
-density geometryhorizontal and vertical density of the image
-depth valueimage depth
-despecklereduce the speckles within an image
-direction typerender text right-to-left or left-to-right
-display serverget image or font from this X server
-dispose methodlayer disposal method
-distribute-cache portlaunch a distributed pixel cache server
-distort type coefficientsdistort image
-dither methodapply error diffusion to image
-draw stringannotate the image with a graphic primitive
-duplicate count,indexesduplicate an image one or more times
-edge radiusapply a filter to detect edges in the image
-emboss radiusemboss an image
-encipher filenameconvert plain pixels to cipher pixels
-encoding typetext encoding type
-endian typeendianness (MSB or LSB) of the image
-enhanceapply a digital filter to enhance a noisy image
-equalizeperform histogram equalization to an image
-evaluate operator valueevaluate an arithmetic, relational, or logical expression
-evaluate-sequence operatorevaluate an arithmetic, relational, or logical expression for an image sequence
-extent geometryset the image size
-extract geometryextract area from image
-family namerender text with this font family
-features distanceanalyze image features (e.g. contract, correlations, etc.).
-fftimplements the discrete Fourier transform (DFT)
-fill colorcolor to use when filling a graphic primitive
-filter typeuse this filter when resizing an image
-flattenflatten a sequence of images
-flipflip image in the vertical direction
-floodfill geometry colorfloodfill the image with color
-flopflop image in the horizontal direction
-font namerender text with this font
-format stringoutput formatted image characteristics
-frame geometrysurround image with an ornamental border
-function nameapply a function to the image
-fuzz distancecolors within this distance are considered equal
-fx expressionapply mathematical expression to an image channel(s)
-gamma valuelevel of gamma correction
-gaussian-blur geometryreduce image noise and reduce detail levels
-geometry geometrypreferred size or location of the image
-gravity typehorizontal and vertical text placement
-grayscale methodconvert image to grayscale
-green-primary pointchromaticity green primary point
-helpprint program options
-hough-lines geometryidentify lines in the image
-identifyidentify the format and characteristics of the image
-iftimplements the inverse discrete Fourier transform (DFT)
-implode amountimplode image pixels about the center
-insert indexinsert last image into the image sequence
-intensity methodmethod to generate an intensity value from a pixel
-intent typetype of rendering intent when managing the image color
-interlace typetype of image interlacing scheme
-interline-spacing valuethe space between two text lines
-interpolate methodpixel color interpolation method
-interword-spacing valuethe space between two words
-kerning valuethe space between two characters
-kuwahara geometryedge preserving noise reduction filter
-label stringassign a label to an image
-lat geometrylocal adaptive thresholding
-layers methodoptimize or compare image layers
-level valueadjust the level of image contrast
-limit type valuepixel cache resource limit
-linear-stretch geometrylinear with saturation histogram stretch
-liquid-rescale geometryrescale image with seam-carving
-list typeColor, Configure, Delegate, Format, Magic, Module, Resource, or Type
-log formatformat of debugging information
-loop iterationsadd Netscape loop extension to your GIF animation
-mattecolor colorframe color
-median radiusapply a median filter to the image
-mean-shift geometrydelineate arbitrarily shaped clusters in the image
-metric typemeasure differences between images with this metric
-mode radiusmake each pixel the 'predominant color' of the neighborhood
-modulate valuevary the brightness, saturation, and hue
-momentsdisplay image moments.
-monitormonitor progress
-monochrometransform image to black and white
-morph valuemorph an image sequence
-morphology method kernelapply a morphology method to the image
-motion-blur geometrysimulate motion blur
-negatereplace each pixel with its complementary color
-noise radiusadd or reduce noise in an image
-normalizetransform image to span the full range of colors
-opaque colorchange this color to the fill color
-ordered-dither NxNordered dither the image
-orient typeimage orientation
-page geometrysize and location of an image canvas (setting)
-paint radiussimulate an oil painting
-perceptibleset each pixel whose value is less than |epsilon| to -epsilon or epsilon (whichever is closer) otherwise the pixel value remains unchanged.
-pingefficiently determine image attributes
-pointsize valuefont point size
-polaroid anglesimulate a Polaroid picture
-poly termsbuild a polynomial from the image sequence and the corresponding terms (coefficients and degree pairs).
-posterize levelsreduce the image to a limited number of color levels
-precision valueset the maximum number of significant digits to be printed
-preview typeimage preview type
-print stringinterpret string and print to console
-process image-filterprocess the image with a custom image filter
-profile filenameadd, delete, or apply an image profile
-quality valueJPEG/MIFF/PNG compression level
-quantize colorspacereduce image colors in this colorspace
-quietsuppress all warning messages
-radial-blur angleradial blur the image
-raise valuelighten/darken image edges to create a 3-D effect
-random-threshold low, highrandom threshold the image
-range-threshold low-black, low-white, high-white, high-blackperform either hard or soft thresholding within some range of values in an image
-read-mask filenameassociate a read mask with the image
-red-primary pointchromaticity red primary point
-regard-warningspay attention to warning messages.
-region geometryapply options to a portion of the image
-remap filenametransform image colors to match this set of colors
-renderrender vector graphics
-repage geometrysize and location of an image canvas
-resample geometrychange the resolution of an image
-resize geometryresize the image
-respect-parenthesessettings remain in effect until parenthesis boundary.
-roll geometryroll an image vertically or horizontally
-rotate degreesapply Paeth rotation to the image
-sample geometryscale image with pixel sampling
-sampling-factor geometryhorizontal and vertical sampling factor
-scale geometryscale the image
-scene valueimage scene number
-seed valueseed a new sequence of pseudo-random numbers
-segment valuessegment an image
-selective-blur geometryselectively blur pixels within a contrast threshold
-separateseparate an image channel into a grayscale image
-sepia-tone thresholdsimulate a sepia-toned photo
-set attribute valueset an image attribute
-shade degreesshade the image using a distant light source
-shadow geometrysimulate an image shadow
-sharpen geometrysharpen the image
-shave geometryshave pixels from the image edges
-shear geometryslide one edge of the image along the X or Y axis
-sigmoidal-contrast geometryincrease the contrast without saturating highlights or shadows
-smush offsetsmush an image sequence together
-size geometrywithh and height of image
-sketch geometrysimulate a pencil sketch
-solarize thresholdnegate all pixels above the threshold level
-splice geometrysplice the background color into the image
-spread radiusdisplace image pixels by a random amount
-statistic type geometryreplace each pixel with corresponding statistic from the neighborhood
-stripstrip image of all profiles and comments
-stroke colorgraphic primitive stroke color
-strokewidth valuegraphic primitive stroke width
-stretch typerender text with this font stretch
-style typerender text with this font style
-swap indexesswap two images in the image sequence
-swirl degreesswirl image pixels about the center
-synchronizesynchronize image to storage device
-taintmark the image as modified
-texture filenamename of texture to tile onto the image background
-threshold valuethreshold the image
-thumbnail geometrycreate a thumbnail of the image
-tile filenametile image when filling a graphic primitive
-tile-offset geometryset the image tile offset
-tint valuetint the image with the fill color
-transformaffine transform image
-transparent colormake this color transparent within the image
-transparent-color colortransparent color
-transposeflip image in the vertical direction and rotate 90 degrees
-transverseflop image in the horizontal direction and rotate 270 degrees
-treedepth valuecolor tree depth
-trimtrim image edges
-type typeimage type
-undercolor colorannotation bounding box color
-unique-colorsdiscard all but one of any pixel color.
-units typethe units of image resolution
-unsharp geometrysharpen the image
-verboseprint detailed information about the image
-versionprint version information
-viewFlashPix viewing transforms
-vignette geometrysoften the edges of the image in vignette style
-virtual-pixel methodaccess method for pixels outside the boundaries of the image
-wave geometryalter an image along a sine wave
-wavelet-denoise thresholdremoves noise from the image using a wavelet transform
-weight typerender text with this font weight
-white-point pointchromaticity white point
-white-threshold valueforce all pixels above the threshold into white
-write filenamewrite images to this file
-write-mask filenameassociate a write mask with the image

參考資料:

Command-line Tools: Convert @ ImageMagick

http://www.imagemagick.org/script/convert.php

首頁文件分類網站建置CentOS使用 ImageMagick Convert 轉換功能