Batch converting SVG to PNG in Inkscape doesn't work - windows

I want to convert multiple SVG files in the folder C:\Users\Eric\Desktop\svg to 512x512 PNG files with the name [SVG File Name].svg.png.
I tried the following command:
for /f %f in ('dir /b "C:\Users\Eric\Desktop\svg"') do inkscape -z -e %f.png -w 512 -h 512 %f
The command line detects the SVG files correctly and goes through them but Inkscape says the following:
C:\Users\Eric\Desktop\inkscape>inkscape -z -e [SVG File Name].svg.png -w 512 -h 512 [SVG File Name].svg
** (inkscape.exe:8412): WARNING **: Can't open file: [SVG File Name].svg (doesn't exist)
** (inkscape.exe:8412): WARNING **: Can't open file: [SVG File Name].svg (doesn't exist)
** (inkscape.exe:8412): WARNING **: Specified document [SVG File Name].svg cannot be opened (does not exist or not a valid SVG file)
I opened one file in the normal Inkscape program, and it worked.

For SVG to PNG conversion I found cairosvg (https://cairosvg.org/) performs better than ImageMagick. Steps for install and running on all files in your directory.
pip3 install cairosvg
Open a python shell in the directory which contains your .svg files and run:
import os
import cairosvg
for file in os.listdir('.'):
if os.path.isfile(file) and file.endswith(".svg"):
name = file.split('.svg')[0]
cairosvg.svg2png(url=name+'.svg',write_to=name+'.png')
This will also ensure you don't overwrite your original .svg files, but will keep the same name. You can then move all your .png files to another directory with:
$ mv *.png [new directory]

Inkscape is a good program.
Sometimes we don't understand the possibilities it has.
For better performance, you should use shell mode.
This mode consists of 2 steps:
Create a file, with the commands to execute.
Run this file using type .\command.txt | inkscape --shell where command.txt your file name, in windows console or bash.
All commands located in action-list, after typing inkscape --shell.
For example, if you want to convert SVG to png, your txt file should contains:
file-open:1.svg; export-filename:1.png; export-do; file-close
file-open:2.svg; export-filename:2.png; export-do; file-close
Syntax is command:arg; command2:arg2; etc
You can create this file using your favorite language like C++, Java, C# or Python.
P.S.
It's faster than using inkscape command with every file in PowerShell, but don't use it for long time operations because it has a memory leak:
Link to Gitlab

Related

Imagemagick error using overlapcrop on Window with Cygwin

I am using Imageimagick to crop arieal images in equal sizes.
Searching Google imagemagick tutorials led me to Fred Weinhaus scripts tutorial which I followed. When I am passing the command on bash or cmd based on syntax given in this website (bash /fullpathto/scriptname.sh with arguments /fullpathto/inputimage /fullpathto/outputimage)
I am getting error
$ overlapcrop -s 128 -o 50% -m matrix -M -L \
-R 'F:\bash\top_potsdam_2_10_RGB' 'F:\bash\o.jpg'
error Invalid Parameter - F:\bash\top_potsdam_2_10_RGB
FILE F:\bash\top_potsdam_2_10_RGB DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE
Even if we set the directory in the path, we get the same error:
$ overlapcrop -s 128 -o 50% -m matrix -M -L -R top_potsdam_2_10_RGB.png o.png
--Screenshots of imagemagick --help and convert --help
error I am getting
Windows is useless when it comes to quoting, so maybe try escaping the % sign by adding a second one or a caret (^) in front of it.
Also, try removing the F: from the paths and try putting the files in the current directory in case the slashes are causing errors.
Finally, you may have your PATH set incorrectly so that when the script executes the convert command it finds the Windows utility that converts filesystems to NTFS rather than the ImageMagick utility that converts images.
Try running:
convert /?
and seeing if you get an error/help message from Windows CONVERT.EXE or something from ImageMagick. If you get the Windows one, your PATH is incorrect and you need to put the directory where you installed ImageMagick ahead (in front of) C:\WINDOWS\System32 or wherever Windows CONVERT.EXE lives and restart your Command Prompt window.

Is it possible to get a files owner url metadata in the macOS terminal?

I can access the meta data property "owner url" thru Photoshop, but am hoping that there's a way to access it from the command line without having to open the file.
Does anyone know of a way to do this?
mdls doesn't list this particular metadata field.
There is no built-in command line tool to achieve this.
However, you can utilize exiftool, which is a platform-independent Perl library plus a command-line application for reading, writing and editing meta information in a wide variety of files.
Installation:
The guidelines for installing it on macOS can be found here. In summary:
Download the ExifTool OS X Package from the ExifTool home page.
(The file you download should be named ExifTool-11.17.dmg.)
Install as a normal OS X package.
(Open the disk image, double-click on the install package, and
follow the instructions.)
You can now run exiftool by typing exiftool in a Terminal window.
Processing a single file:
Reading the "owner url" via the command line:
Run the following command in a Terminal window:
$ exiftool -b −xmp:WebStatement ~/Desktop/path/to/image.psd
Note: the ~/Desktop/path/to/image.psd part in the command above should be replaced with a real image filepath.
This command will log the URL to the console only if the image metadata contains one. For instance:
https://www.example.com
Writing the "owner url" via the command line:
You can also write the "owner url" to a file by running the following command:
$ exiftool −xmp:WebStatement="https://www.foobar.com" ~/Desktop/path/to/image.psd
Note: As mentioned previously, the ~/Desktop/path/to/image.psd part in the command above should be replaced with a real image filepath, and the https://www.foobar.com part should be replaced with the actual URL you want to apply.
Processing multiple files:
Reading the "owner url" for multiple files via the command line:
If you wanted to read the "owner url" for all image files within a given folder, (including those in sub folders), and generate a JSON report you can run the following command:
$ exiftool -j -r −xmp:WebStatement ~/Desktop/path/to/folder/ -ext jpg -ext png -ext psd -ext tif > ~/Desktop/owner-urls.json
Breakdown of command (above):
-j - Use JSON formatting for output.
-r - Recursively process sub directories.
−xmp:WebStatement - Retrieve the WebStatement value, i.e. "owner url".
~/Desktop/path/to/folder/ - The path to the folder containing images (This should be replaced with a real path to a folder).
-ext jpg -ext png -ext psd -ext tif - The file extension(s) to process.
> ~/Desktop/owner-urls.json - Save the JSON output to file at the Desktop named owners-url.json.

How can I open a file without an extension or known file type?

I was given a 700Mb CD from my boss from 2002. The files are either videos or pictures, she can't remember. I loaded the CD onto my mac to find that the files do not have extensions. I have tried adding several different extensions to the files (.mp4, .flv, .jpg, .png, .bmp, etc.) but my mac still cannot open them. I've tried loading them into VLC, and while VLC can recognize that the files have different durations (meaning they are probably videos), it still cannot play the videos. When I open the files in TextEdit, the first line looks like this:
ˇˇimprDè¸PICTéÆdOˇ÷Original Image6<˜ÊµéÆpˇˇˇˇˇp
I've also tried the GetFileInfo command in Terminal on one of the files, and get the following output:
file: "/Users/Me/Desktop/CD 1/myfile"
type: "\0\0\0\0"
creator: "\0\0\0\0"
attributes: avbstclinmedz
created: 06/07/2017 21:42:04
modified: 06/07/2017 21:42:04
Any other suggestions? I'd really like to find out what on this disc! Thanks.
Judging from the few bytes of header, one might suspect it's a PICT format. Please see PICT format. It's an old Mac format and since you mentioned you're using a Mac, perhaps that's what was used in your workplace 15 years ago, as well? See also PICT format.
imagine the file name is myfile with no extension like myfile.txt so click on the magnifier icon
and type Terminal. In the terminal change your directory to where your file is located using the cd command. I have created a file using the touch command in the Terminal (with no content), added a line into it and then showed its stuff on the terminal using cat command (or if the content is more than one page suggest to use less command). Or if you want to edit it you could use vim command for example.
Monas-MacBook-Pro:test mona$ touch myfile
Monas-MacBook-Pro:test mona$ echo "hello" >> myfile
Monas-MacBook-Pro:test mona$ cat myfile
hello
Monas-MacBook-Pro:test mona$ less myfile
Monas-MacBook-Pro:test mona$
Monas-MacBook-Pro:test mona$ vi myfile
Another option is installing Notepad++ and rightclicking on the file and choosing to open it with Notepad++.
If your file is an executable, you will see weird contents either by vim or Notepad++.
You can download Notepad++ from https://notepad-plus-plus.org/
I decided to try FileJuicer to open these enigmatic files, and it worked! I turns out that each file contained a series of pictures.

Compress command results in corrupted zip file

I have a script set up to rotate some log files in windows, and as part of the process I'd like it to automatically compress the rotated file. To do this I use the command
compress source.file destination.file.zip
However, if I try to open the file, I get the message "The Compressed (zipped) Folder is invalid or corrupted"
I've tried compress with -Z, and I get the same message. What am I doing wrong?
compress output is not ZIP file format compatible, it uses the LZW algorithm.
The only way to "open" a compressed file is with uncompress or gunzip.
Windows ports of common Unix commands, including compress and gzip/gunzip available here.
EDIT: To produce ZIP files from the command line in Windows, you can use something like 7-Zip, which includes a command line application (7z.exe). The Unix commands linked above also include zip.exe for manipulating ZIP files from the command line.

Specifying the destination for the pdf output when using pdflatex, from gVim

I am generating a pdf output with pdflatex with the following command in gVim:
:!pdflatex %
This command in turns executes the following in the Command Prompt:
cmd.exe /c pdflatex /testvim.tex
Now, the problem I'm having with this is that the pdf is outputted to the system32 folder:
C:\windows\system32\testvim.pdf
How can I instruct pdflatex to generate the pdf in the folder where the tex file resides?
What about using the latex plugin for vim?
http://vim-latex.sourceforge.net/
This depends mainly on your LaTeX version. Do you use MikTeX or TeXLive ?
The pdflatex command of MikTeX has a command line option for specifying the output directory and the auxiliary directory (for .aux files).
I don't have MikTeX installed on my PC now, but you should be able to figure it out when running pdflatex --help or pdflatex /? from the command prompt.
If you are using TeXLive, you can first switch to the wanted output directory, then run pdflatex with the full path to your latex input file. This outputs everything into the current working directory, including temporary tex files.
I would suggest that you write your own runpdflatex.bat file which includes the correct call to pdflatex so you don't have to bother with it every time you want to compile your latex file.
Do you start GVim per Icon?
I do the following:
Opening Dos Box
Change to my tex-directory cd\local\tex\make
gvim foobar.tex
Executing :!pdflatex % creates the PDF document in local\tex\make not in the system32-folder

Resources