class_docstr: Sets up printing to the given file. If ``fp`` is omitted,
  ``sys.stdout.buffer`` or ``sys.stdout`` is assumed.
class_docstr_tok: ["Sets","up","printing","to","the","given","file",".","If","``","fp","``","is","omitted",",","``","sys.stdout.buffer","``","or","``","sys.stdout","``","is","assumed","."]
docstr: Draw a PIL image, centered in the given box.
docstr_tok: ["Draw","a","PIL","image",",","centered","in","the","given","box","."]
code: def image(self, box, im, dpi=None):
      """Draw a PIL image, centered in the given box."""
      # default resolution depends on mode
      if not dpi:
          if im.mode == "1":
              dpi = 200  # fax
          else:
              dpi = 100  # grayscale
      # image size (on paper)
      x = im.size[0] * 72 / dpi
      y = im.size[1] * 72 / dpi
      # max allowed size
      xmax = float(box[2] - box[0])
      ymax = float(box[3] - box[1])
      if x > xmax:
          y = y * xmax / x
          x = xmax
      if y > ymax:
          x = x * ymax / y
          y = ymax
      dx = (xmax - x) / 2 + box[0]
      dy = (ymax - y) / 2 + box[1]
      self.fp.write(b"gsave\n%f %f translate\n" % (dx, dy))
      if (x, y) != im.size:
          # EpsImagePlugin._save prints the image at (0,0,xsize,ysize)
          sx = x / im.size[0]
          sy = y / im.size[1]
          self.fp.write(b"%f %f scale\n" % (sx, sy))
      EpsImagePlugin._save(im, self.fp, None, 0)
      self.fp.write(b"\ngrestore\n")
  
file_path: pillow/src/PIL/PSDraw.py
imports: from __future__ import annotations
  import sys
  from .None import EpsImagePlugin
label_desc: Use image node_id 8 for calling the PSDraw obj's underlying member method code with example usage: obj.image(box, im, dpi) without return types