First, what is Imagemagick?
ImageMagick is a free open source image editing software. Either from the command line, or by C / C ++, Perl, Java, PHP, Python or Ruby programming library to complete the call. Focus ImageMagic focused on performance, reduce the bug and provide a stable API and ABI on.
Second, download and install
Windows are an example here
Using the 16-bit 8-bit slower than 15 to 50% in processing the image memory is also doubled. Such as dealing with a 1024x768 pixel image you want to use 8-bit 3.6M memory, 16-bit to use 7.2M of memory.
Here we have chosen to download the official recommended file, which is the first one: ImageMagick-7.0.8-12-Q16-x64-dll.exe
This version 7.0 and 6:00 a few different versions of some system environment variables are automatically configured.
Use magick --version to see if the installation was successful:
Third, the use
If many sub-command can not be used directly, you can put them as magick sub-command, such as:
identify bbb.png
magick identify bbb.png
1, format conversion
magick test.jpg test.png
Save this image to represent a test.jpg as test.png, also modify the picture name and format
(Png lot smaller than the original jpg
2, synthetic gif
magick a.jpg b.jpg c.jpg test.gif
magick *.jpg images.gif
The synthesis of a specified picture gif (like the size of whichever of the first figure)
3, adjust the picture size
Proportionally change
magick b.png -resize 200% b1.png magick convert b.png -resize 200% b1.png magick convert -resize 200% b.png b1.png
Image width extended to 2 times the original, high shrink by half
magick convert b.png -resize 200x50% b7.png magick convert b.png -resize 200%x50% b8.png
Width is adjusted to 100, the high aspect ratio of the image according to the original adjustment followed
convert -resize 100 b.png b15.png
Height adjustment is 200, according to the original picture aspect ratio of the width adjustment follow
convert -resize x200 b.png b16.png
4, remove an image embedded in all profiles
magick convert -strip 1.jpg
5, crop
crop an image parameter can be divided into blocks of the same size image
magick img1.jpg -crop 500x500 dest.jpg
For example, the original image size of 1920x1200, 12 can be divided images, note that if size is not an integer multiple of the target image, the image portion of the right and lower edges on the actual size of
Cutting a predetermined size of the original image on the panel
magick img1.jpg -crop 600x450+300+600 dest.jpg
600x450 is wide by + 300 + 600 is a cross ordinate
6, inverted picture
magick convert a.jpg -negate canny.jpg
7, the compressed picture
The picture quality is reduced to the original 10% (i.e. 90% compression off), ranging from 1 (lowest image quality and highest compression rate) to 100 (highest image quality and minimum compression rate), the default value according to an output format there are 75,92,100, options are available for JPEG / MIFF / PNG.
magick convert -quality 80 1.jpg 2.jpg
Example: create thumbnail:
-resize, thumbnail size defined output; -quality 70, reduce the quality of the thumbnail is 70%; - strip: Let thumbnail images embedded remove all configuration files, comments and other information, in order to reduce the file size.
magick convert -resize 100x200 -quality 70 -strip 1.jpg 2.jpg
8, add borders to images
Set the border color is blue (can also use the rgb (0,0,255) or rgb (0%, 0%, 100%) instead), a wide frame and a high frame width is 5%, 5% higher, respectively, in other words, the picture height and width have increased by 10%
magick 1.jpg -bordercolor blue -border 5% 2.jpg
9, filters
magick convert monochrome .jpg -monochrome monochrome_example.jpg magick convert charcoal .jpg -charcoal 1.2 charcoal _example.jpg
-monochrome No configuration options; however -charcoal need to set up a relevant factor, about 1 to achieve a similar effect charcoal painting.
magick convert a.jpg -edge 3 edge.jpg magick convert a.jpg -colors 2 color.jpg
Reduced to 2 colors, these options can also be used together.
10, edge detection
magick convert a.jpg -canny 1 canny.jpg
Canny algorithm used with coarse parameter.
The image is inverted, then on a good read:
magick convert a.jpg -canny 1 -negate canny.jpg
Reference links:
1. https://www.cnblogs.com/wbxk/p/9794094.html
2. https://blog.csdn.net/qq_24127015/article/details/86523738
3. https://blog.csdn.net/wangmeitingaa/article/details/88885711