2021-01-16 17:36:05 +00:00
|
|
|
|
# convert
|
|
|
|
|
# Image converter and manipulator
|
|
|
|
|
|
|
|
|
|
# Resize an image to a fixed width and proportional height.
|
2017-05-21 19:26:32 +00:00
|
|
|
|
convert original-image.jpg -resize 100x converted-image.jpg
|
|
|
|
|
|
2021-01-16 17:36:05 +00:00
|
|
|
|
# Resize an image to a fixed height and proportional width.
|
2017-05-21 19:26:32 +00:00
|
|
|
|
convert original-image.jpg -resize x100 converted-image.jpg
|
|
|
|
|
|
2021-01-16 17:36:05 +00:00
|
|
|
|
# Resize an image to a fixed width and height.
|
2017-05-21 19:26:32 +00:00
|
|
|
|
convert original-image.jpg -resize 100x100 converted-image.jpg
|
|
|
|
|
|
2021-01-16 17:36:05 +00:00
|
|
|
|
# Resize an image and simultaneously change its file type.
|
2017-05-21 19:26:32 +00:00
|
|
|
|
convert original-image.jpg -resize 100x converted-image.png
|
|
|
|
|
|
2021-01-16 17:36:05 +00:00
|
|
|
|
# Resize all of the images within a directory, using a for loop.
|
2019-11-06 14:23:50 +00:00
|
|
|
|
for file in original/image/path/*; do
|
|
|
|
|
convert "$file" -resize 150 converted/image/path/"$file"
|
2017-05-21 19:26:32 +00:00
|
|
|
|
done
|
|
|
|
|
|
2021-01-16 17:36:05 +00:00
|
|
|
|
# Make text annotation, which in this example is 'Flower'.
|
2017-05-21 19:26:32 +00:00
|
|
|
|
convert flower.jpg -font courier -fill white -pointsize 20 -annotate +50+50 'Flower' flower_annotate1.jpg
|
|
|
|
|
|
2021-01-16 17:36:05 +00:00
|
|
|
|
# Crop an image.
|
2017-05-21 19:26:32 +00:00
|
|
|
|
convert flower.jpg -crop 128×128+50+50 flower_crop.jpg
|
|
|
|
|
|
2021-01-16 17:36:05 +00:00
|
|
|
|
# Rotate an image.
|
2017-05-21 19:26:32 +00:00
|
|
|
|
convert flower.jpg -rotate 45 flower_rotate45.jpg
|
|
|
|
|
|
2021-01-16 17:36:05 +00:00
|
|
|
|
# Add a border around an image.
|
2017-05-21 19:26:32 +00:00
|
|
|
|
convert -border 1x1 -bordercolor "#FFFFFF" image.png new-image.png
|
|
|
|
|
|
2021-01-16 17:36:05 +00:00
|
|
|
|
# Convert PNG to JPEG, with 70% quality.
|
2017-05-21 19:26:32 +00:00
|
|
|
|
convert -quality 70 image.png new_image.jpg
|
|
|
|
|
|
2021-01-16 17:36:05 +00:00
|
|
|
|
# Apply vignette & grayscale effects to all JPGs in the CWD, using a for loop.
|
2019-11-06 14:47:22 +00:00
|
|
|
|
for FILE in *.jpg; { convert -background black -colorspace gray -vignette 200x100 "$FILE" "$FILE"; }
|
2020-11-05 20:06:30 +00:00
|
|
|
|
|
2021-01-16 17:36:05 +00:00
|
|
|
|
# Convert and combine multiple images to a single PDF.
|
2020-11-05 20:06:30 +00:00
|
|
|
|
convert image1.png image2.jpg image3.bmp output.pdf
|