convert-----Linux中的图片处理工具

以前使用R作图的时候,一直很忧虑怎么将两个图片拼接在一起,有一些是可以做到的,但是可能是自己了解的比较少,这样成功的例子比较少,但是现在发现一个很好的工具就是convert,这个的存在完美的解决了这个问题
首先先看一下convert的参数
Image Settings:
-adjoin 将图像连接到单个多图像文件中
-affine matrix 仿射变换矩阵
-alpha option activate, deactivate, reset, or set the alpha channel
-antialias remove pixel-aliasing
-authenticate password
decipher image with this password
-attenuate value lessen (or intensify) when adding noise to an image
-background color background color
-bias value add bias when convolving an image
-black-point-compensation
use black point compensation
-blue-primary point chromaticity blue primary point
-bordercolor color border color
-caption string assign a caption to an image
-channel type apply option to select image channels
-colors value preferred number of colors in the image
-colorspace type alternate image colorspace
-comment string annotate image with comment
-compose operator set image composite operator
-compress type type of pixel compression when writing the image
-define format:option
define one or more image format options
-delay value display the next image after pausing
-density geometry horizontal and vertical density of the image
-depth value image depth
-display server get image or font from this X server
-dispose method layer disposal method
-dither method apply error diffusion to image
-encoding type text encoding type
-endian type endianness (MSB or LSB) of the image
-family name render text with this font family
-fill color color to use when filling a graphic primitive
-filter type use this filter when resizing an image
-font name render text with this font
-format “string” output formatted image characteristics
-fuzz distance colors within this distance are considered equal
-gravity type horizontal and vertical text placement
-green-primary point chromaticity green primary point
-intent type type of rendering intent when managing the image color
-interlace type type of image interlacing scheme
-interpolate method pixel color interpolation method
-interword-spacing value
set the space between two words
-kerning value set the space between two letters
-label string assign a label to an image
-limit type value pixel cache resource limit
-loop iterations add Netscape loop extension to your GIF animation
-mask filename associate a mask with the image
-mattecolor color frame color
-monitor monitor progress
-orient type image orientation
-page geometry size and location of an image canvas (setting)
-ping efficiently determine image attributes
-pointsize value font point size
-preview type image preview type
-quality value JPEG/MIFF/PNG compression level
-quiet suppress all warning messages
-red-primary point chromaticity red primary point
-regard-warnings pay attention to warning messages
-remap filename transform image colors to match this set of colors
-respect-parentheses settings remain in effect until parenthesis boundary
-sampling-factor geometry
horizontal and vertical sampling factor
-scene value image scene number
-seed value seed a new sequence of pseudo-random numbers
-size geometry width and height of image
-stretch type render text with this font stretch
-stroke color graphic primitive stroke color
-strokewidth value graphic primitive stroke width
-style type render text with this font style
-taint image as ineligible for bi-modal delegate
-texture filename name of texture to tile onto the image background
-tile-offset geometry
tile offset
-treedepth value color tree depth
-transparent-color color
transparent color
-undercolor color annotation bounding box color
-units type the units of image resolution
-verbose print detailed information about the image
-view FlashPix viewing transforms
-virtual-pixel method
virtual pixel access method
-weight type render text with this font weight
-white-point point chromaticity white point

