Score:0

How can I batch convert some .jpgs to .pngs

kp flag

I would like to convert some .jpgs to a 640x480 size.

I looked through my Ubuntu_Tips.odt file and found this.

Convert png to a 640x480 png.
 convert Screenshot_1360x768.png -resize 640x480! 640smaller.png

I have 8 of those files in /home/andy/Downloads/.

Is there a way to do a batch convert of those .jpgs files to the smaller file size?

Thanks.

petep avatar
in flag
use a for loop.
Score:3
cn flag

Repeat your command 8 times? It is probably the better method as you might need to change your command on the current proportions of those files. A command that repeats convert without taking that in consideration will not get the expected result.

Instead of convert there is also mogrify. It does not require a 2nd filename so this will convert all pngs to 640x480. You can narrow it down by altering the wildcard:

mogrify -resize 640x480 *.png

(this will overwrite the existing file(s))

If you need to alter proportions you need to add an escaped !:

convert -resize 640x480\! {file_old}.png {file_new}.png

(this will result in a new file)

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.