Last active
February 15, 2024 10:43
-
-
Save thorsummoner/3ad6f806f1c08246f240222a3c0a5c47 to your computer and use it in GitHub Desktop.
GIMP Plug-in for Simple SVG Exports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# GIMP Plug-in for Simple SVG Exports | |
# Copyright (C) 2016 by Dylan Grafmyre <[email protected]> | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 3 of the License, or | |
# (at your option) any later version. | |
# based on an openraster plugin by Jon Nordby <[email protected]> | |
# https://git.gnome.org/browse/gimp/tree/plug-ins/pygimp/plug-ins/file-openraster.py?h=GIMP_2_8_16 | |
import gimpfu | |
def register_save_handlers(): | |
gimpfu.gimp.register_save_handler('file-svg-save', 'svg', '') | |
def save_svg(img, drawable, filename, raw_filename): | |
gimpfu.gimp.pdb.gimp_vectors_export_to_file(img, filename, None) | |
gimpfu.register( | |
'file-svg-save', #name | |
'save an SVG (.svg) file', #description | |
'save an SVG (.svg) file', | |
'Dylan Grafmyre', #author | |
'Dylan Grafmyre', #copyright | |
'2016', #year | |
'SVG', | |
'*', | |
[ #input args. Format (type, name, description, default [, extra]) | |
(gimpfu.PF_IMAGE, "image", "Input image", None), | |
(gimpfu.PF_DRAWABLE, "drawable", "Input drawable", None), | |
(gimpfu.PF_STRING, "filename", "The name of the file", None), | |
(gimpfu.PF_STRING, "raw-filename", "The name of the file", None), | |
], | |
[], #results. Format (type, name, description) | |
save_svg, #callback | |
on_query = register_save_handlers, | |
menu = '<Save>' | |
) | |
gimpfu.main() |
In case it helps anyone else: On Linux, once the .py
file has been installed in the $HOME/.config/GIMP/2.10/plug-ins
directory, make sure the file has the "execute" bit set. If you're on the command line, you can do this: chmod +x {filename}.py
.
At least that's what it took to make this plugin start working on my Linux box (Ubuntu 20.04).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jcornelius2013
download the .py file, locate your gimp Assets folder,
https://www.gimp.org/tutorials/Asset_Folders/
if necessary, create a "scripts" folder inside the asset folder (asset
folder usually has the version number in it),
place a copy of the .py file inside the scripts folder
quit gimp fully, and open it anew
It can be hard to confirm if a plugin got loaded, it may often be found
under
Filters
->Script-Fu
-> (plugin name), but it could be installedunder many different menus.