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.jpgResizes 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 *.pngConverts all PNG images in the current directory to JPEG format.
Add Border to Images
mogrify -bordercolor black -border 20x20 *.jpgAdds a black border of 20 pixels around all JPEG images in the current directory.
Rotate Images
mogrify -rotate 90 *.jpgRotates all JPEG images in the current directory by 90 degrees clockwise.
Convert Images to Grayscale
mogrify -type Grayscale *.jpgConverts 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.jpgHow 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.jpgHow 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.jpgHow 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.jpgHow 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.jpgHow 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.jpgHow 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.jpgApplications of the mogrify command
- Batch resize images
- Batch rotate images
- Batch convert image formats
- Batch add effects or filters to images
- Batch compress images