Mass-convert brushes from version 2 to version 3?

brushes
Tags: #<Tag:0x00007fa778a09ae8>

#1

GIMP’s integration with MyPaint’s brushes fails to “see” older brushes. Is there any way to batch-convert all version 2 brushes to version 3?

I’m trying to come up with some insane “sed” line, but perhaps it has already been done, or can be done more easily with the program itself, like “$ mypaint --update-brushes-to-new-version-please”.

I guess other specifications don’t matter much here, except that I’m on Linux, Debian specifically.


#2

If you look in lib/brush.py there is a helper function to convert older formats.

Have you tried this? It’s almost batch… Load the brushes into mypaint gui and then export the brush group as a zip file. I think that will write out the brushes in the new format.


#3

Thanks! I’ll try the brush.py thing. I had actually already exported the brush groups just for the sake of having GIMP’s tags following MyPaint’s groups, and it preserved the older version of the brushes.


#4

Bummer. I wonder if you clone each brush if that would upgrade it. Failing that, making some sort of edit (add a note) to each brush might do it. . . .hardly a “mass convert” though. . .


#5

Apparently "/lib/mypaint/lib/brushes_migrate_json.py " does just that, but I’m not being able to make it work, getting “/usr/bin/python: Import by filename is not supported.”

I got the command line from here:

Usage: PYTHONPATH=. python -m lib/brushes_migrate_json [BRUSHDIR…]

Using python 3.5 and 3.6 the errors are different:

$ PYTHONPATH=. /usr/bin/python3.6 -m /usr/local/lib/mypaint/lib/brushes_migrate_json.py /home/d/.config/GIMP/2.9/brushesmyp/02-sketch/
/usr/bin/python3.6: Error while finding module specification for ‘/usr/local/lib/mypaint/lib/brushes_migrate_json.py’ (ModuleNotFoundError: No module named ‘/usr/local/lib/mypaint/lib/brushes_migrate_json’)

$ PYTHONPATH=. /usr/bin/python3.5 -m /usr/local/lib/mypaint/lib/brushes_migrate_json.py 02-sketch
/usr/bin/python3.5: Error while finding module specification for ‘/usr/local/lib/mypaint/lib/brushes_migrate_json.py’ (ImportError: No module named ‘/usr/local/lib/mypaint/lib/brushes_migrate_json’)


#6

Haha, good find. that was right under my nose, too.

I think you’ll want to cd into that folder:
cd /usr/local/lib/mypaint/
when you run that command:
PYTHONPATH=. python -m lib/brushes_migrate_json /home/d/.config/GIMP/2.9/brushesmyp/02-sketch/

But I couldn’t get it to work either, getting:
No module named lib/brushes_migrate_json


#7

Same here, with Python 3.
I’m guessing the solution may be related with this:
https://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html


#8

Now it worked. somehow.

I’m puzzled because I don’t know what exactly I did differently now, I was pretty much hopeless even trying some defunct install remains, but this worked, now, with python2, and the mypaint folder/install I was actually using:

PYTHONPATH=. python -m lib/brushes_migrate_json /home/d/.config/GIMP/2.9/brushesmyp/04-texture/

Most of the time I’m just using the bash history command, I’ve tried some variations like without the “-m” and adding ./ and .py, to no avail, and then, somehow it worked, when I was expecting an error message.

One of the rare instances where solving a problem somehow makes me feel just as stupid as when I couldn’t solve it, if not even more.


#9

You’ve got to be kidding. I still can’t get it to work. However, this seems to be another way, running from the mypaint src folder:

python
from lib import brushes_migrate_json
brushes_migrate_json.migrate_brushes_to_json(’./brushes’)

or whatever path to brushes. I didn’t actually check if it worked, but no errors :slight_smile:
I still have no idea why the -m run-as-a-module script method doesn’t work 99.99% of the time but magically worked for you.