code: def read_image(image_name, image_size=None, crop_size=None):
      image = imread(image_name, pilmode="RGB")
  
      if image_size is not None:
          height, width, _ = image.shape
          new_height, new_width = image_size
  
          if height < width:
              # Since width is bigger than height, this scaler
              # factor will say by how much it bigger
              # New width dimension will be scaled in the way
              # that output image will have proportional width and
              # height compae to it's original size
              proportion_scaler = width / height
              image_size = (
                  new_height,
                  int(new_width * proportion_scaler),
              )
          else:
              proportion_scaler = height / width
              image_size = (
                  int(new_height * proportion_scaler),
                  new_width,
              )
  
          image = transform.resize(
              image, image_size, preserve_range=True, mode="constant"
          )
  
      if crop_size is not None:
          height, width, _ = image.shape
          height_slice = slice(
              (height - crop_size[0]) // 2, (height + crop_size[0]) // 2
          )
  
          width_slice = slice(
              (width - crop_size[1]) // 2, (width + crop_size[1]) // 2
          )
  
          image = image[height_slice, width_slice, :]
  
      # (height, width, channel) -> (1, height, width, channel)
      image = np.expand_dims(image, axis=0)
      return asfloat(image)
  
file_path: neupy/examples/cnn/imagenet_tools.py
imports: from __future__ import division
  import os
  import requests
  from tqdm import tqdm
  import numpy
  from imageio import imread
  from skimage import transform
  from neupy.utils import asfloat
label_desc: Use image node_id 2 for calling a global function with example usage: read_image(image_name, image_size, crop_size) and returns: asfloat