Get the format module to use for optimizing the image.
1427
def _get_format_module(image_format):
    """"""
    format_module = None
    nag_about_gifs = False

    if detect_format.is_format_selected(image_format,
                                        Settings.to_png_formats,
                                        png.PROGRAMS):
        format_module = png
    elif detect_format.is_format_selected(image_format, jpeg.FORMATS,
                                          jpeg.PROGRAMS):
        format_module = jpeg
    elif detect_format.is_format_selected(image_format, gif.FORMATS,
                                          gif.PROGRAMS):
        # this captures still GIFs too if not caught above
        format_module = gif
        nag_about_gifs = True

    return format_module, nag_about_gifs
1034717
def get_format(**kwargs):
    

    settings = foundations.data_structures.Structure(**{"format": QTextCharFormat(),
                                                        "background_color": None,
                                                        "color": None,
                                                        "font_weight": None,
                                                        "font_point_size": None,
                                                        "italic": False})
    settings.update(kwargs)

    format = QTextCharFormat(settings.format)

    settings.background_color and format.setBackground(settings.background_color)
    settings.color and format.setForeground(settings.color)
    settings.font_weight and format.setFontWeight(settings.font_weight)
    settings.font_point_size and format.setFontPointSize(settings.font_point_size)
    settings.italic and format.setFontItalic(True)

    return format
886913
private ImageFormat getFormat(List<ImageFormat> l, String n){
		for(ImageFormat f:l)
			if(f.getName().equals(n))
				return f;
		return null;
	}
570042
def getmodule(object):
    """"""
    if ismodule(object):
        return object
    if isclass(object):
        return sys.modules.get(object.__module__)
    try:
        file = getabsfile(object)
    except TypeError:
        return None
    if modulesbyfile.has_key(file):
        return sys.modules[modulesbyfile[file]]
    for module in sys.modules.values():
        if hasattr(module, '__file__'):
            modulesbyfile[getabsfile(module)] = module.__name__
    if modulesbyfile.has_key(file):
        return sys.modules[modulesbyfile[file]]
    main = sys.modules['__main__']
    if hasattr(main, object.__name__):
        mainobject = getattr(main, object.__name__)
        if mainobject is object:
            return main
    builtin = sys.modules['__builtin__']
    if hasattr(builtin, object.__name__):
        builtinobject = getattr(builtin, object.__name__)
        if builtinobject is object:
            return builtin
968605
public function getModuleSize()
    {
        if ( is_null($this->moduleSize) )
        {
            $this->moduleSize = $this->getImageFormat() == "jpeg" ? 8 : 4;
        }

        return $this->moduleSize;
    }
454828
def get_ext(self, format=None, **kwargs):
        
        try:
            format = format or self.default_params['format']
            return ".%s" % format.lower()
        except KeyError: pass
189647
def get_format_modules(lang=None, reverse=False):
    
    if lang is None:
        lang = get_language()
    modules = _format_modules_cache.setdefault(lang, list(
        iter_format_modules(lang)))
    if reverse:
        return list(reversed(modules))
    return modules
1337025
def png(self):
        """"""
        use_plugin('freeimage')
        with TemporaryFilePath(suffix='.png') as tmp:
            safe_range_im = 255 * normalise(self)
            imsave(tmp.fpath, safe_range_im.astype(np.uint8))
            with open(tmp.fpath, 'rb') as fh:
                return fh.read()
805960
def get_format_spec(self):
        '''
        
        '''
        return u"{{:{align}{width}}}".format(align=self.align, width=self.width)
974294
def apply(self, resource):
        
        if not isinstance(resource, Image.Image):
            raise ValueError('Unknown resource format')

        original_width, original_height = resource.size

        if self.start[0] < original_width or self.start[1] < original_height:
            left = self.start[0]
            upper = self.start[1]
        else:
            left = 0
            upper = 0

        right = self.start[0] + self.size[0]
        lower = self.start[1] + self.size[1]

        resource_format = resource.format
        resource = resource.crop(
            (
                left,
                upper,
                right if right < original_width else original_width,
                lower if lower < original_height else original_height
            )
        )
        resource.format = resource_format

        return resource
820783
def get_module_path(exc_type):
    
    module = inspect.getmodule(exc_type)
    return "{}.{}".format(module.__name__, exc_type.__name__)
1208871
def get_package_formats():
    """"""
    # pylint: disable=fixme
    # HACK: This obviously isn't great, and it is subject to change as
    # the API changes, but it'll do for now as a interim method of
    # introspection to get the parameters we need.
    def get_parameters(cls):
        """Build parameters for a package format."""
        params = {}

        # Create a dummy instance so we can check if a parameter is required.
        # As with the rest of this function, this is obviously hacky. We'll
        # figure out a way to pull this information in from the API later.
        dummy_kwargs = {k: "dummy" for k in cls.swagger_types}
        instance = cls(**dummy_kwargs)

        for k, v in six.iteritems(cls.swagger_types):
            attr = getattr(cls, k)
            docs = attr.__doc__.strip().split("\n")
            doc = (docs[1] if docs[1] else docs[0]).strip()

            try:
                setattr(instance, k, None)
                required = False
            except ValueError:
                required = True

            params[cls.attribute_map.get(k)] = {
                "type": v,
                "help": doc,
                "required": required,
            }

        return params

    return {
        key.replace("PackagesUpload", "").lower(): get_parameters(cls)
        for key, cls in inspect.getmembers(cloudsmith_api.models)
        if key.startswith("PackagesUpload")
    }
1018453
function (format) {
        if (!this.image || !this.size) return null;

        format = format || "image/png";
        var canvas = document.createElement("canvas");
        var context = canvas.getContext("2d");
        context.canvas.width = this.size.w;
        context.canvas.height = this.size.h;

        var imgData = context.createImageData(this.size.w, this.size.h);
        for (var i = 0; i < this.image.length; i++) {
            imgData.data[i] = this.image[i];
        }
        context.putImageData(imgData, 0, 0);
        
        return canvas.toDataURL(format);
    }
787211
def convert(f, opts = {})
      opts = opts.dup
      f = f.to_s.downcase
      allowed = %w(jpeg jpg png)
      raise ArgumentError, "Format must be one of: #{allowed.join(',')}" unless allowed.include?(f)
      self.format_override = f == 'jpeg' ? 'jpg' : f
      opts[:Q] = opts.delete(:quality) if opts.has_key?(:quality)
      write_opts.merge!(opts)
      get_image
    end
1042891
function _imageOptim(rawFile, algorithms, reduceFunc, initVal) {
    return Q.all([rawFile.loadSize(), rawFile.loadType()])
        .then(function () {
            return algorithms[rawFile.type].reduce(reduceFunc, initVal);
        })
        .fail(function (err) {
            throw err;
        });
}
1287936
def _convert(self, format):
        
        if self.format == format:
            return self
        else:
            image = Image(self.pil_image)
            image._format = format
            return image
970160
function getLitmusForModule (module) {

    if (isLitmus(module)) {
        return module;
    }

    if (module.test && isLitmus(module.test)) {
        return module.test;
    }

    throw new Error('litmus: expected module to export litmus.Test or litmus.Suite');
}