Converting svg to png with inkscape command line failing - svg

I feel like I must be doing something silly wrong, but I just can't get this to work. This is the command I am running from cmd:
inkscape.com "C:\path\ship.svg" -e --export-png="C:\Path\ship.png" --without-gui
In return, I get:
WARNING: File path "--export-png=C:\path\ship.png" includes directory that doesn't exist.
It does exist. What am I missing?

You should have used either -e or --export-png, not both, since they mean the same thing.
But According to the docs, -e and --export-png are no longer available. You should use -o or --export-filename=FILENAME instead. And still, you can use only one of them since -o is just the shortcut for --export-filename.
inkscape "C:\path\ship.svg" -o "C:\path\ship.png"
or
inkscape "C:\path\ship.svg" --export-filename="C:\path\ship.png"

Just an update for 2021 (it should be typed in oneline - broken down for readability only)
inkscape
--export-width=128
--export-type=png
--export-filename="C:\path\ship.png" "C:\path\build.svg"
or if you want transparent PNGs, add --export-background-opacity=0 to invocation arguments:
inkscape
--export-background-opacity=0
--export-width=128
--export-type=png
--export-filename="C:\path\ship.png" "C:\path\build.svg"

In inkscape version 1.0.2 following command will work:
inkscape --export-type="png" myfile.svg --export-filename=myfile.png

Related

pstoedit gives different result while converting eps to dxf using "dxf" and "dxf_14"

I am using pstoedit as a part of a shell script to convert svg to dxf.
When I use pstoedit -psarg '-dNOSAFER' -dt -f 'dxf: -mm' "${epsfile}" "${dxffile}" in script, the result is like the picture below.
But when i use pstoedit -psarg '-dNOSAFER' -dt -f 'dxf_14: -mm' "${epsfile}" "${dxffile}" the result is like the picture below.
See the difference? dxf gives complete lines, but dxf_14 gives small lines not connected. I read pstohedit -help and it mentions to use dxf_14 because it's newer, but I can't if it's going to produce results like this.
I also see a bunch of options specific to dxf_14, but I'm not sure what to use. Can anyone guide me on what switches to use for dxf_14 to get desired result, like the first picture above?
PS. I'm using Inkscape to create svg and then the script converts svg to eps using inkscape cli and the pstoedit is used to convert eps to dxf, if it helps.
PS2. pstoedit version is pstoedit: version 3.74 / DLL interface 108 (built: Oct 31 2019 - release build - g++ 9.2.0 - 64-bit)

imagemagick RAW file identify/convert - no such file or directory (tmp file)

I'm trying to use imagemagick-7 (CLI) on ubuntu to identify and convert RAW images to PNG format. I am using the dcraw binary as the delegate for identifying and converting raw images.
I updated the dng:decode delegate in delegates.xml as follows:
<delegate decode="dng:decode" command=""dcraw" "%i"" />
When I run this command: magick identify test.dng, I get the following error:
identify: unable to open image '/tmp/magick-24332a6nW8lcwejNJ.ppm': No such file or directory # error/blob.c/OpenBlob/3489.
The same error is given for magick convert. I noticed that imagemagick is generating a temporary intermediate file in my /tmp directory, which has a different name than the name it's expecting to find there. For example, it generates this file - magick-24332P6aVDePOFeCn.ppm - but is expecting the file it generated to have this name - magick-24332a6nW8lcwejNJ.ppm - which is why it's not finding it.
Note: I tested the same thing on OS X and it works perfectly fine (with the same delegates.xml configuration).
Is this a bug in imagemagick's implementation for unix systems or am I doing something wrong? Any thoughts would be greatly appreciated!
You were close the right command to use in delegate is
<delegate decode="dng:decode" command=""dcraw" -c "%i" > "%u.ppm"" />
Almost! You need to use the %o placeholder to tell the delegate manager were the output file will be written to. However the dcraw utility doesn't have in output destination options -- at least from what I can tell form the man-page. It does have a stdout option (-c), so you should be able to pipe/redirect the stream to an output location.
dcraw -c %i > %o
or in delegate XML.
<delegate decode="dng:decode" command=""dcraw" -c "%i" > "%o"" />
Update
Some tricks I've observed with custom delegations.
Use full path to binaries. Usually because I installed something outside of the systems PATH. Usually /usr/local/bin or /opt directories.
command="/usr/local/bin/dcraw ...
Use mv over pipes. If your not comfortable with debugging unix streams & such. Just do some basic copy/move command. We can rewrite the above command with something like...
dcraw %i; mv %i.ppm %o
Ignore escaping quotes until you know its working. Encapsulating arguments are important, and keep everything safe, but \"%i & "%i are hard to read.
<delegate decode="dng:decode" command="dcraw %i; mv %i.ppm %o" />
... verify things are called correctly ... then probably escape paths.
<delegate decode="dng:decode" command="dcraw "%i"; mv "%i".ppm "%o"" />
As pointed out previously, use identify -list Delegate to verify that the command is loaded correctly, and -verbose to verify that it was called correctly during runtime.
For anyone else who experiences this problem, my solution ended up being to switch from imagemagick to graphicsmagick, which is by default configured to use dcraw (of course, you need to have dcraw installed and on your PATH).
http://www.graphicsmagick.org/

