'Converts the image to expected one.'

def convert(self, _from, _to):

    try:
        args = (([self.config.image_converter] + self.config.image_converter_args) + [_from, _to])
        logger.debug('Invoking    %r    ...', args)
        p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
    except OSError as err:
        if (err.errno != ENOENT):
            raise
        logger.warning(__('convert    command    %r    cannot    be    run.check    the    image_converter    setting'), self.config.image_converter)
        return False
    try:
        (stdout, stderr) = p.communicate()
    except (OSError, IOError) as err:
        if (err.errno not in (EPIPE, EINVAL)):
            raise
        (stdout, stderr) = (p.stdout.read(), p.stderr.read())
        p.wait()
    if (p.returncode != 0):
        raise ExtensionError((__('convert    exited    with    error:\n[stderr]\n%s\n[stdout]\n%s') % (stderr, stdout)))
    return True
