Is there a way to make an Inkscape template where every image that is dragged and dropped onto the canvas has a template applied to it so that a label text is set to the filename and the image grid is 3 pictures wide?
-Gui sends current svg to the extension system. -Svg is processed -Svg is returned ( You can generate svgs too, but it's very similar )
However, the extension system does not support drag and drop. It also has no way to intercept or be triggered by drag and drop to the gui.
Drag and drop can be done using a custom Gtk3 windows built using glade if you want to do that.
This is not part of the Inkscape inkex api - just standard Gtk3 you would have to write yourself.
However as this is part of the extension loop, it cannot return any data to the Inkscape canvas until the extension exits.
This means you cannot drop files one by one and see them appear on the canvas from a single run of the extension. You could drop 4 files in one drag or relaunch the extension again and drag another.
**It is actually possible to write a very convoluted workaround to this by writing a tempfile, then calling dbus to launch a 2nd child extension from the 1st. However I don't know of any extensions which do this (apart from one I wrote as an experiment)**
After the drag and drop code is written it's a case of using PIL (Pillow) which is bundled with Inkscape on Windows to read the dnd image and convert it to base64 (if you want an embedded image)
PIL can read metadata etc from images too.
For the text, inkex can easily create text objects.
You would have to do some calculations with bounding boxes of the images to place them, relative to existing images on canvas.
Also if you want perfect text alignment, it would require a command call to the main inkscape program from the extension, as inkex cannot calcuate text bounding boxes. (There is an exception to this - you can use David Burghoff's textparser)
--------------------- You could however just forget the drag and drop feature. Drag 4 images in the normal way onto canvas, select all 4 image, then run a much simpler extension to achieve what you want - that's what I would do.
I've been looking for an image grid generator that puts the name of the file underneath the image.
Something easy to use like this but includes the file name of the image under the picture: https://image-grid-generator.com/
Is there a way to make an Inkscape template where every image that is dragged and dropped onto the canvas has a template applied to it so that a label text is set to the filename and the image grid is 3 pictures wide?
In theory anything can be done.
See the note at the very bottom :)
The extension system is:
-Gui sends current svg to the extension system.
-Svg is processed
-Svg is returned
( You can generate svgs too, but it's very similar )
However, the extension system does not support drag and drop.
It also has no way to intercept or be triggered by drag and drop to the gui.
Drag and drop can be done using a custom Gtk3 windows built using glade if you want to do that.
This is not part of the Inkscape inkex api - just standard Gtk3 you would have to write yourself.
However as this is part of the extension loop, it cannot return any data to the Inkscape canvas until the extension exits.
This means you cannot drop files one by one and see them appear on the canvas from a single run of the extension.
You could drop 4 files in one drag or relaunch the extension again and drag another.
**It is actually possible to write a very convoluted workaround to this by writing a tempfile, then calling dbus to launch a 2nd child extension from the 1st.
However I don't know of any extensions which do this (apart from one I wrote as an experiment)**
After the drag and drop code is written it's a case of using PIL (Pillow) which is bundled with Inkscape on Windows to read the dnd image and convert it to base64 (if you want an embedded image)
PIL can read metadata etc from images too.
For the text, inkex can easily create text objects.
You would have to do some calculations with bounding boxes of the images to place them, relative to existing images on canvas.
Also if you want perfect text alignment, it would require a command call to the main inkscape program from the extension, as inkex cannot calcuate text bounding boxes.
(There is an exception to this - you can use David Burghoff's textparser)
---------------------
You could however just forget the drag and drop feature.
Drag 4 images in the normal way onto canvas, select all 4 image, then run a much simpler extension to achieve what you want - that's what I would do.