python - Decoding then encoding a jpeg file will cause the output to be rotated if there is Orientation exif metadata on the source jpeg -
the example here stripped-down version of upscaling program wrote while trying learn how use tensorflow. if feed image has orientation exif metadata (my test image has rotate 270 cw) output image rotated if "correct" orientation. doesn't seem documented anywhere.
is there way prevent happening, either passing in flag or value decode_jpeg / encode_jpeg functions, or stripping out metadata beforehand?
"use tensorflow decode encode image @ hard-coded location , save result second hard-coded location." import tensorflow tf def main(): "use tensorflow decode encode image @ hard-coded location , save result second hard-coded location." sess = tf.session() image_decoded = tf.image.decode_jpeg(tf.read_file('d:\\tensorflow\\upscaling\\c890faa477.jpg'), channels=3) fname = tf.constant('d:\\tensorflow\\upscaling\\c890faa477_dec_enc.jpg') enc = tf.image.encode_jpeg(tf.cast(image_decoded, tf.uint8)) fwrite = tf.write_file(fname, enc) sess.run(fwrite) return main()
it turns out had backward. both windows explorer , default photo viewer automatically applying rotation, , flipping width / height values match new rotation. nothing python or tensorflow.
Comments
Post a Comment