31 lines
1.1 KiB
Plaintext
31 lines
1.1 KiB
Plaintext
---
|
|
tags: [ graphics, images ]
|
|
---
|
|
# To resize an image to a fixed width and proportional height:
|
|
convert original.jpg -resize 100x converted.jpg
|
|
|
|
# To resize an image to a fixed height and proportional width:
|
|
convert original.jpg -resize x100 converted.jpg
|
|
|
|
# To resize an image to a fixed width and height:
|
|
convert original.jpg -resize 100x100 converted.jpg
|
|
|
|
# To resize an image and simultaneously change its file type:
|
|
convert original.jpg -resize 100x converted.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 converted/image/path/$new_file.png;
|
|
done
|
|
|
|
# To resize and convert a JPG image to favicon.ico
|
|
# with a fixed width and height (48px):
|
|
convert original.png -resize x48 -gravity center -crop 48x48+0+0 -colors 256 -transparent white converted.ico
|
|
|
|
# To resize and convert a PNG or GIF image to favicon.ico
|
|
# with a fixed width and height (48px):
|
|
convert original.png -resize x48 -gravity center -crop 48x48+0+0 -flatten -colors 256 -background transparent converted.ico
|