The convert command in Linux is a part of the ImageMagick suite, a powerful toolset for image manipulation. This command allows you to convert between different image formats, resize images, change image quality, and perform a wide variety of other image transformations.
Here are a few basic examples of what you can do with the convert command:
Converting an Image Format:
To convert a JPEG image to a PNG, you would use:
convert image.jpg image.png
Resizing an Image:
To resize an image to a specific width and height (e.g., 100x100 pixels), you can use:
# based on the pixel of x*y convert original.jpg -resize 100x100 resized.jpg # based on the ratio convert original.jpg -resize 30% reduced.jpg # based on the ratio of x*y convert original.jpg -resize 50%x30% reduced.jpg
Changing Image Quality:
To change the quality of a JPEG image, useful for reducing file size, use:
convert original.jpg -quality 85 compressed.jpg
Combining Multiple Images:
To combine multiple images into one, for instance, side by side:
These examples are just the tip of the iceberg in terms of what ImageMagick’s convert command can do. It’s a very powerful tool with a wide array of options and capabilities. For more detailed information, you can check the manual page (man convert) or the official ImageMagick documentation.
Other Functions You May Want to Know
Certainly! Here are examples demonstrating various capabilities of ImageMagick:
Image Composition:
Overlay one image on top of another (watermark):
convert background.jpg watermark.png -gravity center -composite output.jpg
Color Manipulation:
Convert an image to grayscale:
These commands showcase the versatility of ImageMagick. Remember to adjust the file names and parameters according to your specific needs. The ImageMagick documentation provides more detailed information and examples for these and other features.