Batch changing picture files
-
- Posts: 7
- Joined: 2019-06-16T10:16:33-07:00
- Authentication code: 1152
Batch changing picture files
I'm trying to figure out how to make the following changes to all the files in folder c:....\input and save them to c:....\output.
I would really appreciate some help with what I should write as I am a complete newbie at this.
Also, I haven't figured out, should I write this in the command promt in C:\Program Files\ImageMagick-7.0.8-Q16\ or somewhere else?
Sourcefile is grayscale JPG.
* Change mode from grayscale to RGB.
* Add an alpha layer
* Convert all white to transparent
* Change black to red (or even better, if it is possible to get the program for each file to stop and ask me for which color to change to)
* Select a rectangle around the content (i.e. so that transparent area outside is excluded)
* Crop to selection
* Save as png
This is as far as I have gotten so far:
cd /users/me/input/
mogrify -strip -colorspace sRGB -format png -alpha set -fuzz 10% -transparent white ?????? -path /users/me/output/ *.png
I would really appreciate some help with what I should write as I am a complete newbie at this.
Also, I haven't figured out, should I write this in the command promt in C:\Program Files\ImageMagick-7.0.8-Q16\ or somewhere else?
Sourcefile is grayscale JPG.
* Change mode from grayscale to RGB.
* Add an alpha layer
* Convert all white to transparent
* Change black to red (or even better, if it is possible to get the program for each file to stop and ask me for which color to change to)
* Select a rectangle around the content (i.e. so that transparent area outside is excluded)
* Crop to selection
* Save as png
This is as far as I have gotten so far:
cd /users/me/input/
mogrify -strip -colorspace sRGB -format png -alpha set -fuzz 10% -transparent white ?????? -path /users/me/output/ *.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Batch changing picture files
That would be:ChristinaChristina wrote:Change black to red
Code: Select all
-fill Red -opaque Black
IM can't do that. Instead of mogrify, you could have a shell loop to process the files, with the shell asking the user for the colour.ChristinaChristina wrote:(or even better, if it is possible to get the program for each file to stop and ask me for which color to change to)
I don't understand. Perhaps "-trim" or "-crop".ChristinaChristina wrote:Select a rectangle around the content (i.e. so that transparent area outside is excluded)
Crop to selection
In that case, your mogrify command should end "*.jpg" not "*.png".ChristinaChristina wrote:Sourcefile is grayscale JPG.
snibgo's IM pages: im.snibgo.com
-
- Posts: 7
- Joined: 2019-06-16T10:16:33-07:00
- Authentication code: 1152
Re: Batch changing picture files
Many thanks!
With the crop my thought was that I could crop away most of the empty/white area around the text which is written on the sheets that are scanned.
With the crop my thought was that I could crop away most of the empty/white area around the text which is written on the sheets that are scanned.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Batch changing picture files
use -fuzz XX% -trim +repage rather than -crop. See https://imagemagick.org/Usage/crop/#trim If the background color is constant, you can either remove the -fuzz XX% or use XX=0
-
- Posts: 7
- Joined: 2019-06-16T10:16:33-07:00
- Authentication code: 1152
Re: Batch changing picture files
I will try that. Thanks!
Can I add a fuzz to the "-fill Red -opaque Black" in order to capture also the black that might have a hint of grey in it?
Can I add a fuzz to the "-fill Red -opaque Black" in order to capture also the black that might have a hint of grey in it?
-
- Posts: 7
- Joined: 2019-06-16T10:16:33-07:00
- Authentication code: 1152
Re: Batch changing picture files
Just realised that the same fuzz works for all colors so increased it to 30% and now it all works as a charm. Incredible!
Many thanks!
(I didn't work out how to handle the space in the folder names - but moved the files to a folder without space in the name
Many thanks!
(I didn't work out how to handle the space in the folder names - but moved the files to a folder without space in the name
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Batch changing picture files
Put your file names in double quotes if they have spaces in them
-
- Posts: 7
- Joined: 2019-06-16T10:16:33-07:00
- Authentication code: 1152
Re: Batch changing picture files
Can you suggest a good place to read up on how to use shell loops?snibgo wrote: ↑2019-06-16T11:32:25-07:00IM can't do that. Instead of mogrify, you could have a shell loop to process the files, with the shell asking the user for the colour.ChristinaChristina wrote:(or even better, if it is possible to get the program for each file to stop and ask me for which color to change to)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Batch changing picture files
I am not on Windows, but search Google for Windows .bat scripting for loops
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Batch changing picture files
Type "help for" at the command line.ChristinaChristina wrote:Can you suggest a good place to read up on how to use shell loops?
snibgo's IM pages: im.snibgo.com