code: def test_resize_with_cropping():
      # This is a regression test for issue # 967
      r = numpy.random.RandomState()
      r.seed(501)
      i, j = numpy.mgrid[0:10, 0:20]
      image = i + j
      mask = r.uniform(size=image.shape) > 0.5
      imask = mask.astype(int)
      cropping = numpy.zeros((30, 40), bool)
      cropping[10:20, 10:30] = True
      workspace, module = make_workspace(
          image,
          cellprofiler.modules.resize.R_BY_FACTOR,
          cellprofiler.modules.resize.I_BILINEAR,
          mask,
          cropping,
      )
      module.resizing_factor_x.value = (
          module.resizing_factor_y.value
      ) = 0.5
      module.run(workspace)
      result = workspace.image_set.get_image(OUTPUT_IMAGE_NAME)
      assert tuple(result.mask.shape) == (5, 10)
      assert tuple(result.crop_mask.shape) == (5, 10)
      x = result.crop_image_similarly(
          numpy.zeros(result.crop_mask.shape)
      )
      assert tuple(x.shape) == (5, 10)
  
imports: import io
  import numpy
  import numpy.testing
  import skimage.exposure
  import skimage.transform
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  import cellprofiler.modules.resize
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.preferences
  import cellprofiler_core.workspace
  import tests.frontend.modules
label_desc: Use image node_id 12 for calling a global function with example usage: test_resize_with_cropping() without return types