view convert.xml @ 10:04bfb8ee7e23 draft

planemo upload for repository https://github.com/bgruening/galaxytools/new/gm/tools/image_processing/image_processing/ commit 8286492ab9c949dd169e9ae1889b963ff2b7ea3a
author bgruening
date Mon, 29 Jan 2024 10:47:45 +0000
parents 5376a7767fb3
children
line wrap: on
line source

<tool id="graphicsmagick_image_convert" name="Convert image format" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="22.05">
    <description>with GraphicsMagick</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements" />
    <command detect_errors="aggressive">
<![CDATA[
        ln -s '${input}' input.${input.ext}
        &&
        #if str($transformations) != 'None':
            #set $trans_options = str($transformations).replace(',', ' ')
        #else:
            #set $trans_options = ''
        #end if

        gm convert
            -resize ${resize}%x
            $trans_options
            #if $palette.palette_select == "automatic"
            -type Palette
            #else if $palette.palette_select == "manual"
            -colors '${palette.palette}'
            #end if
            'input.${input.ext}'
            'temp.${output_format}'
        &&
        mv 'temp.${output_format}' '${output}'
]]>
    </command>
    <inputs>
        <param format="jpg,png,bmp,gif,svg,eps,tiff,xcf" name="input" type="data" label="Image to convert" />
        <param name="transformations" multiple="true" type="select" display="checkboxes" label="Transformations">
            <option value="-flip">flip vertically</option>
            <option value="-flop">flip horizontally</option>
            <option value="-rotate 90">rotate 90 degree to the right</option>
            <option value="-rotate 270">rotate 90 degree to the left</option>
            <option value="-rotate 180">rotate 180 degree</option>
        </param>

        <conditional name="palette">
            <param name="palette_select" type="select" label="Reduce Color Palette">
                <option value="no" selected="true">No</option>
                <option value="automatic">Automatic</option>
                <option value="manual">Manual</option>
            </param>
            <when value="automatic" />
            <when value="manual">
                <param name="palette" type="integer" min="1" label="Color Palette Size" value="32" help="Number of colors to use, should be in powers of 2 (1, 2, 4, 8, 16, 32, 64, ...), otherwise space is wasted in the palette."/>
            </when>
            <when value="no" />
        </conditional>
        <param name="resize" type="float" value="100" label="Resize (%)" min="0"/>
        <param name="output_format" type="select" label="Output Format">
                <option value="jpg">jpg</option>
                <option value="png">png</option>
                <option value="bmp">bmp</option>
                <option value="gif">gif</option>
                <option value="svg">svg</option>
                <option value="eps">eps</option>
                <option value="pdf">pdf</option>
                <option value="tiff">tiff</option>
        </param>
    </inputs>
    <outputs>
        <data format="png" name="output">
            <change_format>
                <when input="output_format" value="jpg" format="jpg" />
                <when input="output_format" value="png" format="png" />
                <when input="output_format" value="bmp" format="bmp" />
                <when input="output_format" value="gif" format="gif" />
                <when input="output_format" value="svg" format="svg" />
                <when input="output_format" value="eps" format="eps" />
                <when input="output_format" value="pdf" format="pdf" />
                <when input="output_format" value="tiff" format="tiff" />
            </change_format>
        </data>
    </outputs>
    <tests>
      <test>
          <param name="input" value="donald.jpg" />
          <param name="output_format" value="png"  />
          <param name="transformations" value="-flip" />
          <param name="resize" value="50" />
          <output name="output" file="result_image_convert_1.png" compare="sim_size" delta="20000" />
      </test>
      <test>
          <param name="input" value="donald.jpg" />
          <param name="output_format" value="jpg"  />
          <conditional name="palette">
              <param name="palette_select" value="automatic" />
          </conditional>
          <output name="output" file="donald-palette.jpg" compare="sim_size" delta="20000" />
      </test>
      <test>
          <param name="input" value="donald.jpg" />
          <param name="output_format" value="jpg"  />
          <conditional name="palette">
              <param name="palette_select" value="manual" />
              <param name="palette" value="2" />
          </conditional>
          <output name="output" file="donald-colors-2.jpg" compare="sim_size" delta="20000" />
      </test>
  </tests>
    <help>
<![CDATA[

**What it does**

This tool converts an image into another format. You can also do some transformations like flipping or rotating.
Here you can see, how -flip behaves:

Input:

.. image:: $PATH_TO_IMAGES/donald.jpg

Output:

.. image:: $PATH_TO_IMAGES/donald.png

]]>
    </help>
    <expand macro="citations" />
</tool>