On the 31st of May, Uptrennd will stop its services and merge into Trodl.com. More information can be found here: https://www.uptrennd.com/post-detail/the-evolution-of-uptrennd-trodl~ODkxMzMw
Compress Multiple Image using Windows Resizer and Image Magick Linux

Utility


multiple image
A few days ago, I converted a handbook about maintaining Gumbrih Village's blog that I made during community service program in my Bachelors in 2014 into a blog post or webpage. Other than to fill my blogs, it is to enrich my online curriculum vitae (CV) where I can link the uploaded handbook as a proof that I actually did it. Anyway, the handbook 56 images because the officers in Gumbrih Village are not as computer literate as millenials today where I have to screenshot the steps in very detail. Not only that 56 is a lot of image to upload to a blog post or web content, back then the screenshot and snipping application are not as developed today. Each images are 3MB (megabyte) large in bmp format which is over most image blog limit which is 1MB. Optimizing the images file size one by one is very tiring. Therefore, I need an application that can do them all at once. I found many online services when I search the term online image compressor on the search engine but most of them are premium services when handling large amount of images. So I relied on installed application on my operating system.

Windows Image Resizer Now Power Toys


windows image resizer demonstration
I will go to Windows first because most people are still in this operating system. One software I found convenient is Windows Image Resizer where all you need to do is select all the images within the folder, right click, and choose Resize pictures. Then you are given options which you can explore yourself and in the end just execute with resizing all images at once. The latest news from the developers blog is that Windows Image Resizer is now a part of Microsoft Power Toys.

Image Magick Linux


Image Magick Linux Demonstration
Almost all Linux operating system are pre-install with Image Magick and if it is not for your case, just go to their website and download. Most people in Linux uses the terminal or command line. The image size became much smaller than using Windows Image Resizer since I convert the bmp to jpg where the conversion already include minimal optimization. The image size was reduced from 3MB to around 150kB. The procedure to convert is as following:

Here is a code to convert 1 bmp image to jpg:


convert image.bmp image.jpg


You can convert multiple files using the following simple command but only if you do not care about the filenames as they will be made random:


convert *.bmp *.jpg


If you are will to replace the files, you can use mogrify command or you can just copy the images to a new folder and mogrify them.


mogrify -format jpg *.bmp


The conventional way to convert multiple files at once is first create an empty file and insert the following code:


for PHOTO in *.[format]
do
BASE=`basename $PHOTO`
convert "$PHOTO" "[folder]/$BASE.[desired format]"
done


In my case I made a filename my-convert in the same directory as the images:


for PHOTO in *.bmp
do
BASE=`basename $PHOTO`
convert "$PHOTO" "Linux/$BASE.jpg"
done


Proceed in executing the file and if it does not work, use administrator access or root or sudo:


chmod  x my-convert
./my-convert


If you want to do more advance modification, you can check the documenation:


convert --help
man convert


If the above commands does not work then search their website.



Mirrors



Please leave a comment if you know other methods.

COMMENT

12

Andrzej Wawrzyniak
22 Oct

Another great post, keep up the good work! I like the fact that You make Linux more accessible by providing these usefull tips. Just to add: IM can also be used on Windows, and a similair script could be written using PowerShell. The syntax is a bit weird (eg basename foo.bar becomes [io.path]::GetFileNameWithoutExtension("foo.bar") but it can be done :)

12

Fajar Purnama
22 Oct

Thanks, I'm still not used to using syntax on Windows LOL.

12

Andrzej Wawrzyniak
23 Oct

You can actually install PowerShell on Linux now, Microsoft has made it open source. I personally also find it insufferable and needlessly complex, but I guess it's mostly down to the difference in design philosophy (KISS on Linux/Unix vs verbose .net-like syntax of Windows). 

22

awal ramlee
21 Oct

Bagus sekali tutorial Fajar Purnama ini. 

COMMUNITY DETAILS

Computers

6912

Subscriber

1

Online

Engage with all topics about Computers!

RELATED COMMUNITIES

Bitcoin Cash

29897 subscribers

Litecoin

28819 subscribers

Cryptocurrency Mining

28132 subscribers

Trading & TA

25349 subscribers

Zcash

20123 subscribers

Uptrennd Optimization

16973 subscribers

© 2021 UpTrennd.com