Collection of mostly command line tools / PHP scripts. Somewhat out of date.

⌈⌋ branch:  scripts + snippets


Artifact [76a9fc87fb]

Artifact 76a9fc87fb3c74ec7a97ef1063a1f8b5d295c726:

  • File inkscape/export_gif.inx — part of check-in [4621d9c6bd] at 2022-10-12 13:01:48 on branch trunk — recombine zip_args into imagick_gif(), distribute some flags onto frame.pngs (user: mario size: 10465)

<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
  <name>GIF slideshow</name>
  <description>Export and combine layers as animation via ImageMagick/Pillow</description>
  <!--<schema:softwareVersion xmlns:schema="https://schema.org/">1.1</schema:softwareVersion>-->
  <category>Export</category>
  <id>org.include-once.inkscape.export-gif</id>
  <dependency type="executable" location="inx">export_gif.py</dependency>
  <label appearance="header">Export and combine layers as animation via ImageMagick/Pillow</label>
  <param name="file" type="path" mode="file" gui-description="Output filename should end in .gif for actual results. Alternatively can be `APNG:dir/filename.apng` with ImageMagick 7." gui-text="Target GIF filename">~/anim.gif</param>
  <param name="mode" type="optiongroup" appearance="combo" gui-description="There's different backends to assemble the GIF. Pillow also works on Windows without convert.exe installed. The JavaScript mode embeds some code, does not actually generate a GIF output file." gui-text="Conversion mode">
    <option value="PNG→ImageMagick (better quality)">PNG→ImageMagick (better quality)</option>
    <option value="SVG→ImageMagick (simple drawings)">SVG→ImageMagick (simple drawings)</option>
    <option value="PNG→Pillow (builtin - a bit faster)">PNG→Pillow (builtin - a bit faster)</option>
    <option value="JavaScript→SVG (embed anim code)">JavaScript→SVG (embed anim code)</option>
  </param>
  <param name="delay" type="float" min="0.01" max="20" precision="2" mode="float" gui-text="Delay between slides (seconds)">0.35</param>
  <param name="loop" type="int" min="0" max="100" precision="1" gui-text="Loop limit (0 for endless)">0</param>
  <image width="505" height="50">export_gif.svg</image>
  <param name="notebook" type="notebook" gui-text="Additional flags and help">
    <page name="ImageMagick" gui-text="ImageMagick">
      <param name="fuzz" type="optiongroup" appearance="combo" gui-description="Detect similar colors for optimization" gui-text="Fuzzing/dither">
        <option value="0%">0%</option>
        <option value="5%">5%</option>
        <option value="10%">10%</option>
        <option value="20%">20%</option>
        <option value="30%">30%</option>
        <option value="50%">50%</option>
      </param>
      <param name="layers" type="optiongroup" appearance="combo" gui-description="Can influence optimization or layer combination. Specifically coalesce/merge are pre-interpreted by export_gif to produce accumulating slides." gui-text="Accumulation/combination of -layers">
        <option value="optimize">optimize</option>
        <option value="coalesce">coalesce</option>
        <option value="compare-any">compare-any</option>
        <option value="compare-clear">compare-clear</option>
        <option value="compare-overlay">compare-overlay</option>
        <option value="composite">composite</option>
        <option value="dispose">dispose</option>
        <option value="flatten">flatten</option>
        <option value="merge">merge</option>
        <option value="mosaic">mosaic</option>
        <option value="optimize-frame">optimize-frame</option>
        <option value="optimize-plus">optimize-plus</option>
        <option value="optimize-transparency">optimize-transparency</option>
        <option value="remove-dups">remove-dups</option>
        <option value="remove-zero">remove-zero</option>
        <option value="trim-bounds">trim-bounds</option>
      </param>
      <param name="extra" type="optiongroup" appearance="combo" gui-description="Some default convert -args." gui-text="Extra args">
        <option value="-quiet">-quiet</option>
        <option value="-optimize">-optimize</option>
        <option value="-size 640x360">-size 640x360</option>
        <option value="-alpha background">-alpha background</option>
        <option value="-auto-gamma">-auto-gamma</option>
        <option value="-auto-level">-auto-level</option>
        <option value="-coalesce">-coalesce</option>
        <option value="-colors 64">-colors 64</option>
        <option value="-dither FloydSteinberg">-dither FloydSteinberg</option>
        <option value="-limit disk 1MB">-limit disk 1MB</option>
        <option value="-reverse">-reverse</option>
        <option value="-monochrome">-monochrome</option>
        <option value="-transparent white">-transparent white</option>
      </param>
      <param name="extra2" type="string" gui-description="Specify additional convert(1) options." gui-text="Custom args"/>
      <param name="background" type="color" mode="color" appearance="colorbutton" gui-description="Only works for SVG→ImageMagick option." gui-text="Background color for transparent layers">0</param>
    </page>
    <page name="System" gui-text="System">
      <param name="preview" type="bool" mode="checkbox" gui-description="Should bring up default image viewer on resulting GIF (via xdg-open, or start… on Windows)" gui-text="Preview result file">false</param>
      <param name="keep_tmp" type="bool" mode="checkbox" gui-description="Will retain the frame PNGs in the fixed directory /tmp/inkscape.export_gif/" gui-text="Keep temporary files">false</param>
      <param name="reload_svg" type="bool" mode="checkbox" gui-description="Averts the warning popup of lacking result data. But is quite redundant for this tool. And should only be enabled if it's becoming too obnoxious." gui-text="Reload SVG in Inkscape">false</param>
      <param name="export_background" type="bool" mode="checkbox" gui-description="Uses --export-background for generating PNG slides prior assembly. (See ImageMagick for color tab.)" gui-text="Force background application in PNG export">false</param>
    </page>
    <page name="Animation" gui-text="Animation">
      <param name="subframes" type="int" min="0" max="100" precision="1" gui-description="Can be overridden per [animate=25] or [steps=25] in layer label." gui-text="Subframes per ❮animation❯ slide">5</param>
      <param name="a_rotate" type="bool" mode="checkbox" gui-description="Actually works better than tweening, and allows for &gt;90° rotations without collapsing the matrix. OTOH the inkex method might handle positioning better." gui-text="Use simpler rotate() handler">true</param>
      <param name="all_anim" type="bool" mode="checkbox" gui-description="Makes [animate] tags redundant, at the expense of longer processing times; and repeat runs for background layers." gui-text="Engage whenever SVG animate instructions are present">false</param>
      <param name="all_pace" type="bool" mode="checkbox" gui-description="Honor begin=, dur=, and some calcMode= settings, for pacing or delayed timing. Otherwise individual layers can be marked with [pace] or [smooth] in addition to [animate]. Else animations run/stretch across the alloted delay time for a slide." gui-text="Honor timing information for all slides">false</param>
    </page>
    <page name="Help" gui-text="Help">
      <label>Layer labels (Ctrl+Shift+L, double click) can specify additional options:</label>
      <label>🞂 [fixed] for very permanent foreground layer</label>
      <label>🞂 [background] for sticky background images</label>
      <label>🞂 [merge] enjoins partial layers; and [exclude] skips them</label>
      <label>🞂 [animate=10] generates ❮animate*❯ subframes, flag: [pace] timing</label>
      <label appearance="url">https://fossil.include-once.org/scripts/wiki/inkscape</label>
    </page>
  </param>
  <effect needs-live-preview="false">
    <object-type>all</object-type>
    <effects-menu>
      <submenu name="Export"/>
    </effects-menu>
    <menu-tip>Export and combine layers as animation via ImageMagick/Pillow</menu-tip>
  </effect>
  <!--output>
        <extension>.gif</extension>
        <mimetype>image/gif</mimetype>
        <filetypename>GIF slideshow (*.gif)</filetypename>
        <filetypetooltip>Graphics Interchange Format 98a</filetypetooltip>
        <dataloss>true</dataloss>
    </output-->
  <script>
    <command location="inx" interpreter="python">export_gif.py</command>
  </script>
  <!--
        pars.add_argument("-"+"-file", type=str, dest="file", default="~/anim.gif", help="Target GIF filename")
        pars.add_argument("-"+"-mode", type=str, dest="mode", default="PNG+ImageMagick", help="Conversion mode")
        pars.add_argument("-"+"-delay", type=float, dest="delay", default=0.35, help="Delay between slides (seconds)")
        pars.add_argument("-"+"-loop", type=int, dest="loop", default=0, help="Loop limit (0 for endless)")
        pars.add_argument("-"+"-notebook", type=str, dest="notebook", default="system", help="Additional flags and help")
        pars.add_argument("-"+"-fuzz", type=str, dest="fuzz", default="10%", help="Fuzzing/dither")
        pars.add_argument("-"+"-layers", type=str, dest="layers", default="optimize", help="Accumulation/combination of -layers")
        pars.add_argument("-"+"-extra", type=str, dest="extra", default="", help="Extra args")
        pars.add_argument("-"+"-extra2", type=str, dest="extra2", default="", help="Custom args")
        pars.add_argument("-"+"-background", type=inkex.Color, dest="background", default="0", help="Background color for transparent layers")
        pars.add_argument("-"+"-preview", type=inkex.Boolean, dest="preview", default=False, help="Preview result file")
        pars.add_argument("-"+"-keep_tmp", type=inkex.Boolean, dest="keep_tmp", default=False, help="Keep temporary files")
        pars.add_argument("-"+"-reload_svg", type=inkex.Boolean, dest="reload_svg", default=False, help="Reload SVG in Inkscape")
        pars.add_argument("-"+"-export_background", type=inkex.Boolean, dest="export_background", default=False, help="Force background application in PNG export")
        pars.add_argument("-"+"-subframes", type=int, dest="subframes", default=5, help="Subframes per ❮animation❯ slide")
        pars.add_argument("-"+"-a_rotate", type=inkex.Boolean, dest="a_rotate", default=True, help="Use simpler rotate() handler")
        pars.add_argument("-"+"-all_anim", type=inkex.Boolean, dest="all_anim", default=False, help="Engage whenever SVG animate instructions are present")
        pars.add_argument("-"+"-all_pace", type=inkex.Boolean, dest="all_pace", default=False, help="Honor timing information for all slides")
-->
</inkscape-extension>