I currently have a script that when you right click on a folder to execute a batch file, converts all the EXRs to PDF:
cd %~dpnx1
for %%a in (.) do set currentfolder=%%~na
start cmd /k convert *exr* -colorspace RGB -colorspace sRGB -background none -alpha remove "%currentfolder%.pdf"
However, I'm wanting to add a gradient background to each of the exrs before they are sent to the PDF...
Is this possible? Hope someone can help.
Thanks.
Adding background gradient to each image, then convert to pdf
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Adding background gradient to each image, then convert to pdf
I think you want to flatten each input over a gradient. Is that correct?
What gradient do you want? I will assume you want black at top-left and white at bottom-right.
What version IM do you use? You use "convert" which implies v6. I suggest you use v7 and "magick".
You can do this by cloning the input, use "-sparse-color" to change that to a gradient, then flatten the input over the clone. This is fairly simple when you have just one input.
But your command reads all the exr files and processes them together, so the command is messier:
I have removed "-colorspace RGB -colorspace sRGB" because it seems pointless. This is Windows CMD format. For Windows BAT, double each % to %%.
What gradient do you want? I will assume you want black at top-left and white at bottom-right.
What version IM do you use? You use "convert" which implies v6. I suggest you use v7 and "magick".
You can do this by cloning the input, use "-sparse-color" to change that to a gradient, then flatten the input over the clone. This is fairly simple when you have just one input.
But your command reads all the exr files and processes them together, so the command is messier:
Code: Select all
magick *exr* null: ( -clone 0--2 -sparse-color bilinear 0,0,black,%[fx:w-1],%[fx:h-1],white ) -compose DstOver -layers Composite "%currentfolder%.pdf"
snibgo's IM pages: im.snibgo.com
Re: Adding background gradient to each image, then convert to pdf
Many thanks for getting back to me. I'm actually using v7 of imagemagick.
Upon running the script, I get the following error:
Upon running the script, I get the following error:
Code: Select all
magick: invalid argument for option 'sparse-color': Color found, instead of X-co
ord @ error/operation.c/SparseColorOption/272.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Adding background gradient to each image, then convert to pdf
Are you running it in a BAT file? If so, did you double each % to %%?
snibgo's IM pages: im.snibgo.com
Re: Adding background gradient to each image, then convert to pdf
No I hadn't, works perfectly. Great job snibgo!!