How to set Linux `convert` command default quality to `100`?
Feb 11, 11:00am

To set the default quality to 100 for the Linux convert command (part of the ImageMagick suite), you have a few options:

1. Use the -quality Option Directly

You can specify the quality for each command:

bash
convert input.jpg -quality 100 output.jpg

2. Set Default Quality in policy.xml

To make 100 the default quality for all convert operations, you can modify ImageMagick's policy configuration file:

  1. Open the policy file (location may vary by distribution):

    bash
    sudo nano /etc/ImageMagick-6/policy.xml

    (Replace 6 with your ImageMagick version if different.)

  2. Locate or add the following line inside the <policymap> section:

    xml
    <policy domain="coder" name="quality" value="100"/>
  3. Save the file and restart any services using ImageMagick.

3. Use an Alias

For a user-specific solution, add an alias to your shell configuration file (e.g., ~/.bashrc or ~/.zshrc):

bash
alias convert='convert -quality 100'

Then reload your shell:

bash
source ~/.bashrc  # or source ~/.zshrc

4. Environment Variable (Temporary)

Set the MAGICK_QUALITY environment variable for your current session:

bash
export MAGICK_QUALITY=100

This will apply to all subsequent convert commands in that session.


Note: The policy.xml method is system-wide, while aliases and environment variables are user-specific. Choose the method that best fits your needs!

Feb 11, 11:00am

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.