├── ~/
│   ├── content/
│   │   ├── image01.jpg
│   │   ├── image02.png
│   │   ├── image03.bmp
│   │   ├── text-file.txt
│   │   ├── video.mp4
│   └── ...
└── ...

Let's say I want to compress all images in my content/ directory utilizing ImageMagick's standard -quality argument, with defualt settings. To overwrite and replace the files in their folder (caution!) it seems I would use the mogrify command:

~/content$ mogrify -quality *

but this just yields the following error:

@error /mogrify.c/MogrifyImageCommand/5730

What's the correct mogrify command? And what will happen to the non-image files (eg text-file.txt and video.mp4)? Perhaps I should request the individual mogrify commands for individual image types (eg jpg, png, bmp, etc.). Or is there a better strategy for salvaging non-image files?

  • 1
    The -quality option needs a value argument ex. mogrify -quality 75 * (without it, the first filename in the expansion of * will be read as a - likely invalid - quality value) Commented Sep 17, 2020 at 1:47
  • @steeldriver thanks that works, but only for images, doesn't seem to work on video (eg*.mp4). Any idea what to do to include both images and video? Commented Sep 17, 2020 at 21:29
  • I have used vlc's transcode feature to do that in the past, but I have no idea what are the best tools currently - sorry Commented Sep 17, 2020 at 23:36

1 Answer 1


Better compressed result for me is with optipng ref

Quoted as below

# install `$ sudo apt-get install -y optipng`
# see helpful syntax `$ tldr optipng`  # you may need install tldr `sudo apt-get install -y tldr`
optipng \       
    -o7         `# use best compression but quite slow ref. tldr optipng - fastest is w/ -o0` \
    -strip all  `# remove all metadata ref. tldr optipng` \
    *           `# all files or enter /path/to/your.png`

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .