Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GIMP Plug-in for Simple SVG Exports
#!/usr/bin/env python
# GIMP Plug-in for Simple SVG Exports
# Copyright (C) 2016 by Dylan Grafmyre <thorsummoner@live.com>
#
# 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 <jononor@gmail.com>
# 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()
@LinuxBeaver
Copy link

LinuxBeaver commented Mar 22, 2021

Hello, will this plugin be ported to Python3 and capable of working with Gimp 3?

@dylan-grafmyre
Copy link

dylan-grafmyre commented Mar 23, 2021

@Just-Another-Gnumer Hey there
I think this script is already python3 compatible, I couldn't find a release candidate for "Gimp 3", could you help me find out more about what the changes to gimpfu will be? This might work on gimp3 already, please let me know if you have an issue

@jcornelius2013
Copy link

jcornelius2013 commented Mar 30, 2022

I've never added a plug in file on gimp is there someone that could give me a quick step by step as to how I would do this.
Thanks.

@thorsummoner
Copy link
Author

thorsummoner commented Mar 31, 2022

@jcornelius2013

download the .py file, locate your gimp Assets folder,
https://www.gimp.org/tutorials/Asset_Folders/

- In Windows 7 and later versions:
     C:\Users\{your_id}\AppData\Roaming\GIMP\2.10 (a.k.a. %APPDATA%/GIMP/2.10)

- In Linux: /home/{your_id}/.config/GIMP/2.10 (a.k.a.
     $XDG_CONFIG_HOME/GIMP/2.10)

- In OSX: /Users/{your_id}/Library/GIMP/2.10/ or possibly
  /Users/{your_id}/Library/Application
     Support/GIMP/2.10/ (this could depend on the GIMP build you use).
     (a.k.a. NSApplicationSupportDirectory/GIMP/2.10)

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 installed
under many different menus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment