RSS/Atom feed Twitter
Site is read-only, email is disabled

SVG to PNG using a script

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

15 of 15 messages available
Toggle history

Please log in to manage your subscriptions.

SVG to PNG using a script Tres Finocchiaro via gimp-user-list 21 Apr 19:47
  SVG to PNG using a script Tres Finocchiaro via gimp-user-list 21 Apr 19:48
  SVG to PNG using a script Guy Stalnaker via gimp-user-list 21 Apr 19:53
   SVG to PNG using a script Tres Finocchiaro via gimp-user-list 21 Apr 19:59
  SVG to PNG using a script Liam R E Quin 21 Apr 20:24
   SVG to PNG using a script Tres Finocchiaro via gimp-user-list 21 Apr 20:36
    SVG to PNG using a script Tres Finocchiaro via gimp-user-list 21 Apr 20:39
     SVG to PNG using a script Tres Finocchiaro via gimp-user-list 21 Apr 20:46
     SVG to PNG using a script Liam R E Quin 21 Apr 22:26
      SVG to PNG using a script Tres Finocchiaro via gimp-user-list 23 Apr 15:51
       SVG to PNG using a script Tres Finocchiaro via gimp-user-list 23 Apr 17:39
        SVG to PNG using a script Tres Finocchiaro via gimp-user-list 23 Apr 17:51
         SVG to PNG using a script Tres Finocchiaro via gimp-user-list 23 Apr 18:00
  SVG to PNG using a script Michael Schumacher 21 Apr 20:57
   SVG to PNG using a script Tres Finocchiaro via gimp-user-list 21 Apr 21:04
Tres Finocchiaro via gimp-user-list
2020-04-21 19:47:17 UTC (about 4 years ago)

SVG to PNG using a script

Hi,

I'm looking into Gimp as a viable scripting solution for a project however most of the scripting references I'm finding are either sparse or dated.

I was wonder if there was a way to utilize Gimp's scripting system to convert an SVG to a PNG?

The best resource I've found is here however, attempts to run this on my machine are failing using GIMP 2.1.0.

http://www.jasonhardin.com/programming/2012/08/23/Gimp-svg-to-png-script/#disqus_thread

The script I'm running: gimp -i --batch='(svg-to-raster "src.svg" "dst.png" 72 0 0)' --batch='(gimp-quit
0)'

Unfortunately it throws the following error: batch command experienced an execution error: Error: eval: unbound variable: file-svg

I'm using MacOS to write the script, but the target platform is Windows.

