You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用ImageMagick批量反转图片颜色?Linux下mogrify命令报错求助

Fixing "mogrify: no decode delegate for this image format" Error When Batch Inverting Images

Let’s walk through fixing your issue step by step—there are two main problems here: incorrect command syntax and missing ImageMagick format support.

1. Your Command Syntax Is Wrong

First off, mogrify doesn’t work the way you wrote it. By default, mogrify modifies source files in-place, and you can’t just append a target folder at the end. To batch process images and save them to a new directory, use one of these correct approaches:

Option 1: Use convert with a loop (most straightforward)

This loops through every image in your source folder, inverts the colors, and saves the result to the target folder with the original filename:

# First make sure the target folder exists
mkdir -p /home/yu/Desktop/2

# Process each image
for img in /home/yu/Desktop/1/*; do
  convert "$img" -negate "/home/yu/Desktop/2/$(basename "$img")"
done

Option 2: Use mogrify with the -path flag

If you prefer mogrify, you need to specify the output directory with -path before your processing flags:

mkdir -p /home/yu/Desktop/2
mogrify -path /home/yu/Desktop/2 -negate /home/yu/Desktop/1/*

2. Fix the "No Decode Delegate" Error

That error means ImageMagick doesn’t have the necessary libraries to read your image format (JPG, PNG, WebP, etc.). Install the missing dependencies based on your Linux distro:

Debian/Ubuntu-based systems

sudo apt update
sudo apt install imagemagick libmagickcore-6.q16-6-extra

The libmagickcore-6.q16-6-extra package adds support for most common image formats.

RHEL/CentOS/Fedora-based systems

# For newer Fedora/RHEL 8+
sudo dnf install ImageMagick ImageMagick-devel

# For older RHEL/CentOS 7
sudo yum install ImageMagick ImageMagick-devel

After installing, verify your format support with:

identify -list format

Check that your image’s format (e.g., JPEG, PNG) appears in the output.

Once you’ve fixed both the syntax and installed the dependencies, re-run your command—your color-inverted images should save to /home/yu/Desktop/2 without issues.

内容的提问来源于stack exchange,提问作者Neil

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 22:58:09