code: def open(filename):
      """
      Load texture from a Quake2 WAL texture file.
  
      By default, a Quake2 standard palette is attached to the texture.
      To override the palette, use the <b>putpalette</b> method.
  
      :param filename: WAL file name, or an opened file handle.
      :returns: An image instance.
      """
      # FIXME: modify to return a WalImageFile instance instead of
      # plain Image object ?
  
      def imopen(fp):
          # read header fields
          header = fp.read(32 + 24 + 32 + 12)
          size = i32(header, 32), i32(header, 36)
          offset = i32(header, 40)
  
          # load pixel data
          fp.seek(offset)
  
          Image._decompression_bomb_check(size)
          im = Image.frombytes("P", size, fp.read(size[0] * size[1]))
          im.putpalette(quake2palette)
  
          im.format = "WAL"
          im.format_description = "Quake2 Texture"
  
          # strings are null-terminated
          im.info["name"] = header[:32].split(b"\0", 1)[0]
          next_name = header[56 : 56 + 32].split(b"\0", 1)[0]
          if next_name:
              im.info["next_name"] = next_name
  
          return im
  
      if hasattr(filename, "read"):
          return imopen(filename)
      else:
          with builtins.open(filename, "rb") as fp:
              return imopen(fp)
  
label_desc: Use image node_id 1 for calling a global function with example usage: open(filename) and returns: im, imopen, imopen