Image Operators:
-adaptive-blur geometry
adaptively blur pixels; decrease effect near edges
-adaptive-resize geometry
adaptively resize image using ‘mesh’ interpolation
-adaptive-sharpen geometry
adaptively sharpen pixels; increase effect near edges
-alpha option on, activate, off, deactivate, set, opaque, copy
transparent, extract, background, or shape
-annotate geometry text
annotate the image with text
-auto-orient automatically orient image
-bench iterations measure performance
-black-threshold value
force all pixels below the threshold into black
-blue-shift factor simulate a scene at nighttime in the moonlight
-blur geometry reduce image noise and reduce detail levels
-border geometry surround image with a border of color
-bordercolor color border color
-cdl filename color correct with a color decision list
-charcoal radius simulate a charcoal drawing
-chop geometry remove pixels from the image interior
-clip clip along the first path from the 8BIM profile
-clip-mask filename associate a clip mask with the image
-clip-path id clip along a named path from the 8BIM profile
-colorize value colorize the image with the fill color
-contrast enhance or reduce the image contrast
-contrast-stretch geometry
improve contrast by stretching' the intensity range -convolve coefficients apply a convolution kernel to the image -cycle amount cycle the image colormap -decipher filename convert cipher pixels to plain pixels -deskew threshold straighten an image -despeckle reduce the speckles within an image -distort method args distort images according to given method ad args -draw string annotate the image with a graphic primitive -edge radius apply a filter to detect edges in the image -encipher filename convert plain pixels to cipher pixels -emboss radius emboss an image -enhance apply a digital filter to enhance a noisy image -equalize perform histogram equalization to an image -evaluate operator value evaluate an expression over image values -extent geometry set the image size -extract geometry extract area from image -fft implements the discrete Fourier transform (DFT) -flip flip image vertically -floodfill geometry color floodfill the image with color -flop flop image horizontally -frame geometry surround image with an ornamental border -function name paramters apply function over image values -gamma value level of gamma correction -gaussian-blur geometry reduce image noise and reduce detail levels -geometry geometry perferred size or location of the image -identify identify the format and characteristics of the image -ift implements the inverse discrete Fourier transform (DFT) -implode amount implode image pixels about the center -lat geometry local adaptive thresholding -layers method optimize, merge, or compare image layers -level value adjust the level of image contrast -level-colors color,color level image using given colors -linear-stretch geometry improve contrast bystretching with saturation’
-liquid-rescale geometry
rescale image with seam-carving
-median radius apply a median filter to the image
-modulate value vary the brightness, saturation, and hue
-monochrome transform image to black and white
-motion-blur geometry
simulate motion blur
-negate replace every pixel with its complementary color
-noise radius add or reduce noise in an image
-normalize transform image to span the full range of colors
-opaque color change this color to the fill color
-ordered-dither NxN
add a noise pattern to the image with specific
amplitudes
-paint radius simulate an oil painting
-polaroid angle simulate a Polaroid picture
-posterize levels reduce the image to a limited number of color levels
-print string interpret string and print to console
-profile filename add, delete, or apply an image profile
-quantize colorspace reduce colors in this colorspace
-radial-blur angle radial blur the image
-raise value lighten/darken image edges to create a 3-D effect
-random-threshold low,high
random threshold the image
-recolor matrix translate, scale, shear, or rotate image colors
-region geometry apply options to a portion of the image
-render render vector graphics
-repage geometry size and location of an image canvas
-resample geometry change the resolution of an image
-resize geometry resize the image
-roll geometry roll an image vertically or horizontally
-rotate degrees apply Paeth rotation to the image
-sample geometry scale image with pixel sampling
-scale geometry scale the image
-segment values segment an image
-selective-blur geometry
selectively blur pixels within a contrast threshold
-sepia-tone threshold
simulate a sepia-toned photo
-set property value set an image property
-shade degrees shade the image using a distant light source
-shadow geometry simulate an image shadow
-sharpen geometry sharpen the image
-shave geometry shave pixels from the image edges
-shear geometry slide one edge of the image along the X or Y axis
-sigmoidal-contrast geometry
increase the contrast without saturating highlights or shadows
-sketch geometry simulate a pencil sketch
-solarize threshold negate all pixels above the threshold level
-sparse-color method args
fill in a image based on a few color points
-splice geometry splice the background color into the image
-spread radius displace image pixels by a random amount
-strip strip image of all profiles and comments
-swirl degrees swirl image pixels about the center
-threshold value threshold the image
-thumbnail geometry create a thumbnail of the image
-tile filename tile image when filling a graphic primitive
-tint value tint the image with the fill color
-transform affine transform image
-transparent color make this color transparent within the image
-transpose flip image vertically and rotate 90 degrees
-transverse flop image horizontally and rotate 270 degrees
-trim trim image edges
-type type image type
-unique-colors discard all but one of any pixel color
-unsharp geometry sharpen the image
-vignette geometry soften the edges of the image in vignette style
-wave geometry alter an image along a sine wave
-white-threshold value
force all pixels above the threshold into white

Image Sequence Operators:
-append append an image sequence
-average average an image sequence
-clut apply a color lookup table to the image
-coalesce merge a sequence of images
-combine combine a sequence of images
-composite composite image
-crop geometry cut out a rectangular region of the image
-deconstruct break down an image sequence into constituent parts
-flatten flatten a sequence of images
-fx expression apply mathematical expression to an image channel(s)
-hald-clut apply a Hald color lookup table to the image
-morph value morph an image sequence
-mosaic create a mosaic from an image sequence
-process arguments process the image with a custom image filter
-reverse reverse image sequence
-separate separate an image channel into a grayscale image
-write filename write images to this file

Image Stack Operators:
-clone index clone an image
-delete index delete the image from the image sequence
-insert index insert last image into the image sequence
-swap indexes swap two images in the image sequence

Miscellaneous Options:
-debug events display copious debugging information
-help print program options
-list type print a list of supported option arguments
-log format format of debugging information
-version print version information

1、如何得到一个图片的尺寸大小,输入这样的命令

identify 1.png

