I have started learning how to write a plugin for inkscape using Python. My mileage is very short. And so is my taste and skills for Python. But I am a relatively skilled programmer (C/C++/Perl/Java). I am posting here an outline of the problem/use-case as a RFC for not re-inventing the wheel.
- 0. Another software (AS) is some sort of typesetting software with zero capabilities when drawing paths and squigles and calligraphy BUT it can load SVG files, scale them and place them at (x,y).
1. Inkscape is started by AS with an input PNG filename which is the background image currently in AS. This is always true, an image will be loaded to inkscape when called by AS.
2. User creates one or more curves/paths in inkscape, for example using the calligraphy tool.
3. When finished, user runs the proposed inkscape plugin which does the following:
- a. find convex hull (*) of all selected paths
b. write top-left corner coordinates of convex hull to file
c. somehow find the scale-factor of the selected paths wrt the whole image and write it to same output file (OF)
4. Background image is deleted and all paths saved to an SVG file
5. the "other software" (AS) loads the SVG file and positions the paths at the location specified by the text file (OF) and scales it accordingly.
6. Ideally the paths created by inkscape and loaded into AS should fall exactly where user drew them in inkscape.
*) For the convex hull I am using code by user ragstian (viewtopic.php?t=13622#p52785) which I also modified to write coordinates of top-left corner to file.
What I am asking from you is
- your opinion about my methodology,
whether something like this or part of it exists,
what's a good way to find the scale factor of selected paths relative to background image, as a percentage.
pointers to inkscape's plugin API. For example I just found how to popup a warning/info message.
But how do i get the filepath of the input image loaded originally to inkscape?