Randomly crop image.

    image, size, seed=0, seed2=0, name=None

size is a 1-D int64 tensor with 2 elements representing the crop height and width. The values must be non negative.

This Op picks a random location in image and crops a height by width rectangle from that location. The random location is picked so the cropped area will fit inside the original image.


  • image: A Tensor. Must be one of the following types: uint8, int8, int16, int32, int64, float32, float64. 3-D of shape [height, width, channels].
  • size: A Tensor of type int64. 1-D of length 2 containing: crop_height, crop_width..
  • seed: An optional int. Defaults to 0. If either seed or seed2 are set to be non-zero, the random number generator is seeded by the given seed. Otherwise, it is seeded by a random seed.
  • seed2: An optional int. Defaults to 0. An second seed to avoid seed collision.
  • name: A name for the operation (optional).


A Tensor. Has the same type as image.