Batch change images in Linux

Source: Internet
Author: User
Tags imagemagick
I went out for a weekend and took a few digital photos. Before uploading files to the Internet, you need to narrow down the file. In the past, "Magic Hands and shadows" were used in windows. How can this work be done in Linux? I started to use gimp for a conversion, but it was too troublesome. Gimp supports batch processing scripts. Google's keyword "gimp-image-scale" can find some scripts for this. However, it is more convenient to use an image
Magick, a command line image processing software

Run the following command to install image magick:

Sudo apt-Get install ImageMagick

Method 1: Convert-resize 50% x50 % photos \ *. jpg small \

The file name of the image converted in this way is changed to a number. If you want the original file name to remain unchanged, you can run the following command (in fact, a script with four rows merged into one row ).

Method 2: For IMG in 'ls photos \ *. jpg '; do convert-resize 50% x50 % $ img
Small-$ IMG; done

It seems much easier to use software in windows.

Note: I used the-sample parameter in the data, instead of the-resize parameter. However, the former may not only resize but also compress the image, so I am not satisfied with the quality of the reduced image. Use convert
-H can display all its parameters, and I chose-resize later.

Later...

After two days, I saw an article that the gthumb of ubuntu can also narrow down the image. I saw it. It is an interface operation, and it still does not feel the convert command line is faster. However, if you just narrow down the page by chance, you don't have to install other software, so you can use the built-in gthumb. The usage is as follows:

Start: I used to enter the image directory (I installed a shortcut menu to quickly enter the terminal), and then started it with the command line:
Gthumb
*. Jpg. In this way, all the images of gthumb are there. Of course, you can also use the main menu "Application-> image-> gthumb image browser" to start and then select an image.

Select All images, and then "tool-> Scale
Images... ", reselect a save target. Next, let alone.

Copy the original document of the UBUNTU Forum as follows:

Mage magick is a powerful image processing tool kit. It provides several very convenient command line commands:
Display animateimport
Montagemogrifyidentify allows you to display, scale, rotate, color, add frames, add comments, and perform GIF animation and Image Indexing to automatically generate images.

1. Create index charts and animations

! /Bin/bash

Montage-bordercolor red-borderwidth 3-label "% F"-tile 5x3 *. jpg
Montage.jpg

Mogrify-format GIF *. jpg

Display montage.jpg

Animate *. jpg

2. Scale convert-sample 80x40 input.jpg output.jpg
# Note: after scaling, the image maintains the original aspect ratio convert-sample 25% x25 % input.jpg
Output.jpg

3. Generate thumbnails for all images in the current directory

For IMG in 'ls *. jpg'

Do

Convert-sample 25% x25 % $ IMG thumb-$ img

Done

4. Get File Information LibTIFF

Raise info filename. Tiff

Pnginfo filename.png

5. You can use the identify of ImageMagick.

Identify-verbose sample.png

Identify-format "% wx % H" sample.png

6. Rotating Images

Convert-Rotate 90 input.jpg output.jpg

7. Change the file type

Convert input.jpg output.png

8. Add comments to the image

Convert-font Helvetica-fill white-pointsize 36 \

-Draw 'text 1050 "Floriade 2002 Canberra Australia "'\

Floriade.jpg comment.jpg

Convert-font fonts/1900805.ttf-fill white-pointsize 36 \

-Draw 'text 10475 "stillhq.com "'\

Floriade.jpg stillhq.jpg

9. Special results

Convert-charcoal 2 input.jpg output.jpg # Carbon pen

Convert-colorize 255 input.jpg output.jpg # Three colors can be specified for coloring.
Red/green/blue

Convert-implode 4 input.jpg output.jpg # explosive effect

Convert-solarize 42 input.jpg output.jpg # exposure, imitating film exposure

Convert-spread 5 input.jpg output.jpg # Move randomly. The parameter is the displacement size.

10. Execute multiple operations at a time

Convert-sample 25% x25 %-spread 4-Charcoal 4 input.jpg output.jpg

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.