shell-批量裁剪各个尺寸的图教程一(ImageMagick安装配置)

我为什么要做这个?

最近在测试广告系统,做图文类的广告测试,经常要上传与广告位置相同的广告素材,会涉及图片素材,做性能测试或是多数据量的测试时候,还为了区分内容好检查,所以需要首先制作符合广告位置的图片一批保存在本地,再上传到素材库,前期测试的时候,我上网找了裁剪图片的站长工具,这里不做推荐了,但站长工具有些缺点,无论是从功能上还是操作效率上都无法满足个人需求,所以决定在centos上利用ImageMagick的convent来对一批原因做裁剪。

首先,我们要在centos下安装ImageMagick。

ImageMagick 是一个用来创建、编辑、合成图片的软件。它可以读取、转换、写入多种格式的图片。图片切割、颜色替换、各种效果的应用,图片的旋转、组合,文本,直线, 多边形,椭圆,曲线,附加到图片伸展旋转。

此次用的Imagemagick版本为7.0.2-9.

 安装步骤:

1、全部用yum 先装好jpg png gif这些包 再装webp 再装ImageMagick

yum install:
giflib-devel
libtiff-devel
libjpeg-devel
libpng-devel

 2、支持JP2,JPC格式---安装jasper-1.701.0.zip

unzip jasper-1.701.0.zip&&cd jasper-1.701.0
./configure --enable-shared
make&&make install

 3、支持JPEG格式---安装jpegsrc.v6b.tar.gz

tar zxvf jpegsrc.v6b.tar.gz&&cd jpeg-6b
./configure --enable-shared
make&&make install
64位系统机器的安装方法:
cp /usr/share/libtool/config.guess .
cp /usr/share/libtool/config.sub .
./configure --enable-shared --enable-static
make libdir=/usr/lib64
make libdir=/usr/lib64 install

4、支持tiff格式---安装tiff-3.8.2.tar.gz

tar zxvf tiff-3.8.2.tar.gz&&cd tiff-3.8.2
./configure 
make&&make install

5、支持freetype2---安装freetype-2.3.12.zip

 

unzip freetype-2.3.12.zip&&cd freetype-2.3.12
./configure
make&&make install

 6、支持png格式---安装libpng-1.2.40.tar

tar zxvf libpng-1.2.40.tar&&cd libpng-1.2.40
cp scripts/makefile.linux   ./makefile
make&&make install

7、支持JBIG格式---安装jbigkit-1.5.tar.gz

tar zxvf jbigkit-1.5.tar.gz&&cd jbigkit
make CFLAGS="-O3 -fPIC" 
make test
CFLAGS=-fPIC
make 
cd libjbig
cp jbig85.h  jbig_ar.h  jbig.h /usr/local/include/ 
cp jbig85.o  jbig_ar.o  jbig.o  libjbig85.a  libjbig.a  tstcodec85.o  tstcodec.o  /usr/local/lib
cp jbig85.o  jbig_ar.o  jbig.o  libjbig85.a  libjbig.a  tstcodec85.o  tstcodec.o  /usr/local/lib64

8、支持webp格式---安装libwebp-0.5.1.tar.gz

tar -zxvf libwebp-0.5.1.tar.gz
./autogen.sh
./configure
make&&make install

9、安装GraphicsMagick-1.3.25.tar.gz

tar zxvf GraphicsMagick-1.3.25.tar.gz
./configure --enable-share=yes
make&&make install

9、安装ImageMagick-7.0.2-9.zip

./configure --prefix=/usr/local/ --enable-shared  --enable-lzw
64位系统
./configure --without-jbig --enable-lzw --without-tiff
make&&make install

测试Imagemagick版本是否正常

[root@xx-xx BAK]# /usr/local/bin/bin/convert -version
/usr/local/bin/bin/convert: /usr/local/lib/libpng12.so.0: no version information available (required by /usr/local/bin/lib/libMagickCore-7.Q16HDRI.so.0)
Version: ImageMagick 7.0.2-9 Q16 x86_64 2018-09-21 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP 
Delegates (built-in): fontconfig freetype jbig jng jpeg png tiff webp x xml zlib

 不要被这么多步骤所吓退了,其实执行好简单,只要安装包在本地,按我上面的步骤踏踏实实装下去。就不会有啥问题。

附上所有安装包下载地址:

 链接:https://pan.baidu.com/s/1ra6fvaC2-cd33iaO3yy-mg 密码:2b3l

工具准备齐全,开始写shell和执行了,继续看,超简单。

 

 

 

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Version: ImageMagick 6.7.6-7 2012-04-20 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC Features: OpenMP Usage: convert.exe [options ...] file [ [options ...] file ...] [options ...] file Image Settings: -adjoin join images into a single multi-image file -affine matrix affine transform 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 -direction type render text right-to-left or left-to-right -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 -interline-spacing value set the space between two text lines -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 -precision value maximum number of significant digits to print -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 -synchronize synchronize image to storage device -taint declare the image as modified -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-gamma automagically adjust gamma level of image -auto-level automagically adjust color levels of image -auto-orient automagically orient (rotate) 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 -brightness-contrast geometry improve brightness / contrast of the image -cdl filename color correct with a color decision list -charcoal radius simulate a charcoal drawing -chop geometry remove pixels from the image interior -clamp restrict pixel range from 0 to the quantum depth -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 -color-matrix matrix apply color correction to the image -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 arithmetic, relational, or logical expression -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 parameters apply function over image values -gamma value level of gamma correction -gaussian-blur geometry reduce image noise and reduce detail levels -geometry geometry preferred 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 with the given colors -linear-stretch geometry improve contrast by `stretching with saturation' -liquid-rescale geometry rescale image with seam-carving -median geometry apply a median filter to the image -mode geometry make each pixel the 'predominant color' of the neighborhood -modulate value vary the brightness, saturation, and hue -monochrome transform image to black and white -morphology method kernel apply a morphology method to the image -motion-blur geometry simulate motion blur -negate replace every pixel with its complementary color -noise geometry 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 -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 -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 -statistic type geometry replace each pixel with corresponding statistic from the neighborhood -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 -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 -evaluate-sequence operator evaluate an arithmetic, relational, or logical expression -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 -print string interpret string and print to console -process arguments process the image with a custom image filter -separate separate an image channel into a grayscale image -smush geometry smush an image sequence together -write filename write images to this file Image Stack Operators: -clone indexes clone an image -delete indexes delete the image from the image sequence -duplicate count,indexes duplicate an image one or more times -insert index insert last image into the image sequence -reverse reverse 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 By default, the image format of `file' is determined by its magic number. To specify a particular image format, precede the filename with an image format name and a colon (i.e. ps:image) or specify the image type as the filename suffix (i.e. image.ps). Specify 'file' as '-' for standard input or output.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值