Pick the best candidate for all image URIs.
770692
def post_process_images(self, doctree):
        """"""

        super(AbstractSlideBuilder, self).post_process_images(doctree)

        # figure out where this doctree is in relation to the srcdir
        relative_base = (
            ['..'] *
            doctree.attributes.get('source')[len(self.srcdir) + 1:].count('/')
        )

        for node in doctree.traverse(nodes.image):

            if node.get('candidates') is None:
                node['candidates'] = ('*',)

            # fix up images with absolute paths
            if node['uri'].startswith(self.outdir):
                node['uri'] = '/'.join(
                    relative_base + [
                        node['uri'][len(self.outdir) + 1:]
                    ]
                )
706394
def _serve_individual_image(self, request):
    """"""
    run = request.args.get('run')
    tag = request.args.get('tag')
    index = int(request.args.get('index'))
    sample = int(request.args.get('sample', 0))
    data = self._get_individual_image(run, tag, index, sample)
    image_type = imghdr.what(None, data)
    content_type = _IMGHDR_TO_MIMETYPE.get(image_type, _DEFAULT_IMAGE_MIMETYPE)
    return http_util.Respond(request, data, content_type)
410571
def pick_orientation(img1, img2, spacing, desired_aspect=1.618):
    
    w1, h1 = img1.size
    w2, h2 = img2.size

    size_a = (w1 + spacing + w2, max(h1, h2, 1))
    size_b = (max(w1, w2, 1), h1 + spacing + h2)

    aspect_a = size_a[0] / size_a[1]
    aspect_b = size_b[0] / size_b[1]

    goodness_a = min(desired_aspect, aspect_a) / max(desired_aspect, aspect_a)
    goodness_b = min(desired_aspect, aspect_b) / max(desired_aspect, aspect_b)

    return 'lr' if goodness_a >= goodness_b else 'tb'
910387
public void setImageUri(int viewId, @Nullable Uri uri) {
        ViewHelper.setImageUri(mCacheView, viewId, uri);
    }
836625
def url_for(**options):
    ''''''

    url_parts = get_url_parts(**options)
    image_hash = hashlib.md5(b(options['image_url'])).hexdigest()
    url_parts.append(image_hash)

    return "/".join(url_parts)
774836
def logo_as_data_uri(self):
        """"""
        _, ext = os.path.splitext(self.logo.file.name)
        with open(self.logo.file.name, 'rb') as f:
            data = base64.b64encode(f.read())

        return 'data:image/{};base64,{}'.format(
            ext[1:],  # Remove the leading dot.
            data.decode()
        )
771375
def select_uri_implementation(ecore_model_path):
    """"""
    if URL_PATTERN.match(ecore_model_path):
        return pyecore.resources.resource.HttpURI
    return pyecore.resources.URI
857938
def avail_images(kwargs=None, call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The avail_images function must be called with '
            '-f or --function, or with the --list-images option'
        )

    if not isinstance(kwargs, dict):
        kwargs = {}

    provider = get_configured_provider()
    location = provider.get('location', DEFAULT_LOCATION)

    if 'location' in kwargs:
        location = kwargs['location']

    params = {
        'Action': 'DescribeImages',
        'RegionId': location,
        'PageSize': '100',
    }
    items = query(params=params)

    ret = {}
    for image in items['Images']['Image']:
        ret[image['ImageId']] = {}
        for item in image:
            ret[image['ImageId']][item] = six.text_type(image[item])

    return ret
116312
def _link_to_img(self):
        
        # make sure options are valid
        if self.rating.lower() not in RATINGS:
            raise InvalidRatingError(self.rating)
        if not (MIN_SIZE <= self.size <= MAX_SIZE):
            raise InvalidSizeError(self.size)
        
        url = ''
        if self.secure:
            url = SECURE_BASE_URL
        else:
            url = BASE_URL

        options = {'s' : self.size, 'r' : self.rating}
        if self.default is not None:
            options['d'] = self.default
        url += self.hash + '?' + urlencode(options)
        return url
209607
def get(img, light=False):
    """"""
    cols = gen_colors(img)

    if len(cols) < 6:
        logging.error("colorz failed to generate enough colors.")
        logging.error("Try another backend or another image. (wal --backend)")
        sys.exit(1)

    return adjust(cols, light)
855337
public static List<String> findCacheKeysForImageUri(String imageUri, ImageMemoryCache memoryCache) {
		List<String> values = new ArrayList<String>();
		for (String key : memoryCache.getKeySet()) {
			if (key.startsWith(imageUri)) {
				values.add(key);
			}
		}
		return values;
	}
995194
private void browseForImage() {
		if (emitter != null) {
			int resp = chooser.showOpenDialog(this);
			if (resp == JFileChooser.APPROVE_OPTION) {
				File file = chooser.getSelectedFile();
				String path = file.getParentFile().getAbsolutePath();
				String name = file.getName();
				
				ConfigurableEmitter.setRelativePath(path);
				emitter.setImageName(name);
				
				imageName.setText(name);
			}
		}
	}
1291567
public static void setImageUri(EfficientCacheView cacheView, int viewId, @Nullable Uri uri) {
        View view = cacheView.findViewByIdEfficient(viewId);
        if (view instanceof ImageView) {
            ((ImageView) view).setImageURI(uri);
        }
    }
855124
def remove_uri(self, image):
        '''
        '''
        image = image or ''
        uri = self.get_uri(image) or ''
        image = image.replace('%s://' %uri,'', 1)
        return image.strip('-').rstrip('/')
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;
        });
}
613783
def image_get(request, image_id):
    """"""
    image = glanceclient(request).images.get(image_id)
    return Image(image)
158202
def get(img, light=False):
    """"""
    cols = gen_colors(img)
    return adjust(cols, light)