How to resize a batch of images on Linux?

Resizing images on Linux with gThumb is easy. However, I have a batch of images inside a folder. Manually resizing them will consume too much time.

How to automatically resize them on Linux with a script?

You can use convert from ImageMagick together with bash script to resize images inside a directory.

mkdir resize; 
IFS=$(echo -en "nb"); 
for i in *; do 
    echo $i; convert $i -resize 600^ resize/$i; 
done

The script will make a new directory named “resize” in current directory, resize all images in current directory to smaller ones of width 600px, and store the resized images into “reisze”.

The line IFS=$(echo -en "nb") is a bash trick to handle situations where images file names have spaces.

Similar Posts

  • Direct multi-hop ssh connection

    How to use multi-hop ssh connection without needs to ssh multiple times? As a example, you are connecting to server.example.com through proxy.example.com from laptop.example.com as follows: laptop —-> proxy —-> server 2 possible methods: Method 1: Use the similar method as in Directly SSH to hosts using internal IPs through the gateway. Add this to…

  • Micosoft招聘部分算法题

    Micosoft招聘部分算法题 1.链表和数组的区别在哪里? 2.编写实现链表排序的一种算法。说明为什么你会选择用这样的方法? 3.编写实现数组排序的一种算法。说明为什么你会选择用这样的方法? 4.请编写能直接实现strstr()函数功能的代码。 5.编写反转字符串的程序,要求优化速度、优化空间。 6.在链表里如何发现循环链接? 7.给出洗牌的一个算法,并将洗好的牌存储在一个整形数组里。 8.写一个函数,检查字符是否是整数,如果是,返回其整数值。(或者:怎样只用4行代码编写出一个从字符串到长整形的函数?) 9.给出一个函数来输出一个字符串的所有排列。 10.请编写实现malloc()内存分配函数功能一样的代码。 11.给出一个函数来复制两个字符串A和B。字符串A的后几个字节和字符串B的前几个字节重叠。 12.怎样编写一个程序,把一个有序整数数组放到二叉树中? 13.怎样从顶部开始逐层打印二叉树结点数据?请编程。 14.怎样把一个链表掉个顺序(也就是反序,注意链表的边界条件并考虑空链表)? 来源:·日月光华 bbs.fudan.edu.cn Read more: Java与C++在语言方面上的不同 MFC程序使用系统风格界面 Linux UDP Programming Tutorial Parameterised AngularJS Routing in Asp.net MVC using $routeProvider Getting Process Own Pid in C and C++ Checking Whether a String Starts with Another String in C++ GCC May “Save” You…

  • How to read the whole file content into a string in Go?

    How to read the whole file content into a string in Go? You can use the ReadFile() func from the io/ioutil package in Go to read the whole file content: func ReadFile(filename string) ([]byte, error) For example, read file filepath content and check the error: if bytes, err := ioutil.ReadFile(filepath); err != nil { log.Fatal(“Failed…

  • How to change default OS for windows dual boot manager in Windows 7?

    How to change default OS for windows dual boot manager in Windows 7? The c:/boot/ in older Windows does not exist anymore. Open the Control Panel and click on the System icon. In the left pane, click on the Advanced system settings link. Under the Advanced tab, click on the Settings button under Startup and…

  • | | |

    Understanding the Raft Consensus Protocol

    The Raft consensus protocol is a distributed consensus algorithm designed to be more understandable than other consensus algorithms like Paxos. It ensures that a cluster of servers can agree on the state of a system even in the presence of failures. Key Concepts Raft divides the consensus problem into three relatively independent subproblems: Leader Election:…

  • CloudFlare with DreamHost

    CloudFlare is a very nice service that provides CDN / optimizer / security protection and more. Good news is that DreamHost turns to be a partner with CloudFlare. The free account on CloudFlare is enough for sites such as Fclose.com. I enabled CloudFlare yesterday and it works smoothly and boosts the site’s performance. Overall, I…

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *