Change png icon color

Post questions on how to use or achieve an effect in Inkscape.
rsf
Posts: 9
Joined: Mon Jun 25, 2012 8:53 pm

Change png icon color

Postby rsf » Mon Jun 25, 2012 8:57 pm

Hello.
I'm importing some small png icons to use in inkscape.
These are black and white antialiased images with transparency.
I would like to change their color to match a given named color.
Red instead of black for example.
Is the any way to do this?
Thanks

User avatar
microUgly
Site Admin
Posts: 2985
Joined: Sat Jun 02, 2007 3:13 pm
Contact:

Re: Change png icon color

Postby microUgly » Mon Jun 25, 2012 9:59 pm

Inkscape is for working with vectors. If you want to edit a PNG, you want to use something like GIMP instead. You will be able to convert Black to Red very easily in GIMP.

rsf
Posts: 9
Joined: Mon Jun 25, 2012 8:53 pm

Re: Change png icon color

Postby rsf » Tue Jun 26, 2012 7:57 pm

Yes. I know I can change the bitmap itself.
In this case I use quite a few icons in a site mockup and would like to try different icon colors.
It seams this can be done with filters (color matrix maybe).
Is there a why to create a filter that would colorize a bitmap in a simpler way?
Preferably using a named color as parameter?
Thanks

chriswww
Posts: 383
Joined: Fri Nov 19, 2010 3:04 pm

Re: Change png icon color

Postby chriswww » Wed Jun 27, 2012 12:02 pm

you can use raster graphics as part of whatever work in inkscape but it was not designed to manipulate these other than sizing, moving, or filtering etc as part of an inkscape composition. inkscape is first and foremost for vector work. If your icons don't have a whole lot of intricate detail you could also trace in inkscape, which will convert to vector...but this is not the simplest of things to do right.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Change png icon color

Postby brynn » Wed Jun 27, 2012 1:15 pm

You could create your own custom filters for this, and set them up with named colors in their name or title, if you like. But learning how to create a new filter from scratch has proven exceedingly difficult for me. So I couldn't tell you how. I have found it easier to tweak existing filters, but that took several hours of studying the manual and experimenting. It does look like the Color Matrix primitive is used exclusively in many, if not all Filters menu > Color filters. The Color Matrix totally makes no sense to me though, so again, I couldn't help.

Oh! Well another way to add color using a filter, is the Flood primitive. But that would fill the icon with a single color, not for example, the background of the icon, or foreground, or whatever. I assume the icons are all different. Are they a single closed shape, say like the 4 suits in a deck of cards? If that's the case, the Flood primitive might be the ticket. But going from Flood primitive to filter, I couldn't say exactly how.

Another member and I have taken up the task of learning how to create a filter from scratch, and then writing a tutorial in simple language, once we figure it out. But who knows how long that will take, lol!

rsf
Posts: 9
Joined: Mon Jun 25, 2012 8:53 pm

Re: Change png icon color

Postby rsf » Wed Jun 27, 2012 10:38 pm

Icons are just bitmaps with transparency.
I was just wondering if there was any already available filters for this task.
I'll browse to see if there are any filters already available and ultimately try to create some kind of rgb multiply filter (and invert option since in the case I want to colorize black pixels)
Don't know If I'll manage to do it dough. It seams quite complicated...
Thanks anyway.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Change png icon color

Postby brynn » Wed Jun 27, 2012 10:56 pm

Yeah, the bottom line is that there are no pre-exising filters that will do exactly what you want. You may find some that you can tweak. But otherwise you'd have to make your own.

But short of doing that, I'm wondering if you couldn't just take a screenshot of your web layout in Inkscape. Then use GIMP (or other raster editor) to try different colors. Once you find the colors you want for each icon, change it in the raster editor, then import back to Inkscape. Would that work?

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: Change png icon color

Postby v1nce » Thu Jun 28, 2012 5:27 am


chriswww
Posts: 383
Joined: Fri Nov 19, 2010 3:04 pm

Re: Change png icon color

Postby chriswww » Thu Jun 28, 2012 10:47 am

as long as things remain non-complicated....import the black and transparency png, select this object, from menu Filters > Color > colorize. from menu choose Filters > filter editor. in the filter editor dialog select the Color Matrix effect if not already selected, near the bottom of the filter editor dialog in Effect Parameters change Type from default Saturate to Matrix. all the black has now become red by default. to change the color select the Flood component of the filter (the effect) and near the bottom of the filter editor dialog you can change flood color in the usual color picker.

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Change png icon color

Postby druban » Thu Jun 28, 2012 9:10 pm

This method is a bit of a cheat. additionally it works best when used with an image that actually has NO transparency, that is, the transparent areas are all converted to opaque white. You can do this in GIMP or some other program by flattening the image or saving it in a format that does not allow transparency. Once you do all the preliminaries, though, the color is super easy to change, especially in the xml file, without even opening it in Inkscape.
Downside: Masks are not always rendered correctly in other programs even though they are SVG compliant. Sad fact.
Also, I know it's not a vey impressive example of an icon, :oops:
image818.png
image818.png (161.86 KiB) Viewed 6414 times

:o AAAARGH! I accidentally made the graphic say 'clip' instead of 'mask' :roll: :oops:
Later: I've corrected it - sloppily - because I had already deleted the file.
Your mind is what you think it is.

rsf
Posts: 9
Joined: Mon Jun 25, 2012 8:53 pm

Re: Change png icon color

Postby rsf » Thu Jul 05, 2012 3:46 am

Hi.
Thanks a lot for the ideas.
I finished the mockup but now I have a starting point to investigate this further.
Using named color is really an advantage. Could the colorize filter use a named color?
Thanks again.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Change png icon color

Postby brynn » Sat Jul 07, 2012 4:51 pm

Actually I've just started to look into filters a little more intensely than before, and I think I know what you can do. Give me a couple hours, or maybe couple of days, lol. I'll make you a tutorial for making a custom filter. Within the filter, you will have to use hexcode, rgb, or dropper tool to set the color. But you could name the filter by the name of the color -- like blue filter, red filter, etc.

I'm not positive that I will be able to do this, but I think I can. And as soon as I get it figured out, I'll give you instructions :D


Return to “Help with using Inkscape”