Convert And Compress Images From The Command Line With Imagemagick

Pavol Kutaj
1 min readJul 17, 2021

The aim of this how-to-guidešŸ is to teach and illustrate the modification of images from command line that can be used with scripts, via using the tool called ImageMagick.

1. steps

magick convert .\IMG_20210105_1539574.jpg -resize 800x600! -strip -define jpeg:extent=200KB img1.jpg

2. usecase/code example

  • see the subfunction in a script I wrote for writing a daily family chronicle
  • Input: put large images within a folder defined within the script
  • Output: find compressed and renamed images within another folder defined in a script
  • Then, the images are linked within a doc with another part of the script such as
### 2021-02-12
<!-- TEXT HERE -->
![2021-02-12](../assets/2021-02-12-1.jpg)

![2021-02-12](../assets/2021-02-12-2.jpg)

--

--

Pavol Kutaj

Today I Learnt | Infrastructure Support Engineer at snowplow.io with a passion for cloud infrastructure/terraform/python/docs. More at https://pavol.kutaj.com