Get the image format.
481802
def get_image_format(filename):
    """"""
    image = None
    bad_image = 1
    image_format = NONE_FORMAT
    sequenced = False
    try:
        bad_image = Image.open(filename).verify()
        image = Image.open(filename)
        image_format = image.format
        sequenced = _is_image_sequenced(image)
    except (OSError, IOError, AttributeError):
        pass

    if sequenced:
        image_format = gif.SEQUENCED_TEMPLATE.format(image_format)
    elif image is None or bad_image or image_format == NONE_FORMAT:
        image_format = ERROR_FORMAT
        comic_format = comic.get_comic_format(filename)
        if comic_format:
            image_format = comic_format
        if (Settings.verbose > 1) and image_format == ERROR_FORMAT and \
                (not Settings.list_only):
            print(filename, "doesn't look like an image or comic archive.")
    return image_format
372748
public static String getImageFormat(ImageInputStream input) {
        Iterator<ImageReader> readers = ImageIO.getImageReaders(input);
        String format = "unknown";
        if (readers.hasNext()) {
            ImageReader reader = readers.next();
            try {
                format = reader.getFormatName();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                reader.dispose();
            }
        }

        return format;
    }
255150
def image_size(self) -> Optional[int]:
        

        """
        images = self.attributes.get('imageinfo', [])
        if images and isinstance(images, collections.abc.Sequence):
            return images[0]['size']
        return None
1170518
def img(self):
        ''''''
        import wx
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')
            img = wx.EmptyImage(self.width, self.height)
            img.SetData(self.imgstr)
        return img
921138
def guessImageMetadataFromData(img_data):
    
    format, width, height = None, None, None
    img_stream = io.BytesIO(img_data)
    try:
      img = PIL.Image.open(img_stream)
    except IOError:
      format = imghdr.what(None, h=img_data)
      format = SUPPORTED_IMG_FORMATS.get(format, None)
    else:
      format = img.format.lower()
      format = SUPPORTED_IMG_FORMATS.get(format, None)
      width, height = img.size
    return format, width, height
919357
def image(self):
        
        if self._image is None:
            self._image = Image(self.fname)
        return self._image
726826
def ReadTif(tifFile):
        """"""
        img = Image.open(tifFile)
        img = np.array(img)
        return img
428108
public Object getData() 
    {
        Object objValue = super.getData();
        ImageIcon image = this.convertValueToImage(objValue);
        return image;
    }
182720
def get_imageblock(filename, format=''):
    
    _, extension = os.path.splitext(filename)

    with open(filename, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read()).decode('utf-8')

    return '\n\n.. raw:: html\n\n\t<img src="data:image/' + (format if format else extension[1:]) + ';base64,' + encoded_string +'">\n'
665006
public function getImageAsString()
    {
        $data = null;
        ob_start();
        $this->show(true);
        $data = ob_get_contents();
        ob_end_clean();

        return $data;
    }
1216536
def get_image_sizes(image):
    """"""

    # It is possible to have the same width appear more than once, if
    # THUMBNAIL_UPSCALE is set to False and the image's width is less than the
    # largest value in FLEXIBLE_IMAGE_SIZES. So keep track of widths and
    # don't output more than one image with the same width (which would result
    # in an invalid `srcset` attribute).
    sizes = []
    seen_widths = []

    for size in settings_sizes():
        img = get_thumbnail_shim(image, size)

        if img.width in seen_widths:
            continue

        seen_widths.append(img.width)

        sizes.append({
            "url": img.url,
            "width": img.width,
            "height": img.height,
        })
    return sizes
432823
def image_url(self) -> Optional[str]:
        

        """
        images = self.attributes.get('imageinfo', [])
        if images and isinstance(images, collections.abc.Sequence):
            return images[0]['url']
        return None
924645
def get_image(self, id):
        """"""
        url = self._base_url + "/3/image/{0}".format(id)
        resp = self._send_request(url)
        return Image(resp, self)
267329
def format_image(self, image, image_format, **kwargs):
        """"""

        image_format = image_format.lower()
        accept = self.request.META['HTTP_ACCEPT'].split(',')

        if FORCE_WEBP and 'image/webp' in accept:
            image_format = 'webp'
        elif image_format == 'png8':
            alpha = image.split()[-1]
            image = image.convert('RGB')
            image = image.convert('P', palette=Image.ADAPTIVE, colors=255)
            image.paste(255, Image.eval(alpha, lambda x: 255 if x <= 128 else 0))
            image_format = 'png'
            kwargs['transparency'] = 255
        elif image_format in ('png32', 'png24'):
            image_format = 'png'

        return super(GetImageView, self).format_image(image, image_format, **kwargs)
733499
def image_data(verbose=False):
  """"""
  # This is a principled use of the `global` statement; don't lint me.
  global _IMAGE_DATA  # pylint: disable=global-statement
  if _IMAGE_DATA is None:
    if verbose:
      logger.info("--- Downloading image.")
    with contextlib.closing(urllib.request.urlopen(IMAGE_URL)) as infile:
      _IMAGE_DATA = infile.read()
  return _IMAGE_DATA
1374781
def texture_formats(self):
        """"""
        info = self._get_renderer_info()
        return {PixelFormat(info.texture_formats[i]) for i in range(info.num_texture_formats)}
1275538
def format_photo_json(self, request, photo, format):
        ""
        try:
            photo = get_cached_object(Photo, pk=photo)
            format = get_cached_object(Format, pk=format)
            content = {
                'error': False,
                'image':settings.MEDIA_URL + photo.image,
                'width':photo.width,
                'height': photo.height,
                'format_width':format.max_width,
                'format_height':format.max_height
            }
        except (Photo.DoesNotExist, Format.DoesNotExist):
            content = {'error':True}
        return HttpResponse(simplejson.dumps(content))