How to Import SVG through console as done through UI - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: How to Import SVG through console as done through UI (/Thread-How-to-Import-SVG-through-console-as-done-through-UI) |
How to Import SVG through console as done through UI - kthedude - 02-15-2024 I have don’t a lot of searching and I cannot find much on the ‘file-svg-load’ procedure. If I start gimp from the directory in which an SVG is located using Code: gimp —verbose -b - And then enter the following procedure Code: (file-svg-load 1 “infile.svg” “infile.svg” 90.0 0 0 0 The UI flashes for a moment but then nothing happens and I don’t see an error. And the console shows a number in parenthesis which I believe represents the returned image. Should O now be able to see the image in the UI? How can I use file-png-save-defaults with this image to save it? If so I don’t know what “drawable” to use. RE: How to Import SVG through console as done through UI - Ofnuts - 02-15-2024 You are missing a closing parenthesis, but that could be a typo. Like all file-*-load procedures (file-svg-load 1 “infile.svg” “infile.svg” 90.0 0 0 0) returns the ID of the loaded image (if successful). This ID should be used in a call to (gimp-image-get-active-layer image) to get the ID of the active layer of the image (its only layer), and you can then use the IDs of both image and layer (as the "drawable") in the arguments to (file-png-save ...). So typically you assign the id returned in the call to a variable. This said using Gimp to just convert from SVG to PNG is probably the most painful way to do it. Using the (free) ImageMagick utility it is as simple as: convert -density 90 infile.svg outfile.png (in recent versions of imagemagick the "convert" above is probably "magick" or "magick convert") RE: How to Import SVG through console as done through UI - kthedude - 02-16-2024 I used the following set of commands in the interactive console (running gimp --verbose -b -) and received the error "Error: Invalid type of argument 1 to gimp-image-get-active-layer" Code: (define myImage (file-svg-load 1 "infile.svg" "infile.svg" 90.0 0 0 0)) And if I run the following directly from the console, I get the error "unbound variable: myImage" Code: --verbose -b '(define myImage (file-svg-load 1 "infile.svg" "infile.svg" 90.0 0 0 0))' -b '(file-png-save-defaults 1 myImage (gimp-image-get-active-layer myImage) "outfile.png" "outfile.png")' I appreciate the tip on ImageMagick, I used it successfully just now. I had seen some others say that it was not a good tool for SVGs and so I didn't peruse it. However, I would like to know in practice how this would be done in gimp if possible. RE: How to Import SVG through console as done through UI - Ofnuts - 02-16-2024 (02-16-2024, 01:35 AM)kthedude Wrote: I used the following set of commands in the interactive console (running gimp --verbose -b -) and received the error "Error: Invalid type of argument 1 to gimp-image-get-active-layer" I don't know Scheme but I think define myImage... should be let myImage... |