Change color

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
fohnbit
Posts: 9
Joined: 2015-04-07T00:33:49-07:00
Authentication code: 6789

Change color

Post by fohnbit »

Hello!

I´m totally new with ImageMagick. I use Ubuntu x64.

I have a lot of PNG, with indexed color (only black) with transparent Background.

I need different colours of this .png files.
Is it possible with ImageMagick?

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

Re: Change color

Post by snibgo »

To change black into (say) red:

Code: Select all

convert in.png -fill red -opaque black out.png
snibgo's IM pages: im.snibgo.com
fohnbit
Posts: 9
Joined: 2015-04-07T00:33:49-07:00
Authentication code: 6789

Re: Change color

Post by fohnbit »

Hello!

Many thanks to this fast reply, but there are still black colors.
Also the transparenz of the black color I lost.

Attached the original and the converted to red.

In the Red Picture you see it is different too the original.

http://de.tinypic.com/r/34nruba/8 (original)
http://de.tinypic.com/r/1zwz2w7/8 (converted to red)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Change color

Post by snibgo »

Code: Select all

convert in.png -alpha off -fill red -opaque black -alpha on out.png
snibgo's IM pages: im.snibgo.com
fohnbit
Posts: 9
Joined: 2015-04-07T00:33:49-07:00
Authentication code: 6789

Re: Change color

Post by fohnbit »

The Hello!

Thank you ... near to the result who I need.
Now it is complete red, but the black parts (with some transparenz) are now filled.
Did you know what what I mean?

The smooth edges of the black color is now hard in red.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Change color

Post by snibgo »

Code: Select all

convert in.png -alpha off -fill red -opaque black -alpha on out.png
For me, IM v6.9.1-0, the alpha values in out.png are the same as in.png.
snibgo's IM pages: im.snibgo.com
fohnbit
Posts: 9
Joined: 2015-04-07T00:33:49-07:00
Authentication code: 6789

Re: Change color

Post by fohnbit »

Hi!

I use Windows 6.9.1-1-Q16-x64 ... maybe this is the problem?
fohnbit
Posts: 9
Joined: 2015-04-07T00:33:49-07:00
Authentication code: 6789

Re: Change color

Post by fohnbit »

Hello again!

I checked the files .. some are indexed colours, some are RGB.
Is for RGB the same command?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Change color

Post by snibgo »

The same command is used for RGB and indexed files.

What version of ImageMagick do you use?
snibgo's IM pages: im.snibgo.com
fohnbit
Posts: 9
Joined: 2015-04-07T00:33:49-07:00
Authentication code: 6789

Re: Change color

Post by fohnbit »

I use 6.9.1.1.Q16-x64 on Windows 8.1 x64.

I also tried 6.9.1.1.Q8-x64 ... same result.

Is there somewhere a link to 6.9.1-0 ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Change color

Post by snibgo »

6.9.1.1 should be fine.

I examined the alpha values with Gimp. My result is:
Image
snibgo's IM pages: im.snibgo.com
fohnbit
Posts: 9
Joined: 2015-04-07T00:33:49-07:00
Authentication code: 6789

Re: Change color

Post by fohnbit »

Ok, I guess with my english I could not describe it clearly.
I have the same result, but it is not same as original.

When you check the original Image, you can see there are some pixel semi-transparent (when you open in Gimp and zoom in).
After convert, it lost this semi-transparent pixel and show full color pixel.

Did you know what I mean?

Thank you for your great help(!)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Change color

Post by snibgo »

In Gimp, I zoom to 800% and use the eyedropper tool. This tells me the pixel values. The background has alpha = 0%. The red guitar has alpha at many values, including 1%, 5%, 11%, 12%, 43%, 47%, 77% and 100%.
snibgo's IM pages: im.snibgo.com
fohnbit
Posts: 9
Joined: 2015-04-07T00:33:49-07:00
Authentication code: 6789

Re: Change color

Post by fohnbit »

Ok, that is strange!
Which Version of Gimp you are using?
fohnbit
Posts: 9
Joined: 2015-04-07T00:33:49-07:00
Authentication code: 6789

Re: Change color

Post by fohnbit »

Hello!

I open the new File with Windows paint, and he show me the image correct.
So it must be a problem of Gimp.

Thank you for your help ... it is solved(!)
Post Reply