class_docstr: Class to represent an interface to the FreeImage library.
  This class is relatively thin. It provides a Pythonic API that converts
  Freeimage objects to Python objects, but that's about it.
  The actual implementation should be provided by the plugins.
  
  The recommended way to call into the Freeimage library (so that
  errors and warnings show up in the right moment) is to use this
  object as a context manager:
  with imageio.fi as lib:
      lib.FreeImage_GetPalette()
class_docstr_tok: ["Class","to","represent","an","interface","to","the","FreeImage","library",".","This","class","is","relatively","thin",".","It","provides","a","Pythonic","API","that","converts","Freeimage","objects","to","Python","objects",",","but","that","'s","about","it",".","The","actual","implementation","should","be","provided","by","the","plugins",".","The","recommended","way","to","call","into","the","Freeimage","library","(","so","that","errors","and","warnings","show","up","in","the","right","moment",")","is","to","use","this","object","as","a","context","manager",":","with","imageio.fi","as","lib",":","lib.FreeImage_GetPalette","(",")"]
docstr: Get the freeimage Format (FIF) from a given filename.
  If mode is 'r', will try to determine the format by reading
  the file, otherwise only the filename is used.
  
  This function also tests whether the format supports reading/writing.
code: def getFIF(self, filename, mode, bb=None):
      """Get the freeimage Format (FIF) from a given filename.
      If mode is 'r', will try to determine the format by reading
      the file, otherwise only the filename is used.
  
      This function also tests whether the format supports reading/writing.
      """
      with self as lib:
          # Init
          ftype = -1
          if mode not in "rw":
              raise ValueError('Invalid mode (must be "r" or "w").')
  
          # Try getting format from the content. Note that some files
          # do not have a header that allows reading the format from
          # the file.
          if mode == "r":
              if bb is not None:
                  fimemory = lib.FreeImage_OpenMemory(
                      ctypes.c_char_p(bb), len(bb)
                  )
                  ftype = lib.FreeImage_GetFileTypeFromMemory(
                      ctypes.c_void_p(fimemory), len(bb)
                  )
                  lib.FreeImage_CloseMemory(ctypes.c_void_p(fimemory))
              if (ftype == -1) and os.path.isfile(filename):
                  ftype = lib.FreeImage_GetFileType(efn(filename), 0)
          # Try getting the format from the extension
          if ftype == -1:
              ftype = lib.FreeImage_GetFIFFromFilename(efn(filename))
  
          # Test if ok
          if ftype == -1:
              raise ValueError(
                  'Cannot determine format of file "%s"' % filename
              )
          elif mode == "w" and not lib.FreeImage_FIFSupportsWriting(
              ftype
          ):
              raise ValueError(
                  'Cannot write the format of file "%s"' % filename
              )
          elif mode == "r" and not lib.FreeImage_FIFSupportsReading(
              ftype
          ):
              raise ValueError(
                  'Cannot read the format of file "%s"' % filename
              )
          return ftype
  
imports: import os
  import sys
  import ctypes
  import threading
  import logging
  import numpy
  from ..core import get_remote_file, load_lib, Dict, resource_dirs, IS_PYPY, get_platform, InternetNotAllowedError, NeedDownloadError
label_desc: Use image node_id 13 for calling the Freeimage obj's underlying member method code with example usage: obj.getFIF(filename, mode, bb) and returns: ftype