Page 1 of 1

Convert colours

Posted: 2014-05-20T10:34:17-07:00
by raced
Hi wonder if someone can help.
I am new to this sort of thing !
I have a load of images (templates of mats) The image is all black on a white background.
I want to change the black to red , while leaving the white as is.
I need to do this on mass for 700 images.
I need the file name to remain the same with say _red at end of file name.
I have been sent the following code however file name is changed to test. Can someone help please?
convert *.jpg +level-colors red,white test_red.jpg

Re: Convert colours

Posted: 2014-05-20T10:46:16-07:00
by snibgo
What is your platform? Windows, Unix, Mac, or what?

Re: Convert colours

Posted: 2014-05-20T12:17:40-07:00
by raced
Hi running on windows 7

Re: Convert colours

Posted: 2014-05-20T12:28:42-07:00
by snibgo

Code: Select all

for /F "usebackq" %%F in (`dir /b *.jpg`) do convert %%F -fill Red -opaque Black %%~nF_red%%~xF

Re: Convert colours

Posted: 2014-05-22T04:42:40-07:00
by raced
Hi
This doesnt work ? The image remains the same colour ?

Re: Convert colours

Posted: 2014-05-22T04:44:37-07:00
by snibgo
Perhaps the images aren't really black. Put an example somewhere like dropbox.com and paste the URL here.

Re: Convert colours

Posted: 2014-05-23T08:10:56-07:00
by raced
http://www.carmats-uk.com/product_images/1268-2OER.jpg
heres a link to one image.
i am using the below code.
This will change the colour from black to red and also resize .
Problem is if it has to do more than one image it then screws.
:copy
ren *.jpg *.JPG

md temp
md webready





:xl
copy *.JPG temp\*.JPG
cd temp



mogrify -resize 500x *.JPG
mogrify -annotate 0,0 '' -font Arial -pointsize 24 xc:grey30 -gravity NorthEast -draw "fill grey70 text 5,5 ''" *
mogrify -annotate 0,0 '' -font Arial -pointsize 24 xc:black -gravity NorthEast -draw "fill black text 6,6 '' text 5,5 '
convert *.jpg +level-colors red,white *.jpg
ren ??????????????????????????????????????????????????.JPG ??????????????????????????????????????????????????_red.jpg


cd ..

deltree temp
pause

Re: Convert colours

Posted: 2014-05-23T08:32:43-07:00
by snibgo
My command works fine for me. IM v6.8.9-0 on Windows 8.1. If run from a command prompt, change each "%%" to "%".

You said "The image is all black on a white background" but it really has black, white and 4 shades of gray. This isn't surprising, as it is a jpg image. If you have any choice, NEVER use jpg for solid colours.

Re: Convert colours

Posted: 2014-05-23T10:53:44-07:00
by raced
I have removed the % and now nothing happens. I am now totally confused ?

Re: Convert colours

Posted: 2014-05-23T18:32:36-07:00
by snibgo
Are you are running a BAT file, or typing the command at the prompt? What exactly is your command?

Nothing happens? No error message?

Re: Convert colours

Posted: 2014-05-23T18:40:25-07:00
by fmw42
What version of Imagemagick are you using? Perhaps you need to ugrade

You cannot use multiple inputs and make multiple outputs using convert.


Either of these work for me on my Mac (unix syntax). The first, however, puts a period before _red.jpg

The input data is in test1 and the results are put into test2 (test2 must exist)

Code: Select all

cd desktop/test1
mogrify -path /Users/fred/desktop/test2 -format _red.jpg +level-colors red,white "*.jpg"
This has the input data in test1 and puts the result in test1

Code: Select all

for img in $(ls); do
convert $img +level-colors red,white ${img}_red.jpg
done

This has the input data in test1 and puts the result in test2

Code: Select all

for img in $(ls); do
convert $img +level-colors red,white ../test2/${img}_red.jpg
done
Sorry I do not know the windows syntax.