code: def test_write(self):
      filename = os_helper.TESTFN
      import locale
  
      if locale.getlocale()[0] is None:
          # Tcl uses Latin1 in the C locale
          filename = os_helper.TESTFN_ASCII
      image = self.create()
      self.addCleanup(os_helper.unlink, filename)
  
      image.write(filename)
      image2 = tkinter.PhotoImage(
          "::img::test2", master=self.root, format="ppm", file=filename
      )
      self.assertEqual(str(image2), "::img::test2")
      self.assertEqual(image2.type(), "photo")
      self.assertEqual(image2.width(), 16)
      self.assertEqual(image2.height(), 16)
      self.assertEqual(image2.get(0, 0), image.get(0, 0))
      self.assertEqual(image2.get(15, 8), image.get(15, 8))
  
      image.write(filename, format="gif", from_coords=(4, 6, 6, 9))
      image3 = tkinter.PhotoImage(
          "::img::test3", master=self.root, format="gif", file=filename
      )
      self.assertEqual(str(image3), "::img::test3")
      self.assertEqual(image3.type(), "photo")
      self.assertEqual(image3.width(), 2)
      self.assertEqual(image3.height(), 3)
      self.assertEqual(image3.get(0, 0), image.get(4, 6))
      self.assertEqual(image3.get(1, 2), image.get(5, 8))
  
imports: import unittest
  import tkinter
  from test import support
  from test.support import os_helper
  from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest, requires_tk
label_desc: Use image node_id 27 for calling the PhotoImageTest obj's underlying member method code with example usage: obj.test_write() without return types