<p dir="auto"><code class="notranslate">resize_image_with_crop_or_pad()</code> should work for multiple images (batch of images) similar to <code class="notranslate">tf.image.resize_images()</code></p>
<p dir="auto">Because <code class="notranslate">tf.image.resize_image_with_crop_or_pad()</code> requires its input to have a fully defined shape, it's not useful as part of an input pipeline since the size of images loaded will not be known in advance.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="  queue = tf.train.string_input_producer(filenames)
  reader = tf.WholeFileReader()
  _, contents = reader.read(queue)
  image = tf.image.decode_jpeg(contents, channels=3)
  cropped = tf.image.resize_image_with_crop_or_pad(image, 224, 224)"><pre class="notranslate">  <span class="pl-s1">queue</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">train</span>.<span class="pl-en">string_input_producer</span>(<span class="pl-s1">filenames</span>)
  <span class="pl-s1">reader</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-v">WholeFileReader</span>()
  <span class="pl-s1">_</span>, <span class="pl-s1">contents</span> <span class="pl-c1">=</span> <span class="pl-s1">reader</span>.<span class="pl-en">read</span>(<span class="pl-s1">queue</span>)
  <span class="pl-s1">image</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">image</span>.<span class="pl-en">decode_jpeg</span>(<span class="pl-s1">contents</span>, <span class="pl-s1">channels</span><span class="pl-c1">=</span><span class="pl-c1">3</span>)
  <span class="pl-s1">cropped</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">image</span>.<span class="pl-en">resize_image_with_crop_or_pad</span>(<span class="pl-s1">image</span>, <span class="pl-c1">224</span>, <span class="pl-c1">224</span>)</pre></div>
<p dir="auto">Ideally the above would work...</p>