Fontforge: Export a glyph to SVG with fontforge command line

How to export a glyph (from its unicode) to SVG with Fontforge command line ?
I also need to specify the font size and keep the original margins it has in the font.
You may have found your answer already, but I just had to do this with the latest build of FontForge. The old answer of this command:
fontforge -lang=ff -c 'Open($1); SelectWorthOutputting(); foreach Export("svg"); endloop;' font.ttf
From a command prompt didn't want to work on Windows10 (I assume a permission issue), but you could give it a try. A quick work-around is to do it via the GUI Execute Script.
Run FontForge (For Windows10 installed in the Program Files (x86) directory, you may need to right-click "run_fontforge.exe" --> Run As Administrator).
Open the font you want to export.
Go to File > Execute Script
Paste: SelectWorthOutputting(); foreach Export("svg"); endloop;
Select "FF" radial button.
Hit OK
It'll save to the FontForge folder (where run_fontforge.exe is located).
On Windows os (Tested on win10)
this is from inside a BATCH file:
c:\Programs\FontForge\bin\fontforge.exe -lang=ff -c "Open($1); SelectWorthOutputting(); foreach Export('%%e_%%f_%%n_%%u.eps'); endloop;" %1
this is directly on the command line:
c:\Programs\FontForge\bin\fontforge.exe -lang=ff -c "Open($1); SelectWorthOutputting(); foreach Export('%e_%f_%n_%u.eps'); endloop;" font-file.ttf
note - the color is not exported. And I don't know if it's unimplemented, or a bug.

Programmatically convert SVG shapes to paths (lineto, moveto)

I have an SVG file coming from Inkscape, Illustrator, or any other application. I want to convert the shapes to lineto, moveto, curveto format.
What I want is something like:
./Appname svgfile outfilewithpath
I will give the SVG file as an argument, then my application will convert the object into the respective paths.
Inkscape has a command-line interface. Use the Inkscape man page along with the verb source for reference:
The ObjectToPath verb converts an object to a path:
inkscape filename.svg --select=myobject --verb=ObjectToPath --export-plain-svg=filename_to_path.svg
The export-text-to-path argument converts text nodes to paths:
inkscape filename.svg --export-eps=filename.eps --export-text-to-path
These are related questions on how to run InkScape from Perl, Ruby, PHP or Python:
Using the Inkscape shell from perl
Run inkscape in PHP
Calling Inkscape in Python
Inkscape Merge Ruby Gem
This is what finally worked for me:
inkscape -f filename.svg --verb EditSelectAll --verb SelectionUnGroup --verb EditSelectAll --verb ObjectToPath --verb FileSave --verb FileQuit
It takes about 9 seconds to run and briefly opens the inkscape gui, which becomes the active application, so it's not ideal, but it's the only answer I could find that actually works.

help - change diff symbol "<", "|" or ">" to a desired one?

diff -w command is used to create a side by side comparison diff file (instead of parallel)
i then view them using vi via ssh terminal
the changes are indicated by either "<" or "|" or ">"
Since the file i am viewing is a source code, navigating to changes alone
using above symbols is difficult since they are also in C source code.
How can i change these default symbols to desired ones ?
Kindly help. Thanks.
Instead of viewing the output of diff -w in vim, you can use vim's built-in diff:
vim -d file1 file2
This opens vim in a vertical split with both files open, and diff markings in the code. This is what it looks like:
And it works in a terminal too:
You can find a short tutorial here
According to my version of diff (2.8.1 from the GNU diffutils by the FSF) -w is used to change the width of the output; The -y parameter outputs side by side comparison. In combination, the two show no further effect than the -y parameter used alone, which means you may have an alias in your terminal profile or in the global terminal profile that aliases diff to diff -y.
I say all this because all options to change the symbols ("<", "|", and ">") conflict with the -y option. If you can live without side-by-side, you have the option of two other included output styles or defining your own. The two output styles are -c (context) and -u (unified). (For more information on what they do see the diff Wikipedia page. For more information on the options see the diff man page.)
A more in depth fix would be to use the following options:
diff --old-group-format="(deleted)---" \
--new-group-format="(added)---" \
--changed-group-format="(updated)---" \
--unchanged-group-format="(nodiff)---" \
old_file.c new_file.c
Now the old file's lines that are not present in the new file are represented by (deleted)---
The new file's lines that are not present in the old file are represented by (added)---
Lines that have been changed are represented by (updated)---
Lines common to both files are represented by (nodiff)---
Since you seem to do this often enough, you have the option of making it an alias in your terminal profile or writing a small shell script to handle it. For more options, see the manual's section on options and specifically see the section on line group formats for information on what you can put between the quotes in the format definitions.
Of course, if you must have side-by-side, try Nathan Fellman's idea above. Otherwise, there's the option of using a dedicated GUI tool for it such as Kompare.

Resources