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?".
As promised, here is my vbscript code to convert all images in a folder to a specific color. This will create a copy of each image in purple, red, green, blue and orange and place the images in folders by those same color names. This script was only possible thanks to Fred's help! So thanks Fred, I can now batch convert images instead of spending hours developing carpal tunnel via Gimp. Just place this script code in a text file in the same directory as your images. Name it anything you want, just give it a VBS extension. Double click to launch. You will see a whole bunch of CMD prompts open and close as images are created. Just let it finish processing before clicking in any other windows.
Thanks Fred. Here is a sample of before and after. The left side of the image in blue is the stock android and the right side in red is the after affect. http://www.mediafire.com/view/?hd9rr5jczdqxmnn
Ideally I would love to be able to pick the specific color using standard RGB Hex colors. I can easily add any single IM command into my script and change up specific values for variables, it is figuring out the base IM command that throws me. I see that there are two books available regarding IM, I may pick one up, regretfully neither focuses on Windows but they might help me to understand the vast possibilities. I still can't believe that this one program can do so much.
Well, I am hoping you can suggest something better Fred, the purple, green and blue look awesome but I can't seem to nail down a bright enough red and orange color.
From those simple images, I would convert turn off the alpha, convert to non-linear grayscale, colorize with whatever color you want (or if the underlying color is not constant, use +level-colors black,somecolor or +level-colors somecolor,white), then turn alpha back on. I think you are making the process more complex than it needs. Try
convert sample.png -alpha off -set colorspace RGB -colorspace gray -fill orange -colorize 100 -alpha on sample_tmp1.png
Just change the orange to any other color name, hex color or rgb(..) color. See http://www.imagemagick.org/script/color.php. There is even a color convert gui link near the top to test various colors.
The image I downloaded had an alpha channel. Is that what you had? My command should recolor your RGB channels and leave the alpha channel alone. So I got two orange rings fading with transparency. What version of IM are you using?
If black should be preserved, then try
convert sample.png -alpha off -set colorspace RGB -fill orange +opaque black -alpha on sample_tmp2.png
Afraid I got the same results. The entire image gets filled with color. Even my .9.png files which have the special black borders were fully filled in.
So frustrating, I know I am close to getting this working. As always, thanks for your suggestions.
Is there any way to add the statements for the +opaque black? I can make do with having to manually adjust the red and orange colors. Having my blue, green and purple generated is still a huge time saver for me.
Maybe you can suggest a way to get the levels right for red and orange so that the red is hex red f10834 and the orange is a hex orange ff6b00?
markdmac wrote:Afraid I got the same results. The entire image gets filled with color. Even my .9.png files which have the special black borders were fully filled in.
So frustrating, I know I am close to getting this working. As always, thanks for your suggestions.
What version of IM are you using? If it is very old, then it may be before -alpha. Or there is a bug in that version with -alpha turning back on again.
I don't understand why my last command is not working for you. It worked fine for me. Is your black really black or near black.
try
convert sample.png -alpha off -set colorspace RGB -fuzz 1% -fill orange +opaque black -alpha on sample_tmp3.png
I am using version 6.7.9-Q16, will check if that is the latest.
The black is a pure black, hex 000000. Android requires it to be that color. What I am finding is that the tint is changing it slightly, for example making it 0007b. This is only an issue for the .9 patch files. What I did is add a second command to replace the color 00070b with 000000. That seems to have done the trick, though I will test your latest suggestion as I prefer the cleaner one step process if it is possible.
markdmac wrote:I am using version 6.7.9-Q16, will check if that is the latest.
The black is a pure black, hex 000000. Android requires it to be that color. What I am finding is that the tint is changing it slightly, for example making it 0007b. This is only an issue for the .9 patch files. What I did is add a second command to replace the color 00070b with 000000. That seems to have done the trick, though I will test your latest suggestion as I prefer the cleaner one step process if it is possible.
That version should be recent enough for -alpha. The current version is 6.8.0.5.
Be sure the specify hex colors with quotes and the # symbol. -fill "#ff0000" as red for example.
Fred, I updated to version 6.8.0-Q16 and the command worked great. I tried it out with the specific hex colors I need and it worked perfectly. So once again, thank you for all your help.
If I may, I'd like to ask one follow up question.
After the +opaque black, is there a way to specify a second color to ignore? I want to be able to add #404040 to the list of colors not to touch. This only affects a small number of images that have a second color in them.
markdmac wrote:
After the +opaque black, is there a way to specify a second color to ignore? I want to be able to add #404040 to the list of colors not to touch. This only affects a small number of images that have a second color in them.
To do that you could create a mask of the colors you want to preserve. You would have to first save your alpha channel. Create the mask, then use the mask to recolor everything else and then add your alpha channel back.
You can also do it with the same kind of command above, so long as you have a known safe color that is not being used in the image or use transparent, but in the latter case you would have to save off the alpha channel, process and then add it back again.
Fred, I did download and instal CygWin, but have no idea how to run your scripts within it.
I'd be most happy to take full advantage of that script if you can provide some direction there. With some testing, I might even be able to automate the process for all the images in a folder by combining VBscript and using the SendKeys method to send file names to your script.
You probably do not need Cygwin. If you post a link to a more complex example I can probably give you the IM commands to process it.
Unfortunately, I do not use Windows and know nothing about it. Best I can do is refer you to http://www.imagemagick.org/Usage/windows/#cygwin. You will need to be sure that you have all the unix commands installed with Cygwin, such as: bc (often missing), expr, sed, awk, tr, sort, etc.
Perhaps some kind Windows/Cygwin user can offer more pointers.