aboutsummaryrefslogtreecommitdiff
path: root/cheat/.cheat/convert
blob: 6e99e5b1cd1364d060f59e3ec8c4a7c5b6124f82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# To resize an image to a fixed width and proportional height:
convert original-image.jpg -resize 100x converted-image.jpg

# To resize an image to a fixed height and proportional width:
convert original-image.jpg -resize x100 converted-image.jpg

# To resize an image to a fixed width and height:
convert original-image.jpg -resize 100x100 converted-image.jpg

# To resize an image and simultaneously change its file type:
convert original-image.jpg -resize 100x converted-image.png

# To resize all of the images within a directory:
# To implement a for loop:
for file in `ls original/image/path/`;
    do new_path=${file%.*};
    new_file=`basename $new_path`;
    convert $file -resize 150 conerted/image/path/$new_file.png;
done

# Resize multi-image and blur it from <filename>.jpg to <filename>_tiny.jpg:
for file in $(ls .); do convert $(echo "$(echo $file | cut -f 1 -d '.').jpg") -resize 5% -blur 0x8 $(echo "$(echo $file | cut -f 1 -d '.')_tiny.jpg") ; done