How to Resize the Picture in shell script / convert commnad
October23
First, we need a convert utility to resize the jpg images.
convert utility is from ImageMagick (open source tool)
If you dont have the convert utility, then install it by using the below command.
1 | sudo apt-get install imagemagick |
After installation, we are ready to resize the images.
execute the below command to resize the image to 50% from its original size
1 2 | syntax: convert source-image -resize 50% output-image |
1 | convert linux.jpg -resize 50% resize_linux.jpg |
If you want to resize all the pictures in one folder, then try with this for loop
1 | for i in *.jpg; do new_file=${i/.*/};convert ${i} -resize 50% ${i} ${new_file}_new.jpg; done |
This convert utility converts the image from one format to another format ( Eg. jpg to png )
1 | convert linux.jpg linux.png |
Recent Comments