FormatConverter

Description

This macro allows instant single-file conversions from various input formats into various output formats.

Currently the following conversions are available:

Source format

target: PNG

target: SVG

Requirements (Debian packages)

dia

(./)

(./)

dia

dot

(./)

(./)

graphviz

Postscript (PS/EPS)

(./)

(./)

inkscape

PDF

(./)

(./)

pstoimg (latex2html) / pdf2svg

xcf

(./)

-

xcftolls

Thus you can attach your complicated multi-layer GIMP file (using the xcf format) to a wiki page. This macro allows you to embed this xcf-image into your wiki page just like any other png image. Thus you do not need to attach your source file (xcf) and your export file (png) separately.

File attachments or URLs can be used as a source for conversions.

All input and output files are cached for efficient operation.

Extensibility

One goal of this macro is to simplify all kinds of single-file conversions. You can add another input/output combination with a few lines of code. The following two examples shall encourage you to add your favourite conversions to this plugin:

   1 def xcf2png_converter_xcftools(_, source_file, target_file, details):
   2     return exec_cmd_tokens(_, ["xcf2png", "-o", target_file, source_file])
   3 
   4 def pdf2svg_converter(_, source_file, target_file, details):
   5     # 'pageno' can be a number or a page specification (e.g. 'iii')
   6     page = details.get("page", 1)
   7     return exec_cmd_tokens(_, ["pdf2svg", source_file, target_file, str(page)])

Download & Release Notes

Download

Release Version

Moin Version

Release Notes

FormatConverter-1.1.py

1.1

1.9.9

fix minor incompatibility with munin 1.9.9

FormatConverter-1.0.py

1.0

1.9

initial release

Usage

<<FormatConverter(ATTACHMENT_OR_URL, INPUT_FILETYPE, OUTPUT_FILETYPE, WIDTH=0, HEIGHT=0, EXTRAS="")>>
attachment_or_url

specify the input file with a URL or the name of an attachment (filename.ext or Pagename/filename.ext

input_filetype
one of the supported input filetypes (dia, dot, pdf, ps, xcf)
output_filetype
one of the supported output filetype (svg, png)
width
[optional] width to be used for the conversion and/or for the embedding (default: use the dimension of the source file)
height

[optional] see width above

extras

[optional] space-separated list of colon-separated pairs (e.g. page=1 for pdf input)

Example

<<FormatConverter(diagram.dia, dia, svg)>>
<<FormatConverter(graphviz.dot, dot, png, width=300)>>
<<FormatConverter(book.pdf, pdf, svg, extras=page:1)>>
<<FormatConverter(http://example.org/article.pdf, pdf, png, height=1024)>>

ReimarBauer, LarsKruse

The code is based on the macro pdf2img by ReimarBauer.

License

GPL v3 or later

Bugs

Discussion

MoinMoin: MacroMarket/FormatConverter (last edited 2018-11-02 02:19:35 by sumpfralle)