Convert SWF slides into a PNG image

    Raises:
        OSError is raised if swfrender is not available.
        ConversionError is raised if image cannot be created.

def swf2png(swf_path, png_path, swfrender_path="swfrender"):
    """Convert SWF slides into a PNG image

    Raises:
        OSError is raised if swfrender is not available.
        ConversionError is raised if image cannot be created.
    """
    # Currently rely on swftools
    #
    # Would be great to have a native python dependency to convert swf into png or jpg.
    # However it seems that pyswf  isn't flawless. Some graphical elements (like the text!) are lost during
    # the export.
    try:
        cmd = [swfrender_path, swf_path, '-o', png_path]
        subprocess.check_output(cmd, stderr=subprocess.STDOUT)
    except subprocess.CalledProcessError as e:
        raise ConversionError("Failed to convert SWF file %s.\n"
                              "\tCommand: %s\n"
                              "\tExit status: %s.\n"
                              "\tOutput:\n%s"
                              % (swf_path, " ".join(cmd), e.returncode, e.output))