Skip to content

Instantly share code, notes, and snippets.

@Collonville
Created September 27, 2019 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Collonville/3681682b54093d390fde56f7f90b8a6b to your computer and use it in GitHub Desktop.
Save Collonville/3681682b54093d390fde56f7f90b8a6b to your computer and use it in GitHub Desktop.
Resize and 0 padding using tensorflow
tf_image = tf.io.decode_image(image, channels=3)
tf_image = tf.compat.v1.image.resize_image_with_pad(tf_image, 256, 512)
out = tf.cast(tf_image, tf.uint8)
out = tf.image.encode_jpeg(out, format="rgb", quality=100)
# out = tf.io.write_file("test.jpeg", out)
with tf.Session() as sess:
jpeg_byte = sess.run(out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment