The Convert to Linux command

Source: Internet
Author: User
Tags bmp image delete key imagemagick

The Convert to Linux command

Powerful convert command
The convert command can be used to transform the format of images, support jpg, BMP, PCX, GIF, PNG, TIFF, xpm and XWD types, and here are a few examples:
Convert xxx.jpg xxx.png convert JPEG to PNG file
Convert xxx.gif xxx.bmp converts GIF to BMP image
Convert Xxx.tiff XXX.PCX converts TIFF to PCX image
You can also change the size of the image:
Convert-resize 1024x768 xxx.jpg xxx1.jpg Change the image pixel to 1024x768, note that between 1024 and 768 is a lowercase letter X
Convert-sample 50%x50% xxx.jpg xxx1.jpg Reduce the image to the original 50%*50%
To rotate an image:
Convert-rotate sky.jpg sky-final.jpg Rotate the image clockwise 270 degrees
You can also add text to the image using the-draw option:
Convert-fill black-pointsize 60-font helvetica-draw ' text 10,80 "Hello, world!" ' Hello.jpg helloworld.jpg
Write Hello on the 10,80 position of the image in a 60-pound all-black Helvetica font, world!
Convert has many other interesting and powerful features that you may wish to try.

Pending edit ...


A few simple applications.

1. Batch image format conversion

If you want to convert all the JPG files in a directory to a PNG file, simply type in the command-line mode:

For%f in (*.jpg) do convert "%f" "%~nf.png"

2. Perform the same operation on all images

For example, bulk generate thumbnails of all PNG image files in a directory (size 80x40):

For%f in (*.png) do convert "%f"-sample 80x40 "%~nf_sample.png"

Similarly, the operation to rotate all PNG images in a directory by 90 degrees is:

For%f in (*.png) do convert "%f"-rotate "%~nf_rotate.png"

can also be batch cutting, fade, jitter, carbonization, add borders, rounded corners, and so on a series of operations, specifically, refer to: linux/l-graf/index.html ">http://www.ibm.com/developerworks/cn/linux/ L-graf/index.html

Http://linux.chinaunix.net/docs/2006-12-15/3481.shtml

3. Add a text description to the image

If you have a large number of images to publish, it would be wise to add a copyright note to all the images. It is easy to implement with Imgemagick:

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

You can specify fonts with-font, you need to install Ghostscript support: http://www.cs.wisc.edu/~ghost/

You can also use the composite command to add watermarks to all images, interested to see here:

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

—————————————————————————————————————————–

Convert

Convert image formats and sizes, 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

Make an image, blur, crop, jitter, etc. according to the specified size. Mogrify overwrites the original image file and then writes to a different image file.

Composite

Create a picture based on one 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 and other reconstructed pictures mathematically and visually.

Display

If you have an X server system, it can display the picture in a sequential order

Animate

Display animated pictures with X server

Import

Output a 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 execution of a script written by the MSL (Magick Scripting Language).

Convert-sample 100x20 input.jpg output.jpg

The above command generates a 100x20 thumbnail image

A better approach is to scale with equal proportions, like this, to uniformly generate a 1/4 thumbnail image.

Convert-sample 25%x25% input.jpg output.jpg

If you write a script, it's like this.

for IMG in ' LS *.jpg '

Do

Convert-sample 25%x25% ${img} thm${img}

Done

Fill picture

Convert-font Fonts/font.ttf-stroke color-fill color-pointsize size

-draw ' text 10,10 "String" ' Input.jpg output.jpg

-font Specifies the font, because then I raise the text,

-stroke the color of the stroke,

-fill fill with the color, here with none can draw hollow words,

-pointsize raise font size, number of pixels,

-draw is used to draw, here is the text, below the position 10,10 is the picture in the upper left corner for the original point sitting

Add a text comment to an image

Sometimes you need to add a text comment to the image. For example, suppose your company has a standard business card image and wants to add each employee's details to a business card before sending it to the printer. Another example is to generate a presentation certificate (presentation certificate) for users who are using online courses on your site.

You can annotate the diagram with some identifying information by using the following command line:

Convert-font Helvetica-fill white-pointsize 36

-draw ' Text 10,50 "Floriade 2002, Canberra, Australia" '

Floriade.jpg comment.jpg

So far, this is the most complex convert command line I've shown in this article, so I'll take some time to explain it.

-font Helvetica Sets the font of the annotation to Helvetica. You can also specify the path to the font file here. This example adds a tag to the image so that the image is no longer available to other sites without permission, but it does this by using a font that is located in a nonstandard location:

Convert-font Fonts/1900805.ttf-fill white-pointsize 36

-draw ' text 10,475 "stillhq.com"

Floriade.jpg stillhq.jpg

-fill White fills the letters with whites rather than standard black.

-pointsize 36 Specifies the size of the letter in points. An inch equals 72 points.

-draw ' text 10,50 ' ... ' is a set of drawing commands, in this case move to position 10, 50, and then draw the text in double quotation marks. Use single quotation marks because if you need to draw more than one word, you need to use double quotes in the drawing command, and you cannot double quotation marks in double quotes.

Execute multiple commands in a single ImageMagick call

You have seen examples of linking commands to annotation examples. However, you can link any of the ImageMagick commands that are mentioned in this article. For example, maybe we want to make a thumbnail of an image and then apply divergence to it. After the divergence occurs, we will apply the charcoal effect:

Convert-sample 25%x25%-spread 4

-charcoal 4 input.jpg output.jpg

Use convert to add a border to a picture

Convert-raise 5x5 input.jpg output.jpg

