Determine if the image format is selected by command line arguments.
348579
def is_format_selected(image_format, formats, progs):
    """"""
    intersection = formats & Settings.formats
    mode = _is_program_selected(progs)
    result = (image_format in intersection) and mode
    return result
471254
def on_foreground_source(self, *args):
        
        if self.foreground_source:
            self.foreground_image = Image(source=self.foreground_source)
1294842
def isExe(self):
        
        if not self.isDll() and not self.isDriver() and ( consts.IMAGE_FILE_EXECUTABLE_IMAGE & self.ntHeaders.fileHeader.characteristics.value) == consts.IMAGE_FILE_EXECUTABLE_IMAGE:
            return True
        return False
375161
private static function detectQualityOfJpgUsingImagickBinary($filename)
    {
        if (function_exists('exec')) {
            // Try Imagick using exec, and routing stderr to stdout (the "2>$1" magic)
            exec("identify -format '%Q' " . escapeshellarg($filename) . " 2>&1", $output, $returnCode);
            //echo 'out:' . print_r($output, true);
            if ((intval($returnCode) == 0) && (is_array($output)) && (count($output) == 1)) {
                return intval($output[0]);
            }
        }
        return null;
    }
41588
def is_valid_file(parser, arg):
    """"""
    arg = os.path.abspath(arg)
    if not os.path.exists(arg):
        parser.error("The file %s does not exist!" % arg)
    else:
        return arg
194350
def check_animated(cls, raw_image):
        ""
        try:
            raw_image.seek(1)
        except EOFError:
            isanimated= False
        else:
            isanimated= True
            raise cls.AnimatedImageException
325639
def getArguments(parser):
    ""
    args = parser.parse_args()    
    # check output image exists if override not forced
    if not args.force:
        if os.path.exists(args.output + args.image[-4:]):
            raise ArgumentError('The supplied output file {} already exists. Run -f/force flag to override.'.format(args.output))

    return args
139783
def on_background_image(self, *args):
        
        if self.background_image is not None:
            self.background_texture = self.background_image.texture
1179817
def validate(args):
    
    if args.format not in FORMATTERS:
        print(
            "Subtitle format not supported. "
            "Run with --list-formats to see all supported formats."
        )
        return False

    if args.src_language not in LANGUAGE_CODES.keys():
        print(
            "Source language not supported. "
            "Run with --list-languages to see all supported languages."
        )
        return False

    if args.dst_language not in LANGUAGE_CODES.keys():
        print(
            "Destination language not supported. "
            "Run with --list-languages to see all supported languages."
        )
        return False

    if not args.source_path:
        print("Error: You need to specify a source path.")
        return False

    return True
702374
def is_imagej(self):
        """"""
        for description in (self.description, self.description1):
            if not description:
                return None
            if description[:7] == 'ImageJ=':
                return description
        return None
457116
def check_python_help(filename):
    """"""
    try:
        proc = run_program(filename, ["-h"])
        output = to_text_string(proc.communicate()[0])
        valid = ("Options and arguments (and corresponding environment "
                 "variables)")
        if 'usage:' in output and valid in output:
            return True
        else:
            return False
    except:
        return False
590929
def validate_args(opts):
    """"""
    if opts['--wide'] is None:
        opts['--wide'] = 2
    else:
        assert opts['--wide'] in ("1", "2"), opts['--wide']
    if opts['--alignment'] is None:
        opts['--alignment'] = 'left'
    else:
        assert opts['--alignment'] in ('left', 'right'), opts['--alignment']
    opts['--wide'] = int(opts['--wide'])
    opts['character_factory'] = WcWideCharacterGenerator
    if opts['--combining']:
        opts['character_factory'] = WcCombinedCharacterGenerator
    return opts
322158
def valid_args?(accepted_arg_formats)
      valid_args = false

      accepted_arg_formats.each { |format|
        # if no arguments exist, and no arguments is an accepted format, args are valid.
        if format.empty? && @current_args.empty?
          valid_args = true
        else
          passed_in_args = @current_args.clone

          format.each_with_index { |arg, i|
            passed_in_args[i] = arg if CMD_BLACKLIST.include?(arg)
          }

          @invalid_args = passed_in_args - format - [nil]

          valid_args = true if passed_in_args == format
        end
      }

      valid_args
    end
1170587
def is_transparent(image):
    
    if not isinstance(image, Image.Image):
        # Can only deal with PIL images, fall back to the assumption that that
        # it's not transparent.
        return False
    return (image.mode in ('RGBA', 'LA') or
            (image.mode == 'P' and 'transparency' in image.info))
310854
def image(image_format, doc=None):
    """"""
    @on_valid('image/{0}'.format(image_format))
    def image_handler(data, **kwargs):
        if hasattr(data, 'read'):
            return data
        elif hasattr(data, 'save'):
            output = stream()
            if introspect.takes_all_arguments(data.save, 'format') or introspect.takes_kwargs(data.save):
                data.save(output, format=image_format.upper())
            else:
                data.save(output)
            output.seek(0)
            return output
        elif hasattr(data, 'render'):
            return data.render()
        elif os.path.isfile(data):
            return open(data, 'rb')

    image_handler.__doc__ = doc or "{0} formatted image".format(image_format)
    return image_handler
1170933
def main(args=None):
    
    parser = ArgumentParser()
    parser.add_argument('-v', '--version',
                        action='version', version=CLI_VERSION)

    parsers = parser.add_subparsers(dest='dtype')

    text.create_arg_parser(parsers.add_parser('text'))
    if image is not None:
        image.create_arg_parser(parsers.add_parser('image'))

    if len(sys.argv if args is None else args) <= 1:
        parser.print_help()
        sys.exit(1)

    args = parser.parse_args(args)
    dtype = globals()[args.dtype]
    try:
        set_args(args)
        cmd = getattr(dtype, 'cmd_' + args.command)
        cmd(args)
    except ValueError as err:
        print(str(err), file=sys.stderr)
        sys.exit(1)
915840
def get_image_command(image):
    ''''''
    info = docker_inspect_or_pull(image)
    try:
        return info['Config']['Cmd']
    except KeyError as ke:
        raise DockerError('Failed to inspect image: JSON result missing key {}'.format(ke))