vsimko / figconv Goto Github PK
View Code? Open in Web Editor NEWImage converter from multiple formats to PDF - useful script for scientific writing e.g. in LaTeX
Home Page: https://github.com/vsimko/figconv
License: MIT License
Image converter from multiple formats to PDF - useful script for scientific writing e.g. in LaTeX
Home Page: https://github.com/vsimko/figconv
License: MIT License
see stty: /dev/stdin: Inappropriate ioctl for device
in:
cd images; figconv
Loading /usr/local/bin/../share/figconv-plugins/argparser.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/common-functions.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/dia-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/ooo-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/pdf-output.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/png-output.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/R-input.sh ... stty: /dev/stdin: Inappropriate ioctl for device
ok
Loading /usr/local/bin/../share/figconv-plugins/svg-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/system-checks.sh ... ok
All plugins loaded.
...
checking dia ... ok
checking odg ... ok
checking ods ... ok
checking odt ... ok
checking R ... ok
checking svg ... ok
checking pdf ... ok
checking png ... ERROR: Ghostscript not installed (gs command)
Selected output format is: pdf
R script loaded
Creating PDF of size 7 x 7
Now running R code that should plot graphics to the PDF
R code done.
This PDF contains only a single page - splitting not needed
Cropping PDF: ./example1.pdf ... mv: cannot stat ‘.pdfcrop’: No such file or directory
done
...
Describe in more details, how to use R to generate images.
There are some assumptions that need to be considered.
The script now generates PDFs, but it should be possible to generate PNGs as well, e.g. in presentations generated in RStudio (*.Rpres files)
These are markdown files that use PNG images, not PDFs
The current PNG export looks worse than converting the same pdf into png using gimp.
Instead of:
Loading /usr/local/bin/../share/figconv-plugins/argparser.sh
The output should be:
Loading /usr/local/share/figconv-plugins/argparser.sh
A Debian/Ubuntu/Mint package would be nice
Might be interesting
Currently, the tool only runs on Linux.
I hope that it should be possible to support Mac as well (but I don't have a Mac)
When missing the file ~/.config/libreoffice
is missing (e.g just after installing libreoffice), The following error occures:
Error: Unable to connect or start own listener. Aborting.
I/O Error: Couldn't open file './xyz.pdf': No such file or directory.
/usr/local/bin/../share/figconv-plugins/pdf-output.sh: line 46: [: : integer expression expected
The second time it works because ~/.confg/libreoffice
has already been created.
This can be fixed by calling: soffice --headless /dev/null
I already tried to use kcov, but didn't have time to finish the implementation:
Travis uses Ubuntu 12.04.5 LTS (precise).
This is a known bug, see also:
http://stackoverflow.com/questions/13064600/unoconv-not-working-on-ubuntu-12-04-server
Error is: UnoException during conversion ... Unsupported URL <file:///...>
tmp-pdfcrop-4176.pdf
tmp-pdfcrop-5279.pdf
tmp-pdfcrop-5618.tex
People won't always use all tools for creating their images. For example, someone might install just Dia and not LibreOffice nor Inkscape.
Wrong:
exit CHECK_FAILED
Should be:
exit $CHECK_FAILED
If I run the tool in some random directory it tries to recursively find images in all subdirectories.
checking odg ... 10980
ERROR: An instance of LibreOffice or OpenOffice is running.
ERROR: This may cause unoconv tool to fail
Should we kill the process now [yes/no] ? (default=no): y
ERROR: failed with return code 2
The script should generate some useful help message when running with -h
or --help
parameter.
When an instance of Open/LibreOffice is running, the unoconv does not generate any PDF.
Closing the Open/LibreOffice window solves the situation, but a reasonable message should be printed to the user as well.
The soffice --headless /dev/null
is called multiple times, which slows down the initialization
For example using Travis-CI
Using vagrant + virtualbox
# we need some virtualization backend, here we use virtualbox
sudo apt-get install virtualbox
# install latest vagrant (1.8+ older versions may not work properly)
https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.deb
dpkg -i vagrant_1.8.1_x86_64.deb
# the VM will live in this directory
mkdir figconv-vm
cd figconv-vm
# now initialize Ubuntu 12.04 LTS (precise)
# same as Travis-CI uses for automated builds
vagrant init hashicorp/precise64
vagrant up
vagrant ssh
Now, you should be logged into the VM running Ubuntu.
# install git and make first
sudo apt-get install git
sudo apt-get install make
# install mandatory dependencies for figconv
sudo apt-get install poppler-utils
sudo apt-get install texlive-extra-utils
# install optional dependencies for figconv
sudo apt-get install dia # diagrams made in dia
sudo apt-get install inkscape # SVG
sudo apt-get install unoconv libreoffice # Open/LibreOffice formats
sudo apt-get install r-base-core # when using R
# now install figconv
git clone --depth 1 https://github.com/vsimko/figconv.git
cd figconv
sudo make install
Sample files in tests/
can now be converted.
figconv
# this lists all generated PDF files
ls tests/*.pdf
# copy the generated files from guest vm to host system
cp -r tests /vagrant
exit # now exit the guest vm
ls -l # list the files in your host system
Rename the project to figconv
because multiple output formats will be supported.
See also issue #12
~/Work/ROADS/smooth-navi-paper/paper/figure_manual $ ls -l
total 1508
-rw-r--r-- 1 vlx vlx 28328 Apr 8 13:23 redirection.odg
-rw-r--r-- 1 vlx vlx 172165 Apr 6 21:36 redirection.png
-rw-r--r-- 1 vlx vlx 411918 Apr 6 21:36 redirection.pptx
-rw-r--r-- 1 vlx vlx 695213 Apr 6 21:36 redirection.xcf
-rw-r--r-- 1 vlx vlx 156315 Apr 6 21:36 roadroid_screenshot.pdf
-rw-r--r-- 1 vlx vlx 26604 Apr 8 12:03 rue_components.odg
-rw-r--r-- 1 vlx vlx 37536 Apr 8 12:03 rue_components.pdf
$ figconv
Loading /usr/local/bin/../share/figconv-plugins/argparser.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/common-functions.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/dia-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/ooo-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/pdf-output.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/png-output.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/R-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/svg-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/system-checks.sh ... ok
All plugins loaded.
--------------------------------------------------------------------------------
find: paths must precede expression: rue_components.odg
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
ERROR: This directory does not contain input images
Given filenames with spaces, generating the PDF works, but cropping the PDF breaks:
checking svg ... ok
checking pdf ... ok
checking png ... ok
Selected output format is: pdf
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This PDF contains only a single page - splitting not needed
Cropping PDF: ./Architektur ... mv: Aufruf von stat für '.pdfcrop' nicht möglich: Datei oder Verzeichnis nicht gefunden
done
Cropping PDF: LoRa.pdf ... mv: Aufruf von stat für '.pdfcrop' nicht möglich: Datei oder Verzeichnis nicht gefunden
done
if pgrep soffice
find a PID, then the unoconv fails
There is gs
mentioned as dependency, but it has been commented out from code.
Is it still needed ?
Add some section, probably to README.md
about other approaches to keep images in sync with the latex code. For example, knitr
and sweave
.
$ make deb
mkdir -p deb/figconv_4.2/DEBIAN
cp deb-control deb/figconv_4.2/DEBIAN/control
mkdir -p deb/figconv_4.2/usr/
cp -r bin/ deb/figconv_4.2/usr/
cp -r share/ deb/figconv_4.2/usr/
mkdir -p deb/figconv_4.2/usr/share/doc/figconv
cp deb-changelog deb/figconv_4.2/usr/share/doc/figconv/changelog
gzip -n -9 deb/figconv_4.2/usr/share/doc/figconv/changelog
cp LICENSE deb/figconv_4.2/usr/share/doc/figconv/copyright
fakeroot dpkg-deb --build deb/figconv_4.2
make: fakeroot: Command not found
make: *** [deb] Error 127
Any artists out there who could make a nice vector-based logo + icon ?
Users expect that make install
actually replaces the old version with the new version (reinstall).
$ sudo apt-get install librsvg2-bin
$ rsvg-convert -f pdf -o t.pdf t.svg
Anyone interested ?
It could be a small technical report or even a paper.
We could compare multiple approaches, e.g. figconv vs knitr
In the current build https://api.travis-ci.org/jobs/288262764/log.txt?deansi=true
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
warnings.warn(str(e), _gtk.Warning)
Previously, there were even more warnings:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.