Tell if there is a preview image.
327325
def has_image(self, digest, mime_type, index, size=500):
        """"""
        cache_key = f"img:{index}:{size}:{digest}"
        return mime_type.startswith("image/") or cache_key in self.cache
1130629
private function get_preview( $preview_size ) {
		$url    = $this->get_url( $preview_size );
		$return = null;
		if ( ! empty( $url ) ) {
			$return = '<img src="' . esc_attr( $url ) . '" class="uix-image-control-preview"><a href="#" class="uix-image-control-remove" data-target="' . $this->id() . '"><span class="dashicons dashicons-no"></span></a>';
		}

		return $return;
	}
1105946
def thumbnail_preview(src_path):
  '''  '''
  try:
    assert(exists(src_path))

    width = '1980'

    dest_dir = mkdtemp(prefix='pyglass')
    cmd = [QLMANAGE, '-t', '-s', width, src_path, '-o', dest_dir]
    assert(check_call(cmd) == 0)

    src_filename = basename(src_path)
    dest_list = glob(join(dest_dir, '%s.png' % (src_filename)))
    assert(dest_list)

    dest_path = dest_list[0]
    assert(exists(dest_path))

    return dest_path
  except:
    return None
629722
def previews(self):
        '''
            
        '''
        MAX_PREVIEW_SIZE = 1000000

        def sanitize(bytes):
            return bytes.decode('utf-8', 'ignore')

        def is_code(fname):
            code_endings = ['.c', '.cpp', 'Makefile',
                            '.java', '.py', '.rb', '.js']
            for ending in code_endings:
                if fname.endswith(ending):
                    return True
            return False

        result = []
        try:
            assert(self.attachment.path is not None)
        except ValueError:
            # The file behind the given path does not exist
            return None
        if zipfile.is_zipfile(self.attachment.path):
            zf = zipfile.ZipFile(self.attachment.path, 'r')
            for zipinfo in zf.infolist():
                if zipinfo.file_size < MAX_PREVIEW_SIZE:
                    try:
                        result.append({'name': zipinfo.filename, 'is_code': is_code(
                            zipinfo.filename), 'preview': sanitize(zf.read(zipinfo))})
                    except NotImplementedError as e:
                        result.append(
                                {'name': zipinfo.filename, 'is_code': False, 'preview': '(NotImplementedError: %s)' % (e)})

                    result.append({'name': zipinfo.filename, 'is_code': is_code(
                        zipinfo.filename), 'preview': sanitize(zf.read(zipinfo))})
                else:
                    result.append(
                        {'name': zipinfo.filename, 'is_code': False, 'preview': '(maximum size exceeded)'})
        elif tarfile.is_tarfile(self.attachment.path):
            tf = tarfile.open(self.attachment.path, 'r')
            for tarinfo in tf.getmembers():
                if tarinfo.isfile():
                    if tarinfo.size < MAX_PREVIEW_SIZE:
                        result.append({'name': tarinfo.name, 'is_code': is_code(
                            tarinfo.name), 'preview': sanitize(tf.extractfile(tarinfo).read())})
                    else:
                        result.append(
                            {'name': tarinfo.name, 'is_code': False, 'preview': '(maximum size exceeded)'})
        else:
            # single file
            f = open(self.attachment.path, 'rb')
            fname = f.name[f.name.rfind(os.sep) + 1:]
            result = [{'name': fname, 'is_code': is_code(
                fname), 'preview': sanitize(f.read())}, ]
        return result
306942
def is_progressive(image):
    
    if not isinstance(image, Image.Image):
        # Can only check PIL images for progressive encoding.
        return False
    return ('progressive' in image.info) or ('progression' in image.info)
97868
def OnPrintPreview(self, event):
        """"""

        print_area = self._get_print_area()
        print_data = self.main_window.print_data

        self.main_window.actions.print_preview(print_area, print_data)
