Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6658967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:58:33+00:00 2026-05-26T01:58:33+00:00

Inkscape has a shell mode invoked like this inkscape –shell where you can execute

  • 0

Inkscape has a shell mode invoked like this

inkscape --shell

where you can execute commands like this:

some_svg_file.svg -e some_png_output.png -y 1.0 -b #ffffff -D -d 150 

which will generate a PNG file, or like this:

/home/simone/some_text.svg -S

which gives you the bounding box of all elements in the file in the return message like this

 svg2,0.72,-12.834,122.67281,12.942
 layer1,0.72,-12.834,122.67281,12.942
 text2985,0.72,-12.834,122.67281,12.942
 tspan2987,0.72,-12.834,122.67281,12.942

The benefit of this is that you can perform operations on SVG files without having to restart Inkscape every time.

I would like to do something like this:

sub do_inkscape {
     my ($file, $commands) = @_;
     # capture output
     return $output
}

Things work OK if I use open2 and forking like this:

use IPC::Open2;

$pid = open2(\*CHLD_OUT, \*CHLD_IN, 'inkscape --shell');
$\ = "\n"; $/ = ">";

my $out; open my $fh, '>', \$out;

if (!defined($kidpid = fork())) {
    die "cannot fork: $!";
} elsif ($kidpid == 0) {
    while (<>) { print CHLD_IN $_; }
} else { 
    while (<CHLD_OUT>) { chop; s/\s*$//gmi; print "\"$_\"";  }
    waitpid($kidpid, 0); 
}

but I can’t find out how to input only one line, and capture only that output without having to restart Inkscape every time.

Thanks

Simone

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:58:33+00:00Added an answer on May 26, 2026 at 1:58 am

    You don’t need to fork, open2 handles that by itself. What you need to do is find a way of detecting when inkscape is waiting for input.

    Here’s a very basic example of how you could achieve that:

    #! /usr/bin/perl
    use strict;
    use warnings;
    
    use IPC::Open2;
    
    sub read_until_prompt($) {
        my ($fh) = (@_);
        my $done = 0;
        while (!$done) {
            my $in;
            read($fh, $in, 1);
            if ($in eq '>') {
                $done = 1;
            } else {
                print $in;
            }
        }
    }
    
    my ($is_in, $is_out);
    my $pid = open2($is_out, $is_in, 'inkscape --shell');
    
    read_until_prompt($is_out);
    print "ready\n";
    
    print $is_in "test.svg -S\n";
    read_until_prompt($is_out);
    
    print $is_in "quit\n";
    waitpid $pid, 0;
    
    print "done!\n";
    

    The read_until_prompt reads from inkscapes output until it finds a > character, and assumes that when it sees one, inkscape is ready.

    Note: This is too simple, you will probably need more logic in there to make it work more reliably if a > can appear outside the prompt in the output you’re expecting. There is also no error checking at all in the above script, which is bad.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to run inkscape in PHP so I can convert an svg image
I frequently execute from a shell (in my case Bash) commands that I want
i am embedding a javascript file inside an svg file like this: <svg xmlns:dc=http://purl.org/dc/elements/1.1/
I have drawn an icon in Inkscape , but would now like to programmatically
I'd like to write an Ant script that calls an external utility (Inkscape, in
I've put some text inside a rectangle using inkscape so the tree is like
I'm in need for a good SVG editor which can produce valid xml according
InkScape users, can you recommend Inkscape for website-template development. I have to learn a
There is a bug in Inkscape where JPEG images included in an SVG document
I have a SVG path, created in Inkscape, that is a single Move (M

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.