*Windows cmd* - Batch Process B&W thumbnails

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Masa
Posts: 4
Joined: 2015-06-22T03:51:21-07:00
Authentication code: 6789

*Windows cmd* - Batch Process B&W thumbnails

Post by Masa »

Hey!

I have something like 9000 small (64pxx64px) thumbnails that I need to convert into Black and White.
I tried Irfanview, but it lost some of the information during batch process.
The problem occurs with images that has transparent backgrounds, counter colors Green Lines and Cyan text.

Then I started browsing and found out that ImageMagick could do the job more efficiently and without losing the details.

Anyhow. I don't seem to find a proper command to do the job.

What I've done so far is:
- Open cmd
- Enter the folder where the images are
- type: Mogrify -type Grayscale *.png
- This seems to save all the colors, but the problem is that I'm losing the background transparency AND the images are in grayscale, not straight B&W.

So, could someone with better knowledge, tell me what should I write in the cmd to do the trick:
- All images in B&W
- Transparent Backgrounds as it is before the conversion

Thank you in advance!

-Masa-
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: *Windows cmd* - Batch Process B&W thumbnails

Post by snibgo »

One of the easiest way to convert greyscale into black and white is with "-threshold", eg:

Code: Select all

mogrify -format tiff -colorspace Gray -threshold 50% xx.png
This shouldn't remove transparency.
snibgo's IM pages: im.snibgo.com
Masa
Posts: 4
Joined: 2015-06-22T03:51:21-07:00
Authentication code: 6789

Re: *Windows cmd* - Batch Process B&W thumbnails

Post by Masa »

Thanks.
I think I finally understood at least a bit what I should do there.
I tried this command and it seemed to work as intended aka B&W the images and leave transparent bg's alone:

Code: Select all

mogrify -threshold 90%  *.PNG
Is there a way to write that command so that it only transforms 32x32 and 64x64 images, but leaves all the other png's alone?
Since I noticed that there's also some larger images in the same folder that I don't want to transform into B & W.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: *Windows cmd* - Batch Process B&W thumbnails

Post by snibgo »

Is there a way to write that command so that it only transforms 32x32 and 64x64 images, but leaves all the other png's alone?
No. The easiest way would be to move or copy the 32x32 and 64x64 images to another directory, and process all the files in that directory. Move or copy by hand or a script.
snibgo's IM pages: im.snibgo.com
Masa
Posts: 4
Joined: 2015-06-22T03:51:21-07:00
Authentication code: 6789

Re: *Windows cmd* - Batch Process B&W thumbnails

Post by Masa »

snibgo wrote:
Is there a way to write that command so that it only transforms 32x32 and 64x64 images, but leaves all the other png's alone?
No. The easiest way would be to move or copy the 32x32 and 64x64 images to another directory, and process all the files in that directory. Move or copy by hand or a script.
Ok. That's what I thought and started already going trough the images one by one.. Tedious work I tell you! :D

One more thing.
Is there any clear instructions how to use the program since it seems to have very high potential?
...if I just learn to use it correctly! :D

If I understood correctly, you can run a lot more difficult scripts with this too, but not from cmd.. or?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: *Windows cmd* - Batch Process B&W thumbnails

Post by snibgo »

For "how to use" guides, see:
http://www.imagemagick.org/Usage/
http://www.imagemagick.org/Usage/basics/

That documentation is now quite old, and doesn't always include new features. The examples are mostly for bash.

For examples with Windows BAT, see my pages.

Like any program, IM can be run by typing at the command prompt, or by running a script.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: *Windows cmd* - Batch Process B&W thumbnails

Post by fmw42 »

Masa
Posts: 4
Joined: 2015-06-22T03:51:21-07:00
Authentication code: 6789

Re: *Windows cmd* - Batch Process B&W thumbnails

Post by Masa »

Thank you very much!
Post Reply