Mailing List Archive

Off topic: - imagemagic command line, strange behaviour
I'm trying to remove grey background from a pdf file, but on windows.
The document contains some grey scale fonts that I want to retain.

Running on windows, via Command line:
magick convert -density 300 document.pdf -fuzz 45% -fill white +opaque black converted_document.pdf

Works, the text is retained including grey-scale font.

But running same command from a bat file, the grey-scale font is removed.

@echo off
cd "C:\Users\Server\Desktop\"
magick convert -density 300 document.pdf -fuzz 45% -fill white +opaque black converted_document.pdf
pause

--
Thelma
Re: Off topic: - imagemagic command line, strange behaviour [ In reply to ]
On 2023-12-28 19:46, thelma@sys-concept.com wrote:
>@echo off
>cd "C:\Users\Server\Desktop\"
>magick convert -density 300 document.pdf -fuzz 45% -fill white +opaque black converted_document.pdf
>pause

Just a wild guess without looking too deep into it: Might the "%" be a
special character in a Batch file, being interpreted as some sort of
variable? Can you escape it, maybe putting the whole "45%" in quotes?

Kind regards

FloGa
Re: Off topic: - imagemagic command line, strange behaviour [ In reply to ]
On 1/3/24 09:09, Florian Gamböck wrote:
> On 2023-12-28 19:46, thelma@sys-concept.com wrote:
>> @echo off
>> cd "C:\Users\Server\Desktop\"
>> magick convert -density 300 document.pdf -fuzz 45% -fill white +opaque black converted_document.pdf
>> pause
>
> Just a wild guess without looking too deep into it: Might the "%" be a special character in a Batch file, being interpreted as some sort of variable? Can you escape it, maybe putting the whole "45%" in quotes?
>
> Kind regards
>
> FloGa

I got this one.
Yes, you are correct changing "45%" to "45%%" solved the problem.