I have a feature request for the official RunCommand plugin, please move this thread if it is not the right category.
Some context : I want to display an "dynamic" SVG available on the web (https://s3.coinmarketcap.com/generated/sparklines/web/7d/usd/74.svg). I use the WebParser to get the file, no problem here.
As the Image meter does not support SVG (that would be another feature request actually), I want to use ImageMagick to generate a PNG.
This was my first try :
Code: Select all
; download SVG
[MeasureSparklineSvg]
Measure=WebParser
UpdateRate=600
Url=https://s3.coinmarketcap.com/generated/sparklines/web/7d/usd/[&MeasureQuoteId].svg
Download=1
Paused=1
DynamicVariables=1
FinishAction=[!UpdateMeasure MeasureSparklinePng][!CommandMeasure MeasureSparklineConvert "Run"]
; build PNG file path
[MeasureSparklinePng]
Measure=String
UpdateDivider=-1
String=[MeasureSparklineSvg]
DynamicVariables=1
RegExpSubstitute=1
Substitute="svg$":"png"
; convert SVG to PNG
[MeasureSparklineConvert]
Measure=Plugin
Plugin=RunCommand
UpdateDivider=-1
Parameter=magick convert -background transparent [MeasureSparklineSvg] [MeasureSparklinePng]
DynamicVariables=1
OutputType=ANSI
Code: Select all
magick convert -background transparent
However I am able to make it work with a intermediary variable, but it is a bit harder to read :
Code: Select all
[Variables]
MagickCommand=
; download SVG
[MeasureSparklineSvg]
Measure=WebParser
UpdateRate=600
Url=https://s3.coinmarketcap.com/generated/sparklines/web/7d/usd/[&MeasureQuoteId].svg
Download=1
Paused=1
DynamicVariables=1
FinishAction=[!UpdateMeasure MeasureSparklinePng]
; build PNG file path
[MeasureSparklinePng]
Measure=String
UpdateDivider=-1
String=[MeasureSparklineSvg]
DynamicVariables=1
RegExpSubstitute=1
Substitute="svg$":"png"
OnUpdateAction=[!SetVariable MagickCommand "magick convert -background transparent [MeasureSparklineSvg] [MeasureSparklinePng]"][!UpdateMeasure MeasureSparklineConvert][!CommandMeasure MeasureSparklineConvert "Run"]
; convert SVG to PNG
[MeasureSparklineConvert]
Measure=Plugin
Plugin=RunCommand
UpdateDivider=-1
Parameter=#MagickCommand#
DynamicVariables=1
OutputType=ANSI
Thank you.