1201789
public function preview()
    {
        if (($pos = strrpos($this->path, '.')) !== false) {
            $type = substr($this->path, $pos + 1);
        } else {
            $type = 'unknown';
        }

        if ($type === 'php') {
            return highlight_string($this->content, true);
        } elseif (!in_array($type, ['jpg', 'gif', 'png', 'exe'])) {
            return nl2br(Html::encode($this->content));
        }

        return false;
    }
560409
public long imagePreview(String wxName, String openId, String image) {
		return preview(wxName, openId, "image", image);
	}
851498
def preview(self, obj, request=None):
        
        source = self.get_thumbnail_source(obj)
        if source:
            try:
                from easy_thumbnails.files import get_thumbnailer
            except ImportError:
                logger.warning(
                    _(
                        '`easy_thumbnails` is not installed and required for '
                        'icekit.admin_tools.mixins.ThumbnailAdminMixin'
                    )
                )
                return ''
            try:
                thumbnailer = get_thumbnailer(source)
                thumbnail = thumbnailer.get_thumbnail(self.thumbnail_options)
                return '<img class="thumbnail" src="{0}" />'.format(
                    thumbnail.url)
            except Exception as ex:
                logger.warning(
                    _(u'`easy_thumbnails` failed to generate a thumbnail image'
                      u' for {0}'.format(source)))
                if self.thumbnail_show_exceptions:
                    return 'Thumbnail exception: {0}'.format(ex)
        return ''
447152
def image_exists(self, image_name, tag='latest'):
        
        code, image = self.image_tags(image_name)
        if code != httplib.OK:
            return False
        tag = tag.lower()
        return any(x.lower() == tag for x in image.tags)
48524
def _is_image_sequenced(image):
    """"""
    try:
        image.seek(1)
        image.seek(0)
        result = True
    except EOFError:
        result = False

    return result
25541
def preview(self):
        """"""

        if hasattr(self, '_url'):
            url = self._url + '/preview'
            return self.post(url)
        else:
            url = urljoin(recurly.base_uri(), self.collection_path + '/preview')
            return self.post(url)
994433
def is_image(name, exts=None):
    """"""

    default = ['jpg', 'png', 'gif', 'jpeg']
    if exts:
        default += exts

    flag = False
    for ext in default:
        if name.lower().endswith(ext):
            flag = True
            break
    return flag
358103
public function PreviewThumbnail()
    {
        $width = (int)Config::inst()->get(__CLASS__, 'asset_preview_width');
        return $this->ScaleMaxWidth($width)  ?: $this->IconTag();
    }
974310
private void previewAlbum(int position) {
        if (mAlbumFiles == null || mAlbumFiles.size() == 0) {
            Toast.makeText(this, R.string.no_selected, Toast.LENGTH_LONG).show();
        } else {
            Album.galleryAlbum(this)
                    .checkable(true)
                    .checkedList(mAlbumFiles)
                    .currentPosition(position)
                    .widget(
                            Widget.newDarkBuilder(this)
                                    .title(mToolbar.getTitle().toString())
                                    .build()
                    )
                    .onResult(new Action<ArrayList<AlbumFile>>() {
                        @Override
                        public void onAction(@NonNull ArrayList<AlbumFile> result) {
                            mAlbumFiles = result;
                            mAdapter.notifyDataSetChanged(mAlbumFiles);
                            mTvMessage.setVisibility(result.size() > 0 ? View.VISIBLE : View.GONE);
                        }
                    })
                    .start();
        }
    }
444505
def has_cover_image?(check = nil)
    	post = obtain_record(check)
    	!post.blank? && !post.cover_image.blank? ? true : false
    end
117110
def _find_image_ext(path, number=None):
    """"""
    if number is not None:
        path = path.format(number)
    path = os.path.splitext(path)[0]
    for ext in _KNOWN_IMG_EXTS:
        this_path = '%s.%s' % (path, ext)
        if os.path.isfile(this_path):
            break
    else:
        ext = 'png'
    return ('%s.%s' % (path, ext), ext)