Resizing and Rotating Images with imgp (with examples)
- Linux
- November 5, 2023
Use Case 1: Convert single images and/or whole directories containing valid image formats
imgp -x 1366x1000 path/to/directory path/to/file
Motivation: The motivation behind using this command is to convert single images or a whole directory of images to a specific resolution, in this case, 1366x1000 pixels. This can be useful when preparing images for display on websites or other digital platforms that have specific size requirements.
Explanation: The -x
flag is used to specify the desired resolution for the images. In this case, 1366x1000
pixels is specified. The two arguments following the flag are the path to the directory (or file) that contains the images to be converted.
Example Output: After running the command, all the images in the specified directory or the single specified image file will be converted to the resolution of 1366x1000 pixels.
Use Case 2: Scale an image by 75% and overwrite the source image to a target resolution
imgp -x 75 -w path/to/file
Motivation: The motivation behind using this command is to scale down an image by a specific percentage (in this case, 75%) while also setting a specific target resolution for the image. This can be useful when wanting to resize an image for web or mobile display.
Explanation: The -x
flag is used to specify the scaling percentage for the image. In this case, 75% is specified. The -w
flag is used to specify the target resolution for the image. The argument following the -w
flag is the path to the image file that will be scaled and overwritten with the new target resolution.
Example Output: After running the command, the specified image file will be scaled down by 75% and overwritten with the new target resolution.
Use Case 3: Rotate an image clockwise by 90 degrees
imgp -o 90 path/to/file
Motivation: The motivation behind using this command is to rotate an image clockwise by a specific angle (in this case, 90 degrees). This can be useful when an image needs to be rotated to align with a specific orientation.
Explanation: The -o
flag is used to specify the rotation angle for the image. In this case, 90 degrees is specified. The argument following the -o
flag is the path to the image file that will be rotated.
Example Output: After running the command, the specified image file will be rotated clockwise by 90 degrees.