[HELP] Bulk change the name of kpp brushes

Hello,
I made 120 brushes (so I have 120 .kpp files). I need to change their names (not the file name, I mean the name property).

I can do it in Krita (using the Resource Manager) but doing it with 120 brushes is a “little bit” frustrating :slight_smile:

Is there a way to make this operation faster or easier? For example, using ImageMagick or some tools?

Thanx!

1 Like

Well, I’d be interested in that too, I only know the method via the brush editor so far.
But maybe one could find a way, because I use the tool “Krita Brush Info” by Kenneth Evans to read out preset information, and that uses “ExifTool” by Phil Harvey to read out the presets.
So I could imagine that, with help of these tools, one could find a way to locate the name string stored in the presets and then possibly change it, if one can already read out the presets settings with these tools. But this would require some research and testing to see if the integrity of the KPP’s would be preserved by such an intervention, or if you would have to completely regenerate the entire header, for example. Unfortunately, this is way beyond my script pushing abilities.

Michelist

kpp files are png files, so any tool that can change the TEXT segment should work. The brush properties are XML, so parsing that is easy. I think you should be able to use the code from Brush Fixer for brushes created in Krita 5.1 beta 1 as a starting point – it loads the preset as a QImage, uses QImage::text to get the text segment, manipulates it, then sets the text back and saves the file.

1 Like

Hi halla,
thanks for this suggestion! Actually, it seems to be the right path to follow.
In case I make it work, I’ll share a plugin for the people who may have my need.

Thanx!
Stefano

2 Likes

I wanted to create a plugin that would partially solve this issue I just did not have time for it yet. Just to say it will come to be too I already have the name allocated on GitHub even. But I need to do my commissions first.

3 Likes

A while ago i did some scripts to do that. These are pure python scripts, not krita scripts or plugins. Has been a while since i last used them but you can try using it.

3 Likes

Thanx to all for your help.

I preferred to follow the @halla suggestion because it’s a more Krita-friendly solution. It worked and I renamed all my brushes.

In my very personal opinion, it should be a built-in feature in Krita, but I understand that there are a lot of features and fixes with a higher priority.

EDIT:

I noticed that the renamed brushes work correctly, but in the Log Viewer this message appears (only the first time) when I select a brush:

WARNING:
KisResourceLocator::loadRequiredResources failed to sanity check the embedded resource:
parent resource: KoResourceSignature(“paintoppresets”, “”, “TFSB__Bold__42.kpp”, “TFSB Bold 42”)
embedded resource: KoResourceSignature(“patterns”, “b31dac2e165bf8e93691ccf62184ba88”, “bold-42.pat”, “\u001F(bold-42.pat)”)

It’s not a blocking warning, it’s just annoying to see. May I have to recalculate that signature code in some way?

My approach was made to be used without needing to open krita as at the time i also didn’t know how to script in krita. But i agree with you this should be in krita. I think someone made a feature request for it too

Have you changed the pattern names as well?

No, I have just changed the name of the brush.
Practically, when I read the “preset” field from the .kpp file and I got the XML string

<Preset name="my_old_name" paintopid="paintbrush"> <param type="string...

I just replace “my_old_name” with a new name. I do only this. I don’t change any other part of the XML.

Any suggestion on how to resolve the sanity check warning on the embedded resource?

KoResourceSignature(“patterns”, “b31dac2e165bf8e93691ccf62184ba88”, “bold-42.pat”, “\u001F(bold-42.pat)”)