1.png PNG 2000x1200 2000x1200+0+0 16-bit DirectClass 21.7kb
2、拼图
横向拼接

convert 1.png 2.png +append result1.png

这样图片就变成了一行两列的图了
纵向拼接

convert 1.png 2.png -append result2.png

这样图片就变成了两行一列的图了
3、放大缩小

convert -resize 100x100 1.png n.png

100x100是图片的尺寸,也可以用百分比,50%x50%
4、图片翻转
上下翻转:

convert -flip 1.png 2.png

左右翻转:

convert -flop 1.png 2.png

1.png 是原始的图片,而2.png是翻转之后的图片
5、单色
把图片变为黑白颜色:

convert -monochrome 1.png 2.png

6、加噪声

convert -noise 3 1.png 2.png

7、油画效果
我们可以用这个功能,把一张普通的图片,变成一张油画,效果非常的逼真

convert -paint 4 1.png 2.png

8、旋转
把一张图片,旋转一定的角度:

convert -rotate 30 1.png 2.png

上面的30,表示向右旋转30度,如果要向左旋转,度数就是负数
9、炭笔效果

convert -charcoal 2 1.png 2.png

形成炭笔或者说是铅笔画的效果。
10、散射
1)毛玻璃效果:

convert -spread 30 1.png 2.png

2)漩涡
以图片的中心作为参照,把图片扭转,形成漩涡的效果:

convert -swirl 67 1.png 2.png

3)凸起效果
用-raise来创建凸边:

convert -raise 5x5 1.png 2.png
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 在Linux合成两张图片可以使用ImageMagick软件包提供的convert命令。以下是合成两张图片的代码示例: ```bash convert image1.jpg image2.jpg +append output.jpg ``` 这个命令将会把两张图片按照水平方向并排合成在一起,并输出为一个新的图片文件"output.jpg"。如果要将两张图片垂直方向拼接,只需要将"+append"换成"-append"即可。 需要注意的是,ImageMagick软件包需要提前安装。在Ubuntu或Debian等基于apt包管理的系统,可以通过以下命令安装: ```bash sudo apt install imagemagick ``` 其他Linux系统可以使用对应的包管理器进行安装。 ### 回答2: 在Linux,我们可以使用一些图像处理库和命令工具来合成两张图片。 一种常见的方法是使用ImageMagick库。首先,我们需要安装ImageMagick,并确保convert命令可用。然后,我们可以使用以下命令将两张图片合成为一张: ``` convert image1.jpg image2.jpg +append output.jpg ``` 这个命令会将image1.jpg和image2.jpg按照水平方向(横向)进行合并,并将结果保存为output.jpg。如果要进行垂直方向(纵向)的合并,可以使用"-append"参数: ``` convert image1.jpg image2.jpg -append output.jpg ``` 除了ImageMagick,还有其他一些图像处理库和工具可以实现图像合成的功能。例如,OpenCV是一个广泛使用的图像处理库,可以通过编写代码来实现图像合成。以下是使用OpenCV库的一个示例代码: ```python import cv2 image1 = cv2.imread('image1.jpg') image2 = cv2.imread('image2.jpg') combined_image = cv2.hconcat([image1, image2]) # 水平合并 cv2.imwrite('output.jpg', combined_image) ``` 这段代码首先使用cv2.imread函数从文件读取两张图片,然后使用cv2.hconcat函数将图片水平合并。最后,使用cv2.imwrite将合并后的结果保存为output.jpg文件。 无论使用ImageMagick还是OpenCV,我们都可以根据实际需求调整代码和参数来实现不同的图像合成效果。 ### 回答3: 在Linux进行合成两张图片的操作可以通过使用图像处理库或者命令工具来实现。以下是使用命令工具ImageMagick来合成两张图片的示例代码: 1. 安装ImageMagick: 在终端执行以下命令安装ImageMagick: ``` sudo apt update sudo apt install imagemagick ``` 2. 合成两张图片: 首先,将要合成的两张图片放在同一个目录下。然后,在终端进入该目录并执行以下命令: ``` convert -composite image1.jpg image2.jpg -gravity center output.jpg ``` 其,`image1.jpg`和`image2.jpg`为要合成的两张图片的文件名,`output.jpg`为合成后的图片的输出文件名。 这个命令的`-gravity center`表示在合成过程将两张图片对齐,可以根据需要修改参数来调整对齐方式。 3. 查看合成结果: 合成完成后,可以在该目录下找到输出文件,可以使用图片查看器或命令工具来查看合成后的图片: ``` eog output.jpg ``` 以上是使用ImageMagick命令工具来合成两张图片的示例代码,你也可以使用其他图像处理库或工具来实现相似的功能。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值