I understand there are many other tools for performing this conversion (and I'm leveraging these tools in other parts of code) but I was hoping to write this as a fallback for this particular system.

Best regards,

-Tres

- Tres.Finocchiaro@gmail.com

Tres Finocchiaro via gimp-user-list
2020-04-21 19:48:51 UTC (about 4 years ago)

SVG to PNG using a script

Apologies, typo:
Error: eval: unbound variable: file-svg

Should have been: Error: eval: unbound variable: *svg-to-raster *

- Tres.Finocchiaro@gmail.com

On Tue, Apr 21, 2020 at 3:47 PM Tres Finocchiaro wrote:

Hi,

I'm looking into Gimp as a viable scripting solution for a project however most of the scripting references I'm finding are either sparse or dated.

I was wonder if there was a way to utilize Gimp's scripting system to convert an SVG to a PNG?

The best resource I've found is here however, attempts to run this on my machine are failing using GIMP 2.1.0.

http://www.jasonhardin.com/programming/2012/08/23/Gimp-svg-to-png-script/#disqus_thread

The script I'm running: gimp -i --batch='(svg-to-raster "src.svg" "dst.png" 72 0 0)' --batch='(gimp-quit 0)'

Unfortunately it throws the following error: batch command experienced an execution error: Error: eval: unbound variable: file-svg

I'm using MacOS to write the script, but the target platform is Windows.

I understand there are many other tools for performing this conversion (and I'm leveraging these tools in other parts of code) but I was hoping to write this as a fallback for this particular system.

Best regards,

-Tres

- Tres.Finocchiaro@gmail.com

Guy Stalnaker via gimp-user-list
2020-04-21 19:53:59 UTC (about 4 years ago)

SVG to PNG using a script

Tres,

Several perhaps better options are tools intended for command line use:

https://www.imagemagick.org/script/download.php

Or, for considerably more sophisticated image work (with correspondingly more detailed and opaque documentation) G'MIC (which also has a builtin tool for use inside GIMP usually packaged with GIMP):

https://gmic.eu/download.shtml

Both of these tools can be scripted.

Regards.

Guy Stalnaker jimmyg521@gmail.com

On Tue, Apr 21, 2020 at 2:47 PM Tres Finocchiaro via gimp-user-list < gimp-user-list@gnome.org> wrote:

Hi,

I'm looking into Gimp as a viable scripting solution for a project however most of the scripting references I'm finding are either sparse or dated.

I was wonder if there was a way to utilize Gimp's scripting system to convert an SVG to a PNG?

The best resource I've found is here however, attempts to run this on my machine are failing using GIMP 2.1.0.

http://www.jasonhardin.com/programming/2012/08/23/Gimp-svg-to-png-script/#disqus_thread

The script I'm running: gimp -i --batch='(svg-to-raster "src.svg" "dst.png" 72 0 0)' --batch='(gimp-quit
0)'

Unfortunately it throws the following error: batch command experienced an execution error: Error: eval: unbound variable: file-svg

I'm using MacOS to write the script, but the target platform is Windows.

I understand there are many other tools for performing this conversion (and I'm leveraging these tools in other parts of code) but I was hoping to write this as a fallback for this particular system.

Best regards,

-Tres

- Tres.Finocchiaro@gmail.com _______________________________________________ gimp-user-list mailing list
List address: gimp-user-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list List archives: https://mail.gnome.org/archives/gimp-user-list

Tres Finocchiaro via gimp-user-list
2020-04-21 19:59:07 UTC (about 4 years ago)

SVG to PNG using a script

Hmm... I'm not sure why the scripting system is continuously dismissed as a viable solution. Is your answer that it's not viable. Requoting:

I understand there are many other tools for performing this conversion (and

I'm leveraging these tools in other parts of code) but I was hoping to write this as a fallback for this particular system.

- Tres.Finocchiaro@gmail.com

On Tue, Apr 21, 2020 at 3:54 PM Guy Stalnaker wrote:

Tres,

Several perhaps better options are tools intended for command line use:

https://www.imagemagick.org/script/download.php

Or, for considerably more sophisticated image work (with correspondingly more detailed and opaque documentation) G'MIC (which also has a builtin tool for use inside GIMP usually packaged with GIMP):

https://gmic.eu/download.shtml

Both of these tools can be scripted.

Regards.

Guy Stalnaker jimmyg521@gmail.com

On Tue, Apr 21, 2020 at 2:47 PM Tres Finocchiaro via gimp-user-list < gimp-user-list@gnome.org> wrote:

Hi,

I'm looking into Gimp as a viable scripting solution for a project however most of the scripting references I'm finding are either sparse or dated.

I was wonder if there was a way to utilize Gimp's scripting system to convert an SVG to a PNG?

The best resource I've found is here however, attempts to run this on my machine are failing using GIMP 2.1.0.

http://www.jasonhardin.com/programming/2012/08/23/Gimp-svg-to-png-script/#disqus_thread

The script I'm running: gimp -i --batch='(svg-to-raster "src.svg" "dst.png" 72 0 0)' --batch='(gimp-quit
0)'

Unfortunately it throws the following error: batch command experienced an execution error: Error: eval: unbound variable: file-svg

I'm using MacOS to write the script, but the target platform is Windows.

I understand there are many other tools for performing this conversion (and
I'm leveraging these tools in other parts of code) but I was hoping to write this as a fallback for this particular system.

Best regards,

-Tres

- Tres.Finocchiaro@gmail.com _______________________________________________ gimp-user-list mailing list
List address: gimp-user-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list List archives: https://mail.gnome.org/archives/gimp-user-list

Liam R E Quin
2020-04-21 20:24:29 UTC (about 4 years ago)

SVG to PNG using a script

On Tue, 2020-04-21 at 15:47 -0400, Tres Finocchiaro via gimp-user-list wrote:

I was wonder if there was a way to utilize Gimp's scripting system to convert an SVG to a PNG?

Yes, from python, perl or scheme (script-fu).

there's also batch mode add-ons such as phatch.

You might prefer to use Inkscape for this one - it can do this in the command-line.

The best resource I've found is here however, attempts to run this on my
machine are failing using GIMP 2.1.0.

Hoping you mean 2.10.18

I'm using MacOS to write the script, but the target platform is Windows.

We are a release behind n the Mac because we don't have a Mac maintainer right now.

I understand there are many other tools for performing this conversion (and
I'm leveraging these tools in other parts of code) but I was hoping to
write this as a fallback for this particular system.

For the error you're getting try changing file-svg to file-svg-save maybe.

slave

Liam Quin - https://www.fromoldbooks.org/

Slave in full-time voluntary servitude
Tres Finocchiaro via gimp-user-list
2020-04-21 20:36:27 UTC (about 4 years ago)

SVG to PNG using a script

I'm confused, I'm attempting to use the gimp command line, is it no longer supported? Why am I being told to use other tools still?

This is a specific attempt to use Gimp for a task. No additional software installed. If Gimp ships with a usable version of python in a reliable location, I'd be happy to leverage that, but the question is in regards to a target system with only Gimp installed, assuming it doesn't have Inkscape, ImageMagick Python or Perl.

I'm asking how to use the gimp command line only.

- Tres.Finocchiaro@gmail.com

On Tue, Apr 21, 2020 at 4:24 PM Liam R E Quin wrote:

On Tue, 2020-04-21 at 15:47 -0400, Tres Finocchiaro via gimp-user-list wrote:

I was wonder if there was a way to utilize Gimp's scripting system to convert an SVG to a PNG?

Yes, from python, perl or scheme (script-fu).

there's also batch mode add-ons such as phatch.

You might prefer to use Inkscape for this one - it can do this in the command-line.

The best resource I've found is here however, attempts to run this on my
machine are failing using GIMP 2.1.0.

Hoping you mean 2.10.18

I'm using MacOS to write the script, but the target platform is Windows.

We are a release behind n the Mac because we don't have a Mac maintainer right now.

I understand there are many other tools for performing this conversion (and
I'm leveraging these tools in other parts of code) but I was hoping to
write this as a fallback for this particular system.

For the error you're getting try changing file-svg to file-svg-save maybe.

slave

--
Liam Quin - https://www.fromoldbooks.org/

Slave in full-time voluntary servitude

Tres Finocchiaro via gimp-user-list
2020-04-21 20:39:29 UTC (about 4 years ago)

SVG to PNG using a script

Liam,

After re-reading your post, is it safe to assume my original question was written in scheme/script-fu?

If so, can someone direct me how to get a list of scheme commands that can be executed from a vanilla gimp install?

- Tres.Finocchiaro@gmail.com

On Tue, Apr 21, 2020 at 4:36 PM Tres Finocchiaro wrote:

I'm confused, I'm attempting to use the gimp command line, is it no longer supported? Why am I being told to use other tools still?

This is a specific attempt to use Gimp for a task. No additional software installed. If Gimp ships with a usable version of python in a reliable location, I'd be happy to leverage that, but the question is in regards to a target system with only Gimp installed, assuming it doesn't have Inkscape, ImageMagick Python or Perl.

I'm asking how to use the gimp command line only.

- Tres.Finocchiaro@gmail.com

On Tue, Apr 21, 2020 at 4:24 PM Liam R E Quin wrote:

On Tue, 2020-04-21 at 15:47 -0400, Tres Finocchiaro via gimp-user-list wrote:

I was wonder if there was a way to utilize Gimp's scripting system to convert an SVG to a PNG?

Yes, from python, perl or scheme (script-fu).

there's also batch mode add-ons such as phatch.

You might prefer to use Inkscape for this one - it can do this in the command-line.

The best resource I've found is here however, attempts to run this on my
machine are failing using GIMP 2.1.0.

Hoping you mean 2.10.18

I'm using MacOS to write the script, but the target platform is Windows.

We are a release behind n the Mac because we don't have a Mac maintainer right now.

I understand there are many other tools for performing this conversion (and
I'm leveraging these tools in other parts of code) but I was hoping to
write this as a fallback for this particular system.

For the error you're getting try changing file-svg to file-svg-save maybe.

slave

--
Liam Quin - https://www.fromoldbooks.org/

Slave in full-time voluntary servitude

Tres Finocchiaro via gimp-user-list
2020-04-21 20:46:24 UTC (about 4 years ago)

SVG to PNG using a script

Are my examples written in Carrette’s SIOD instead of TinyScheme? Was the svg-to-raster command removed in a certain version (or perhaps not distributed with the macOS build?).

This seems like it's a fairly simple script, but the fact that it doesn't work leads me to believe something has changed since the linked article was written.

- Tres.Finocchiaro@gmail.com

On Tue, Apr 21, 2020 at 4:39 PM Tres Finocchiaro wrote:

Liam,

After re-reading your post, is it safe to assume my original question was written in scheme/script-fu?

If so, can someone direct me how to get a list of scheme commands that can be executed from a vanilla gimp install?

- Tres.Finocchiaro@gmail.com

On Tue, Apr 21, 2020 at 4:36 PM Tres Finocchiaro < tres.finocchiaro@gmail.com> wrote:

I'm confused, I'm attempting to use the gimp command line, is it no longer supported? Why am I being told to use other tools still?

This is a specific attempt to use Gimp for a task. No additional software installed. If Gimp ships with a usable version of python in a reliable location, I'd be happy to leverage that, but the question is in regards to a target system with only Gimp installed, assuming it doesn't have Inkscape, ImageMagick Python or Perl.

I'm asking how to use the gimp command line only.

- Tres.Finocchiaro@gmail.com

On Tue, Apr 21, 2020 at 4:24 PM Liam R E Quin wrote:

On Tue, 2020-04-21 at 15:47 -0400, Tres Finocchiaro via gimp-user-list wrote:

I was wonder if there was a way to utilize Gimp's scripting system to convert an SVG to a PNG?

Yes, from python, perl or scheme (script-fu).

there's also batch mode add-ons such as phatch.

You might prefer to use Inkscape for this one - it can do this in the command-line.

The best resource I've found is here however, attempts to run this on my
machine are failing using GIMP 2.1.0.

Hoping you mean 2.10.18

I'm using MacOS to write the script, but the target platform is Windows.

We are a release behind n the Mac because we don't have a Mac maintainer right now.

I understand there are many other tools for performing this conversion (and
I'm leveraging these tools in other parts of code) but I was hoping to
write this as a fallback for this particular system.

For the error you're getting try changing file-svg to file-svg-save maybe.

slave

--
Liam Quin - https://www.fromoldbooks.org/

Slave in full-time voluntary servitude

Michael Schumacher
2020-04-21 20:57:38 UTC (about 4 years ago)

SVG to PNG using a script

On 4/21/20 9:47 PM, Tres Finocchiaro via gimp-user-list wrote:

The best resource I've found is here however, attempts to run this on my machine are failing using GIMP 2.1.0.

http://www.jasonhardin.com/programming/2012/08/23/Gimp-svg-to-png-script/#disqus_thread

The script I'm running: gimp -i --batch='(svg-to-raster "src.svg" "dst.png" 72 0 0)' --batch='(gimp-quit
0)'

Unfortunately it throws the following error: batch command experienced an execution error: Error: eval: unbound variable: file-svg

What you found is just the command line being used to run a custom script someone wrote - I assume this was available from one of the now-defunct links in the message you linked to.

In short: what you have found and posted is not a complete script, not by far.

In principle, the actual script was likely similar to the examples in https://www.gimp.org/tutorials/Basic_Batch/ - with different parameters, though, as it only really needs to open a file and export it with a different file name.

--
Regards,
Michael
GPG: 96A8 B38A 728A 577D 724D 60E5 F855 53EC B36D 4CDD

Tres Finocchiaro via gimp-user-list
2020-04-21 21:04:35 UTC (about 4 years ago)

SVG to PNG using a script

Michael,

You're completely right, the web archive of that original post has it for download. Here's the web archive article, which specifically mentions downloading svg-to-raster.scm.

https://web.archive.org/web/20140214102644/http://porpoisehead.net/mysw/index.php?pgid=gimp_svg

Fortunately, web archive had a copy of the scheme source. I've re-hosted it here: https://gist.github.com/tresf/c06aac6ceb51b86f328c3655fb503efe

I'll continue down this path and share my progress. Thanks kindly!

- Tres.Finocchiaro@gmail.com

On Tue, Apr 21, 2020 at 4:57 PM Michael Schumacher wrote:

On 4/21/20 9:47 PM, Tres Finocchiaro via gimp-user-list wrote:

The best resource I've found is here however, attempts to run this on my machine are failing using GIMP 2.1.0.

http://www.jasonhardin.com/programming/2012/08/23/Gimp-svg-to-png-script/#disqus_thread

The script I'm running:
gimp -i --batch='(svg-to-raster "src.svg" "dst.png" 72 0 0)' --batch='(gimp-quit
0)'

Unfortunately it throws the following error: batch command experienced an execution error: Error: eval: unbound variable: file-svg

What you found is just the command line being used to run a custom script someone wrote - I assume this was available from one of the now-defunct links in the message you linked to.

In short: what you have found and posted is not a complete script, not by far.

In principle, the actual script was likely similar to the examples in https://www.gimp.org/tutorials/Basic_Batch/ - with different parameters, though, as it only really needs to open a file and export it with a different file name.

--
Regards,
Michael
GPG: 96A8 B38A 728A 577D 724D 60E5 F855 53EC B36D 4CDD _______________________________________________ gimp-user-list mailing list
List address: gimp-user-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list List archives: https://mail.gnome.org/archives/gimp-user-list

Liam R E Quin
2020-04-21 22:26:21 UTC (about 4 years ago)

SVG to PNG using a script

On Tue, 2020-04-21 at 16:39 -0400, Tres Finocchiaro wrote:

Liam,

After re-reading your post, is it safe to assume my original question was written in scheme/script-fu?

Probably the script you were running, the one you didn't includeand got from Web archive, was in Scheme, yes.

It's a text file, and the likely error from the message is that it calls file-png to export, and not file-png-save.

If so, can someone direct me how to get a list of scheme commands that can
be executed from a vanilla gimp install?

Help->Procedure Browser

slave liam

Liam Quin - web slave for https://www.fromoldbooks.org/
with fabulous vintage art and fascinating texts to read.
Click here to have the slave beaten.
Tres Finocchiaro via gimp-user-list
2020-04-23 15:51:35 UTC (about 4 years ago)

SVG to PNG using a script

A one-liner using Gimp and no other tools:

./gimp -i -b '(let* ((image (car (file-svg-load RUN-NONINTERACTIVE *"input.svg"* "" *72* (- 0 *400*) (- 0 *600*) 0))) (drawable (car (gimp-image-get-active-layer image)))) (plug-in-autocrop RUN-NONINTERACTIVE image drawable) (gimp-file-save RUN-NONINTERACTIVE image drawable *"output.png"* *"output.png"*) (gimp-image-delete image))' -b '(gimp-quit 0)'

Where:

- "input.svg" is the source file name - 72 is the output resolution in pixels-per-inch - 400 is the output width
- 600 is the output height
- "output.png" is the output file name

-Tres

- Tres.Finocchiaro@gmail.com

On Tue, Apr 21, 2020 at 6:26 PM Liam R E Quin wrote:

On Tue, 2020-04-21 at 16:39 -0400, Tres Finocchiaro wrote:

Liam,

After re-reading your post, is it safe to assume my original question was written in scheme/script-fu?

Probably the script you were running, the one you didn't includeand got from Web archive, was in Scheme, yes.

It's a text file, and the likely error from the message is that it calls file-png to export, and not file-png-save.

If so, can someone direct me how to get a list of scheme commands that can
be executed from a vanilla gimp install?

Help->Procedure Browser

slave liam

-- Liam Quin - web slave for https://www.fromoldbooks.org/ with fabulous vintage art and fascinating texts to read. Click here to have the slave beaten.

Tres Finocchiaro via gimp-user-list
2020-04-23 17:39:23 UTC (about 4 years ago)

SVG to PNG using a script

Are there any known caveats to running these command on Windows?

I'm testing the above with CMD and no matter how I run it, it pops up a dialog asking me what resolution to import the file at, I can't get it to run non-interactively.

- I've tried escaping the asterisks - I've tried gimp-2.10.exe
- I've tried gimp-console-2.10.exe - I've tried swapping single quotes and double-quotes

It works on macOS Gimp 2.10.14 but does not work on Windows using Gimp 2.10.18.

When I try to run the first portion interactively, I receive the following errors:

- Opening *'C:\Users\owner\Desktop\((image'* failed: Error opening file C:\Users\owner\Desktop\((image: No such file or directory - Opening *'C:\Users\owner\Desktop\(car'* failed: Error opening file C:\Users\owner\Desktop\(car: No such file or directory - Opening *'C:\Users\owner\Desktop\(file-svg-load'* failed: Error opening file C:\Users\owner\Desktop\(file-svg-load: No such file or directory

I've tried using PowerShell and receive very similar results. What am I doing wrong?

-Tres

- Tres.Finocchiaro@gmail.com

On Thu, Apr 23, 2020 at 11:51 AM Tres Finocchiaro < tres.finocchiaro@gmail.com> wrote:

A one-liner using Gimp and no other tools:

./gimp -i -b '(let* ((image (car (file-svg-load RUN-NONINTERACTIVE *"input.svg"* "" *72* (- 0 *400*) (- 0 *600*) 0))) (drawable (car (gimp-image-get-active-layer image)))) (plug-in-autocrop RUN-NONINTERACTIVE image drawable) (gimp-file-save RUN-NONINTERACTIVE image drawable *"output.png"* *"output.png"*) (gimp-image-delete image))' -b '(gimp-quit 0)'

Where:

- "input.svg" is the source file name - 72 is the output resolution in pixels-per-inch - 400 is the output width
- 600 is the output height
- "output.png" is the output file name

-Tres

- Tres.Finocchiaro@gmail.com

On Tue, Apr 21, 2020 at 6:26 PM Liam R E Quin wrote:

On Tue, 2020-04-21 at 16:39 -0400, Tres Finocchiaro wrote:

Liam,

After re-reading your post, is it safe to assume my original question was written in scheme/script-fu?

Probably the script you were running, the one you didn't includeand got from Web archive, was in Scheme, yes.

It's a text file, and the likely error from the message is that it calls file-png to export, and not file-png-save.

If so, can someone direct me how to get a list of scheme commands that can
be executed from a vanilla gimp install?

Help->Procedure Browser

slave liam

-- Liam Quin - web slave for https://www.fromoldbooks.org/ with fabulous vintage art and fascinating texts to read. Click here to have the slave beaten.

Tres Finocchiaro via gimp-user-list
2020-04-23 17:51:03 UTC (about 4 years ago)

SVG to PNG using a script

Ok, I got it. Had to remove all single quotes and use backslash instead of uptick to escape the double-quotes.

Here's a working Windows example: https://gist.github.com/tresf/1bd76fc8cd4a4def215c68cab990dfb1

Thanks again for the help.

- Tres.Finocchiaro@gmail.com

On Thu, Apr 23, 2020 at 1:39 PM Tres Finocchiaro wrote:

Are there any known caveats to running these command on Windows?

I'm testing the above with CMD and no matter how I run it, it pops up a dialog asking me what resolution to import the file at, I can't get it to run non-interactively.

- I've tried escaping the asterisks - I've tried gimp-2.10.exe
- I've tried gimp-console-2.10.exe - I've tried swapping single quotes and double-quotes

It works on macOS Gimp 2.10.14 but does not work on Windows using Gimp 2.10.18.

When I try to run the first portion interactively, I receive the following errors:

- Opening *'C:\Users\owner\Desktop\((image'* failed: Error opening file C:\Users\owner\Desktop\((image: No such file or directory - Opening *'C:\Users\owner\Desktop\(car'* failed: Error opening file C:\Users\owner\Desktop\(car: No such file or directory - Opening *'C:\Users\owner\Desktop\(file-svg-load'* failed: Error opening file C:\Users\owner\Desktop\(file-svg-load: No such file or directory

I've tried using PowerShell and receive very similar results. What am I doing wrong?

-Tres

- Tres.Finocchiaro@gmail.com

On Thu, Apr 23, 2020 at 11:51 AM Tres Finocchiaro < tres.finocchiaro@gmail.com> wrote:

A one-liner using Gimp and no other tools:

./gimp -i -b '(let* ((image (car (file-svg-load RUN-NONINTERACTIVE *"input.svg"* "" *72* (- 0 *400*) (- 0 *600*) 0))) (drawable (car (gimp-image-get-active-layer image)))) (plug-in-autocrop RUN-NONINTERACTIVE image drawable) (gimp-file-save RUN-NONINTERACTIVE image drawable *"output.png"* *"output.png"*) (gimp-image-delete image))' -b '(gimp-quit 0)'

Where:

- "input.svg" is the source file name - 72 is the output resolution in pixels-per-inch - 400 is the output width
- 600 is the output height
- "output.png" is the output file name

-Tres

- Tres.Finocchiaro@gmail.com

On Tue, Apr 21, 2020 at 6:26 PM Liam R E Quin wrote:

On Tue, 2020-04-21 at 16:39 -0400, Tres Finocchiaro wrote:

Liam,

After re-reading your post, is it safe to assume my original question was written in scheme/script-fu?

Probably the script you were running, the one you didn't includeand got from Web archive, was in Scheme, yes.

It's a text file, and the likely error from the message is that it calls file-png to export, and not file-png-save.

If so, can someone direct me how to get a list of scheme commands that can
be executed from a vanilla gimp install?

Help->Procedure Browser

slave liam

-- Liam Quin - web slave for https://www.fromoldbooks.org/ with fabulous vintage art and fascinating texts to read. Click here to have the slave beaten.

Tres Finocchiaro via gimp-user-list
2020-04-23 18:00:35 UTC (about 4 years ago)

SVG to PNG using a script

Link to originating question: https://superuser.com/a/1545028/443147

- Tres.Finocchiaro@gmail.com

On Thu, Apr 23, 2020 at 1:51 PM Tres Finocchiaro wrote:

Ok, I got it. Had to remove all single quotes and use backslash instead of uptick to escape the double-quotes.

Here's a working Windows example: https://gist.github.com/tresf/1bd76fc8cd4a4def215c68cab990dfb1

Thanks again for the help.

- Tres.Finocchiaro@gmail.com

On Thu, Apr 23, 2020 at 1:39 PM Tres Finocchiaro < tres.finocchiaro@gmail.com> wrote:

Are there any known caveats to running these command on Windows?

I'm testing the above with CMD and no matter how I run it, it pops up a dialog asking me what resolution to import the file at, I can't get it to run non-interactively.

- I've tried escaping the asterisks - I've tried gimp-2.10.exe
- I've tried gimp-console-2.10.exe - I've tried swapping single quotes and double-quotes

It works on macOS Gimp 2.10.14 but does not work on Windows using Gimp 2.10.18.

When I try to run the first portion interactively, I receive the following errors:

- Opening *'C:\Users\owner\Desktop\((image'* failed: Error opening file C:\Users\owner\Desktop\((image: No such file or directory - Opening *'C:\Users\owner\Desktop\(car'* failed: Error opening file C:\Users\owner\Desktop\(car: No such file or directory - Opening *'C:\Users\owner\Desktop\(file-svg-load'* failed: Error opening file C:\Users\owner\Desktop\(file-svg-load: No such file or directory

I've tried using PowerShell and receive very similar results. What am I doing wrong?

-Tres

- Tres.Finocchiaro@gmail.com

On Thu, Apr 23, 2020 at 11:51 AM Tres Finocchiaro < tres.finocchiaro@gmail.com> wrote:

A one-liner using Gimp and no other tools:

./gimp -i -b '(let* ((image (car (file-svg-load RUN-NONINTERACTIVE *"input.svg"* "" *72* (- 0 *400*) (- 0 *600*) 0))) (drawable (car (gimp-image-get-active-layer image)))) (plug-in-autocrop RUN-NONINTERACTIVE image drawable) (gimp-file-save RUN-NONINTERACTIVE image drawable *"output.png"* *"output.png"*) (gimp-image-delete image))' -b '(gimp-quit 0)'

Where:

- "input.svg" is the source file name - 72 is the output resolution in pixels-per-inch - 400 is the output width
- 600 is the output height
- "output.png" is the output file name

-Tres

- Tres.Finocchiaro@gmail.com

On Tue, Apr 21, 2020 at 6:26 PM Liam R E Quin wrote:

On Tue, 2020-04-21 at 16:39 -0400, Tres Finocchiaro wrote:

Liam,

After re-reading your post, is it safe to assume my original question was written in scheme/script-fu?

Probably the script you were running, the one you didn't includeand got from Web archive, was in Scheme, yes.

It's a text file, and the likely error from the message is that it calls file-png to export, and not file-png-save.

If so, can someone direct me how to get a list of scheme commands that can
be executed from a vanilla gimp install?

Help->Procedure Browser

slave liam

-- Liam Quin - web slave for https://www.fromoldbooks.org/ with fabulous vintage art and fascinating texts to read. Click here to have the slave beaten.