Imagick Picture Processing

Source: Internet
Author: User
Tags imagemagick

ImageMagick is a free software that creates, edits, and synthesizes pictures. It can read, convert, and write images in many formats. Picture cutting, color substitution, application of various effects, picture rotation, composition, text, line, polygon, ellipse, curve, attach to the picture stretching rotation. Its all open source, can be free to use, copy, modify, release. It complies with the GPL license agreement. It can run on most operating systems.

Most importantly, the use of most of ImageMagick's features comes from command-line tools.

ImageMagick, GraphicsMagick commands at a glance

----------------------------------------------------------------------------

[Convert | identify | mogrify | composite | montage | compare | display | animate | import | conjure]

Convert: Transform image format and size, blur, crop, banish stains, jitter, proximity, picture pictures, add new images, generate thumbnails, etc.
Identify: Describes the format and characteristics of one or more image files.
Mogrify: According to the specified size * * * An image, blur, crop, jitter and so on. Mogrify overwrites the original image file and then writes to a different image file.
Composite: Creates a picture based on a picture or multiple picture combinations.
Montage: Create some separate feature images. Any decorative images that contain feature images, such as borders, structures, picture names, and so on.
Compare: Evaluate different pictures in arithmetic and visually * * * other makeover pictures.
Display: If you have an X server system, it can show the picture in a sequential order
Animate: Display animated pictures with X server
Import: Prints the picture file on X server or any visible window. You can capture a single window, the entire screen or a rectangular portion of any screen.
Conjure: Explains the script executed by the MSL (Magick Scripting Language).

Example One: synthetic operation (ImageMagick)

    1. Convert-crop 300x300+0+0 -resize 200x200-colors +profile "*" 1. jpg C8>1. png


explanation of the processing process:

1, the current directory 1.jpg picture file, from the upper left corner (0,0) coordinates as the starting point, cutting a piece of 300x300 pixels.

2. Then reduce the part to 200x200 pixels.

3, then reduce the color to 100 colors.
4, +profile "*" means that the image file does not store EXIF information to reduce the volume of the picture.

5, the final generation of 1.png, saved in the current directory.


Note:-resize will try to preserve the original length-to-width ratio, so it does not necessarily generate a picture that matches the size you specify, such as if the 2.jpg size is 400x200, so if you use the command: Convert 2.jpg-resize 100x100 2.png, Then the actual size of the generated picture 2.png is 100x50.

Common parameters Use Description:
-crop width x Height + start axis + start ordinate: crop graph
-resize width x Height!: Change the size, if using an exclamation point, indicating that the visual scale is not retained, forcibly changing the size to match the given width and height, if only a width or height is given, such as "width X" or "X high" (The effect of "X high" and "width × height" is the same), The dimension is scaled proportionally to the known parameter.
-colors Number of colors: Set the number of colors used in the image, if it is generated PNG or GIF pictures should specify this parameter
-quality quality: Set JPEG image output quality, recommended to use 80, this command only for the output format is JPG, should not be omitted, the default quality is 95, the resulting picture is too large
+profile "*": Image does not store EXIF information, must be used, otherwise generate pictures too large

example two: generating thumbnails (ImageMagick command line)----------------------------------------------------------------------------


    1. Convert-sample 80x40 input.jpg output.jpg (using a simple algorithm to generate thumbnails, fast, low-quality, suitable for generating images below 100x100)

    2. Convert-resize 100x100 foo.jpg thumbnail.jpg (good quality)

    3. Convert-resize %x50% foo.jpg thumbnail.jpg

    4. Convert-resize 100x200 jpg (picture path) One- to-one JPG (the zoomed-in storage path) picture proportionally scaled

    5. Convert-resize 100x200\! A. jpg (picture path) one-by-one. jpg (to hold the path after zooming) forces the zoom to a given width and height

example three: crop a picture (ImageMagick command line)------------------------------------------------------------------------- ---

Convert-crop (Long) x200 (h) +ten(x coordinate) +ten(y) jpg ( source picture path) one. jpg ( Store path after scaling)

example four: Rotate an image (ImageMagick command line)------------------------------------------------------------------------- ---

    1. Convert-rotate input.jpg output.jpg

Example Five: Get file information (ImageMagick command line)-------------------------------------------------------------------- -------

    1. Libtiff Tiffinfo Filename.tiff

Example six: Turning a picture into a black and white color

    1. Convert-monochrome Foo.png Bar.png

Add Image Watermark processing (ImageMagick command line)
--------------------------------
Suppose you add a watermark icon named Logo.gif to the lower-right corner of the original picture (Src.jpg), and the bottom edge of the watermark is 10 pixels from the original picture, and the right edge is 5 pixels from the original picture. You can use the following command:

    1. Convert src.jpg logo.gif-gravity southeast-geometry +5+ -composite dest.jpg

Add an English text watermark (ImageMagick command line)

-----------------------------------------------------
Convert-fill white-pointsize 24-draw "text 10,15 ' Lifesinger 2006 '" 1.png 2.png

Text coordinates in: 10x50 's position
You can specify fonts with-font, and you need to install Ghostscript support.

If you install IM, GM, do not install Ghostscript font, will default to use the Linux system font, directory is:/usr/share/fonts/default/type1/


add Chinese text watermark (ImageMagick command line)

-----------------------------------------------------

Methods for high-version ImageMagick

-------------------

Convert-font C:\ImageMagick\font\fangzheng.ttf-fill green-pointsize 40-draw "text 10,50 ' text '" D:\bagImg\21.jpg d:\bag Img\22.jpg

Parameter description:-font C:\ImageMagick\font\fangzheng.ttf is a font file that indicates Windows.

To a higher version of the ImageMagick, in addition to the Chinese text watermark is not garbled.


Imagick Picture Processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.