What is mogrify Linux command?
mogrify is a powerful command-line tool in Linux used for batch processing images. It allows users to resize, rotate, flip, convert, and apply various effects to multiple images at once, making it a handy tool for image manipulation tasks.
mogrify Syntax:
mogrify [options] [parameters]
mogrify Options:
Option | Description |
---|---|
-crop | crop an image to the specified geometry |
-resize | resize the image |
-rotate | rotate the image by the specified degrees |
-flip | flip the image vertically |
-flop | flop the image horizontally |
-quality | set the image quality |
Parameters:
Parameter | Description |
---|---|
file(s) | The image file(s) to be processed |
mogrify Command Usage Examples:
Resize Images to a Specific Width
mogrify -resize 800x input_image.jpg
Resizes the input_image.jpg to have a width of 800 pixels while maintaining the aspect ratio.
Convert PNG Images to JPEG Format
mogrify -format jpg *.png
Converts all PNG images in the current directory to JPEG format.
Add Border to Images
mogrify -bordercolor black -border 20x20 *.jpg
Adds a black border of 20 pixels around all JPEG images in the current directory.
Rotate Images
mogrify -rotate 90 *.jpg
Rotates all JPEG images in the current directory by 90 degrees clockwise.
Convert Images to Grayscale
mogrify -type Grayscale *.jpg
Converts all JPEG images in the current directory to grayscale color mode.
How do I resize an image using mogrify in Linux?
To resize an image using mogrify in bash, execute the following command:
mogrify -resize 50% image.jpg
How can I rotate an image with mogrify in Linux?
To rotate an image using the mogrify command in bash, you can use the following command:
mogrify -rotate 90 image.jpg
How do I convert images to grayscale with mogrify in Linux?
To convert images to grayscale with mogrify in bash, you can run the following command:
mogrify -type Grayscale image.jpg
How can I add a border to an image using mogrify in Linux?
To add a border to an image with mogrify in bash, use the following command:
mogrify -bordercolor black -border 20x20 image.jpg
How do I crop an image using mogrify in Linux?
To crop an image with mogrify in bash, you can use the following command:
mogrify -crop 100x100+50+50 image.jpg
How can I blur an image with mogrify in Linux?
To blur an image using mogrify in bash, execute the following command:
mogrify -blur 0x8 image.jpg
How do I add text to an image using mogrify in Linux?
To add text to an image with mogrify in bash, you can use the following command:
mogrify -fill white -undercolor '#00000080' -pointsize 36 -annotate +100+100 'Example Text' image.jpg
Applications of the mogrify command
- Batch resize images
- Batch rotate images
- Batch convert image formats
- Batch add effects or filters to images
- Batch compress images