code: def _save_netpbm(im, fp, filename):
      # Unused by default.
      # To use, uncomment the register_save call at the end of the file.
      #
      # If you need real GIF compression and/or RGB quantization, you
      # can use the external NETPBM/PBMPLUS utilities.  See comments
      # below for information on how to enable this.
  
      import os
      from subprocess import Popen, check_call, PIPE, CalledProcessError
  
      tempfile = im._dump()
  
      with open(filename, "wb") as f:
          if im.mode != "RGB":
              with open(os.devnull, "wb") as devnull:
                  check_call(
                      ["ppmtogif", tempfile], stdout=f, stderr=devnull
                  )
          else:
              # Pipe ppmquant output into ppmtogif
              # "ppmquant 256 %s | ppmtogif > %s" % (tempfile, filename)
              quant_cmd = ["ppmquant", "256", tempfile]
              togif_cmd = ["ppmtogif"]
              with open(os.devnull, "wb") as devnull:
                  quant_proc = Popen(
                      quant_cmd, stdout=PIPE, stderr=devnull
                  )
                  togif_proc = Popen(
                      togif_cmd,
                      stdin=quant_proc.stdout,
                      stdout=f,
                      stderr=devnull,
                  )
  
              # Allow ppmquant to receive SIGPIPE if ppmtogif exits
              quant_proc.stdout.close()
  
              retcode = quant_proc.wait()
              if retcode:
                  raise CalledProcessError(retcode, quant_cmd)
  
              retcode = togif_proc.wait()
              if retcode:
                  raise CalledProcessError(retcode, togif_cmd)
  
      try:
          os.unlink(tempfile)
      except OSError:
          pass
  
imports: import itertools
  from .None import Image, ImageChops, ImageFile, ImagePalette, ImageSequence
  from ._binary import i8, i16le, o8, o16le
label_desc: Use image node_id 10 for calling a global function with example usage: _save_netpbm(im, fp, filename) without return types