Convert +raise 5x5 input.jpg output.jpg

The above command with-,+ edge color to achieve the effect of processing edge!

Convert-bordercolor red-border 5x5 input.jpg output.jpg

Simple plus 5 pixels wide red edge!

Convertconvert as the name implies is the transformation of the image, it is mainly used to convert the image format, but also can do zoom, cut, blur, inversion and other operations.

Format conversions such as converting foo.jpg to Foo.png:

Convert foo.jpg foo.png If you want to convert all the JPG files in the directory to GIF, we can take advantage of the shell's powerful features:

Find./-name "*.jpg"-exec convert {} {}.gif \; The converted GIF name is *.jpg.gif, so it doesn't look natural, it's okay, we can take another step:

Rename. jpg.gif. gif *. Jpg.gif Originally, I want to find in the time, with basename to get the file name without a suffix, so it will not form. Jpg.gif this ugly name, but don't know why, is not, if you know, tell me or, you can also use the shell Script to do the above:

For I in *.jpg

Do

Convert $i ' basename $i. jpg '. gif

Done we also use mogrify to accomplish the same effect:

Mogrify-format PNG *.jpg The above command will convert all JPG files below the directory into PNG format. Convert can also convert multiple photos into PDF format:

Convert *.jpg foo.pdf size Scaling For example, we want to make a thumbnail for a normal-sized picture, so we can

Convert-resize 100x100 foo.jpg thumbnail.jpg You can also use percentages, which are more intuitive:

Convert-resize 50%x50% foo.jpg Thumbnail.jpgconvert automatically considers the height-to-width ratio of the image when scaling the image, meaning that the new image has the same aspect ratio as the original. We can also generate thumbnails in batches:

Mogrify-sample 80x60 *.jpg Note that this command will overwrite the original image, but you can back up your picture before you start the operation.

Add a border around a picture with a border, you can use the-mattecolor parameters, such as a comrade sacrificed, we need to make a black border for him portrait, can be:

Convert-mattecolor "#000000"-frame 60x60 yourname.jpg rememberyou.png where, "#000000 ″ is the color of the border, the size of the border is 60x60 you can also add a border like this:

Convert-border 60x60-bordercolor "#000000" yourname.jpg rememberyou.png add text to the picture

Convert-fill green-pointsize 40-draw ' text 10,50 "charry.org" ' foo.png bar.png the above command in the distance from the upper left corner of the picture 10x50 position, Write the charry.org in green, and if you want to specify a different font, you can use the-font parameter.

Fuzzy Gaussian Blur:

Convert-blur foo.jpg Foo.png-blur parameter can also-blur 80x5. The latter 5 represents the value of sigma, which is an image term, and I'm not sure, in short, its value plays a key role in blurring the effect.

Flip Upside down:

Convert-flip foo.png bar.png Flip around:

Convert-flop Foo.png bar.png The appearance of negative color formation:

Convert-negate foo.png bar.png Monochrome color the picture into black and white:

Convert-monochrome foo.png bar.png plus noise

Convert-noise 3 foo.png bar.png oil Painting effect We can use this function, a common picture, into a painting, the effect is very realistic

Convert-paint 4 foo.png bar.png rotate a picture, rotate a certain angle:

Convert-rotate foo.png bar.png above 30, which means rotate to the right 30 degrees, if you want to rotate to the left, the degree is negative.

Charcoal Effect

Convert-charcoal 2 foo.png bar.png form charcoal or pencil drawing effect.

Scattering of frosted glass effect:

Convert-spread the Foo.png bar.png Vortex takes the center of the picture as a reference, reversing the picture to create a vortex effect:

Convert-swirl foo.png bar.png convex effect with-raise to create convex edges:

Convert-raise 5x5 foo.png bar.png after execution, you will see that the photo is surrounded by a 5x5 edge, and if you want a concave edge, change the-raise to +raise. In fact, the convex edge and concave edge look different is not very big.

Other features are less common, and if you're interested, you can look at its online documentation

Importimport is a component for the screen, listed below are our common features, other features, you refer to its man good.

Capture any rectangular area of the screen

Import Foo.png after entering the above command, your mouse will become a cross, this time, you just want to intercept the place to draw a rectangle on it.

window for intercepting programs

Import-pause 3-frame foo.png Enter, use your mouse to click on the window you want to cut. Parameter-frame function is to tell the import, when the target window of the outer frame, the role of parameter-pause is very important, you can try to remove it, compare, you will find that the target window title bar is gray, pause is to let import a little delay, When your target window gets the focus, it only starts, so the diagram is more natural.

Intercept a tilted window if you want to make your comparison cool, you can take a slanted window by intercepting it as follows:

Import-rotate 30-pause 3-frame foo.png intercept entire screen

Import-pause 3-window Root Screen.png Note that you have paused for 3 seconds and you need to switch to the screen that needs to be intercepted within 3 seconds oh.

Displaydisplay should be the most frequent image processing software we use, after all, it's more

Show pictures

Display Foo.png If you want to show multiple files, you can use a wildcard character

Display *.png Slideshow

Display-delay 5 * Displays a picture every 5 seconds

Some shortcut keys

Space (spaces): Show next picture

Backspace (back delete key): Show previous picture

H: Flip Horizontally

V: Flip Vertically

/: Rotate 90 degrees clockwise

\: Rotate 90 degrees counterclockwise

: enlarge

<: Narrowing

F7: Blur Picture

Alt+s: Rotate the pixels in the middle of the picture

Ctrl+s: Save Image

Ctrl+d: Deleting pictures

Q: Exit

The Convert to Linux command

Related Article

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.