class_docstr: Abstract image class for (de)serializing images to/from byte streams/strings.
  
  The class doesn't define any image properties.
  
  It has:
  
  methods:
  
     * to_bytes() - serialize image to byte string
  
  classmethods:
  
     * from_bytes(bytestring) - make instance by deserializing a byte string
     * from_url(url) - make instance by fetching and deserializing a URL
  
  Loading from byte strings should provide round-trip equivalence:
  
  .. code:: python
  
      img_a = klass.from_bytes(bstr)
      img_b = klass.from_bytes(img_a.to_bytes())
  
      np.allclose(img_a.get_fdata(), img_b.get_fdata())
      np.allclose(img_a.affine, img_b.affine)
  
  Further, for images that are single files on disk, the following methods of loading
  the image must be equivalent:
  
  .. code:: python
  
      img = klass.from_filename(fname)
  
      with open(fname, 'rb') as fobj:
          img = klass.from_bytes(fobj.read())
  
  And the following methods of saving a file must be equivalent:
  
  .. code:: python
  
      img.to_filename(fname)
  
      with open(fname, 'wb') as fobj:
          fobj.write(img.to_bytes())
  
  Images that consist of separate header and data files (e.g., Analyze
  images) currently do not support this interface.
  For multi-file images, ``to_bytes()`` and ``from_bytes()`` must be
  overridden, and any encoding details should be documented.
docstr: Construct image from a byte string
  
  Class method
  
  Parameters
  ----------
  bytestring : bytes
      Byte string containing the on-disk representation of an image
docstr_tok: ["Construct","image","from","a","byte","string","Class","method","Parameters","--","--","--","--","--","bytestring",":","bytes","Byte","string","containing","the","on-disk","representation","of","an","image"]
code: def from_bytes(
      klass: type[StreamImgT], bytestring: bytes
  ) -> StreamImgT:
      """Construct image from a byte string
  
      Class method
  
      Parameters
      ----------
      bytestring : bytes
          Byte string containing the on-disk representation of an image
      """
      return klass.from_stream(io.BytesIO(bytestring))
  
imports: from __future__ import annotations
  import io
  import typing
  from copy import deepcopy
  from urllib import request
  from ._compression import COMPRESSION_ERRORS
  from .fileholders import FileHolder, FileMap
  from .filename_parser import TypesFilenamesError, _stringify_path, splitext_addext, types_filenames
  from .openers import ImageOpener
label_desc: Use image node_id 4 for calling the SerializableImage obj's underlying member method code with example usage: obj.from_bytes(klass, bytestring) and returns: klass