code: def _image_resize(image):
      # resize with decode=False will produce a PNG encoded image
      # (even starting with a decoded image)
      # this behavior is enforced in test/unity/image_util.cxx:test_resize
      # then, we can go through this function again and fall into the above case.
      # while we're resizing (which implies decoding) anyway, let's take
      # the opportunity to reduce the size if it's quite large.
      width = image.width
      height = image.height
      while width > 400:
          width = width / 2
          height = height / 2
  
      # if already in jpeg and the size isn't changing, force a decode/encode
      # to convert to PNG
      if image._format_enum == 0 and width == image.width:
          image = _tc.image_analysis.resize(
              image, width=width, height=height, decode=True
          )
  
      # now resize with decode=False to get PNG
      image = _tc.image_analysis.resize(
          image, width=int(width), height=int(height), decode=False
      )
      assert image._format_enum == 1  # png
  
      return image
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  from ...visualization import _get_client_app_path
  import turicreate
  import subprocess
  import six
  from six.moves import _thread
  import json
  import base64
  import math
label_desc: Use image node_id 8 for calling a global function with example usage: _image_resize(image) and returns: image