Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
08-01-2025, 08:08 PM
|
#1
|
|
Senior Member
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 22.04
Posts: 2,209
Rep:
|
How to use Inkscape headless from the command line?
I am trying to use Python pymupdf to generate a pdf. I also want to use some emojis.
I have the font NotoColorEmoji.ttf
But the emojis all come out mono-coloured!
So I found a Python script here to convert emojis to .svg, using Python subprocess and inkscape. Thereafter convert .svg to .png and stick them in my pdf, there are not many I want!
In bash
shows: When I try to use this path to inkscape, I get this error:
Quote:
|
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/inkscape
|
Full error:
Quote:
/usr/bin/inkscape --export-overwrite --actions="select-by-id:text-box; object-to-path; export-id:text-box; export-id:text-box; export-do; FileClose" "/home/peterr/PVE/emoji2svg2png/svg/Animals & Nature - 9728 (black sun with rays).svg"
Traceback (most recent call last):
File "/usr/lib/python3.12/idlelib/run.py", line 580, in runcode
exec(code, self.locals)
File "<pyshell#71>", line 1, in <module>
File "<pyshell#61>", line 14, in generate_symbols
File "<pyshell#27>", line 19, in write_new_letter
File "<pyshell#29>", line 6, in convert_to_path
File "/usr/lib/python3.12/subprocess.py", line 389, in call
with Popen(*popenargs, **kwargs) as p:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/inkscape --export-overwrite --actions="select-by-id:text-box; object-to-path; export-id:text-box; export-id:text-box; export-do; FileClose" "/home/peterr/PVE/emoji2svg2png/svg/Animals & Nature - 9728 (black sun with rays).svg"'
|
The owner of /usr/bin/inkscape is root. Is that the problem??
I also tried using just
Quote:
|
inkscape_path = 'inkscape'
|
, because I can launch inkscape with that command in bash, but that does not work either!
Very grateful for any tips you may have.
|
|
|
|
08-01-2025, 08:54 PM
|
#2
|
|
LQ Guru
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 20,519
|
|
|
|
|
08-01-2025, 11:51 PM
|
#3
|
|
Senior Member
Registered: Jul 2020
Posts: 1,880
|
bash not finding existing programs may be caused by borked path cache. Check by running 'type inkscape', clear by running 'hash -r' or 'hash -d inkscape'.
|
|
|
|
08-02-2025, 12:26 AM
|
#4
|
|
Senior Member
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 22.04
Posts: 2,209
Original Poster
Rep:
|
Thanks!
Not familiar with the word "borked". Isuppose it's not good!
I tried some command line inkscape stuff, which worked:
cd to: /PVE/emoji2svg2png
Quote:
# worked but empty file
inkscape --export-type="png" symbol-template.svg
# works
inkscape --export-type="png" greenArrow1.svg #works
# read svg export as pdf
cat greenArrow1.svg | inkscape --pipe --export-filename=greenArrow1.pdf
|
So I know inkscape can work from the command line!
returns:
Quote:
|
inkscape is hashed (/usr/bin/inkscape)
|
running
didn't seem to change anything:
Quote:
type inkscape
inkscape is hashed (/usr/bin/inkscape)
|
but after
I see:
Quote:
type inkscape
inkscape is /usr/bin/inkscape
|
BUT: I get the same error as above when I try to run Python to convert an emoji to svg:
Quote:
|
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/inkscape etc.
|
Last edited by Pedroski; 08-02-2025 at 12:29 AM.
|
|
|
|
08-02-2025, 08:58 AM
|
#5
|
|
Member
Registered: Jun 2025
Distribution: Slackware64 Current
Posts: 227
Rep:
|
I think inkscape is mostly a GUI frontend to some vector/svg libraries or lower level binaries or, that there are lower level binaries that can invoke the same svg/vector libs inkscape uses.
Cause I've seen a few slackware SBO build scripts where svg icons were generated programatically, and it wasn't by inkscape.
What I'm getting at is:
There's probably a command line tool available that isn't inkscape but does what inkscape does but 'isolated' as a tiny headless renderer.
Wish I could remember/tell you that tool though.
Hmm, I just grepped the SBO git repo for 'svg' and a tool named 'nanosvg' cropped up, and play old imagemagicks 'convert'.
Which was used to, well, convert some svgs into pngs.
Code:
audio/lingot/lingot.SlackBuild:svgicon="$( /bin/ls icons/*.svg | head -1 )"
audio/lingot/lingot.SlackBuild:iconname="$( basename $svgicon .svg )"
audio/lingot/lingot.SlackBuild: convert -resize $size $svgicon $dir/$iconname.png
so yeah, perhaps good old imagemagick will do the trick, highly probable since again, inkscape is FOSS and FOSS tends to do a lot of library sharing.
Why not give it a try?
|
|
|
|
08-02-2025, 10:16 AM
|
#6
|
|
Senior Member
Registered: Jul 2003
Location: NY
Distribution: Slackware, Termux, illumos, Minix3
Posts: 1,524
|
There might be something wrong with your Inkscape. Make sure it runs first. If you use ImageMagick, it will use Inkscape on the backend.
Code:
magick penguin-motif.svg penguin-motif.png
Setting _INKSCAPE_GC=disable as a workaround for broken libgc
You should not use AppImage in production, but you can speed up the AppImage by following this guide: https://inkscape.org/learn/appimage/
** (org.inkscape.Inkscape:29019): WARNING **: 11:06:01.221: Mismatch between cc:license and cc:License metadata:
cc:license value URI: http://artlibre.org/licence/lal (using this one!)
cc:License derived URI: http://creativecommons.org/licenses/by-sa/4.0/
(org.inkscape.Inkscape:29019): Gtk-WARNING **: 11:06:01.403: Creating a portal monitor failed: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.Inhibit” on object at path /org/freedesktop/portal/desktop
Ignore the cruft. Old IM used 'convert file.svg file.png'. /usr/bin/inkscape should be mode 0755 and root:root (or root:bin or whatever your system uses).
|
|
|
|
08-02-2025, 11:15 AM
|
#7
|
|
Senior Member
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 4,317
|
Quote:
Originally Posted by jayjwa
If you use ImageMagick, it will use Inkscape on the backend.
|
I've used SVG files with ImageMagick without Inkscape installed, so I had to check that.
Quote:
|
Originally Posted by https://imagemagick.org/script/formats.php
By default, ImageMagick renders SVGs with inkscape if it is in your execution path; otherwise RSVG. If neither is available, ImageMagick reverts to its internal SVG renderer (called MSVG).
...
If you want to render an SVG using MSVG, add msvg: just before the file name.
|
So whilst I agree fixing whatever is up with Inkscape is the right solution, prefixing the filename with "msvg:" might be a valid workaround.
Also, this appears to be one of the areas GraphicsMagick does differently:
Quote:
|
Originally Posted by http://www.graphicsmagick.org/formats.html
Requires libxml2 and freetype2. Note that SVG is a very complex specification so support is still not complete.
|
|
|
|
|
08-02-2025, 01:59 PM
|
#8
|
|
Member
Registered: Jun 2013
Location: Ferndale, MI USA
Distribution: Debian, NetBSD
Posts: 39
Rep: 
|
This doesn't answer your question, but might be what you need. The Noto Color Emoji fonts are open source and you can get the source from https://github.com/googlefonts/noto-emoji It appears they already have .png and .svg images of the characters that you can download.
|
|
|
|
08-02-2025, 06:51 PM
|
#9
|
|
Senior Member
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 22.04
Posts: 2,209
Original Poster
Rep:
|
Thanks everyone!
My installation of Inkscape works fine, nothing wrong there, as far as I can see.
Above I posted some inkscape command lines I tried, just to see if I could do anything from the command line. That worked!
As I understand it, fonts start life as .svg, then become fonts. So really, this is just reverse engineering. Just not working as is!
My problem is getting the individual emojis to .svg. Converting svg to png is fairly simple, I can manage that, I think!
There is another solution here using emojipy. I haven't tried it yet, but it looks promising.
@Steve48220 Great idea, the only caveat is: the repo has been limited to 1000 files from 2500+
I would still like to make the inkscape command work. I will keep fiddling with it.
The way the programme works is basically:
1. load a simple template (letter A on transparent background)
2. get the svg info as text
3. change the font name from Arial to NotoColorEmoji
4. replace the letter A with the emoji
5. then export this as .svg
I've tried this step by step in Idle. It's only 5. that doesn't work.
Oh, I just thought, maybe Idle is the problem! Sometimes, things just won't work in Idle, for reasons I can't explain.
I will make the whole thing executable and try that!
|
|
|
|
08-02-2025, 07:02 PM
|
#10
|
|
Senior Member
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 22.04
Posts: 2,209
Original Poster
Rep:
|
Well, running the script directly in bash did not help!
Still get the same error!
Quote:
File "/usr/lib/python3.12/subprocess.py", line 389, in call
with Popen(*popenargs, **kwargs) as p:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/inkscape --export-overwrite --actions="select-by-id:text-box; object-to-path; export-id:text-box; export-id:text-box; export-do; FileClose "/home/peterr/PVE/emoji2svg2png/svg/Animals & Nature - 9728 (black sun with rays).svg"'
|
The ouput file is created, it's just empty!
Last edited by Pedroski; 08-02-2025 at 07:04 PM.
|
|
|
|
08-02-2025, 08:07 PM
|
#11
|
|
LQ Guru
Registered: Oct 2004
Distribution: Arch
Posts: 5,818
|
Quote:
|
"/home/peterr/PVE/emoji2svg2png/svg/Animals & Nature - 9728 (black sun with rays).svg"'
|
Get the spaces and non allowed chars out of the file name.
|
|
|
|
08-03-2025, 03:25 AM
|
#12
|
|
Senior Member
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 22.04
Posts: 2,209
Original Poster
Rep:
|
Good idea, but still no joy!
This is the file name now:
Quote:
|
_animal_9728_summinck.svg
|
and the file path:
Quote:
|
/home/peterr/PVE/emoji2svg2png/svg/_animal_9728_summinck.svg
|
But still stuck with the same error:
Quote:
peterr@peterr-Modern-15-B7M:~/PVE/emoji2svg2png$ python3 export-all-emojiV2.py
Exporting all emoji...
/usr/bin/inkscape --export-overwrite --actions="select-by-id:text-box; object-to-path; export-id:text-box; export-id:text-box; export-do; FileClose;" /home/peterr/PVE/emoji2svg2png/svg/_animal_9728_summinck.svg
Traceback (most recent call last):
File "/home/peterr/PVE/emoji2svg2png/export-all-emojiV2.py", line 110, in <module>
generate_symbols()
File "/home/peterr/PVE/emoji2svg2png/export-all-emojiV2.py", line 87, in generate_symbols
write_new_letter(glyph, hex_code, decimal, name, category)
File "/home/peterr/PVE/emoji2svg2png/export-all-emojiV2.py", line 53, in write_new_letter
convert_to_path(file_name)
File "/home/peterr/PVE/emoji2svg2png/export-all-emojiV2.py", line 68, in convert_to_path
subprocess.call(command)
File "/usr/lib/python3.12/subprocess.py", line 389, in call
with Popen(*popenargs, **kwargs) as p:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/inkscape --export-overwrite --actions="select-by-id:text-box; object-to-path; export-id:text-box; export-id:text-box; export-do; FileClose;" /home/peterr/PVE/emoji2svg2png/svg/_animal_9728_summinck.svg'
peterr@peterr-Modern-15-B7M:~/PVE/emoji2svg2png$
|
The output file is created, but it is empty!
|
|
|
|
08-03-2025, 05:01 AM
|
#13
|
|
Senior Member
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 22.04
Posts: 2,209
Original Poster
Rep:
|
Thanks for all your replies and advice!
In Python this helped:
Code:
subprocess.call(command, shell=True)
BUT: the outputs are all BLACK on transparent background! The point was to get the coloured emoji as a COLOURED .svg
This github repo does not seem to do what it set out to do!
Have to try another approach!
|
|
|
|
08-03-2025, 10:19 AM
|
#14
|
|
Member
Registered: Jun 2013
Location: Ferndale, MI USA
Distribution: Debian, NetBSD
Posts: 39
Rep: 
|
Quote:
Originally Posted by Pedroski
@Steve48220 Great idea, the only caveat is: the repo has been limited to 1000 files from 2500+
|
The 1000 file limit is for the web interface only. If you use git to clone the repo, you should get everything - which might be a lot more than what you want.
|
|
|
|
08-04-2025, 04:46 AM
|
#15
|
|
Senior Member
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 22.04
Posts: 2,209
Original Poster
Rep:
|
@Steve48220 Thanks again, I will bear that in mind. Never tried to use git to clone anything: might end up with Frankenstein!
I still can't make this work, but I will keep trying!
|
|
|
|
All times are GMT -5. The time now is 06:10 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|