#!/usr/bin/env python # coding: utf-8 # In[1]: #change image file extension import cv2 import os import matplotlib.pyplot as plt # 実行 num = 0 while num == 0: fname = input("Filen name of input image with the extension: ") path = fname is_file = os.path.isfile(path) if is_file: fn = fname.split('.')[0] fe = fname.split('.')[1] break else: print('Not find the file name') #画像の読み込み(input filenの名前:input.xxx) img = cv2.imread(fname) plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)) #画像の表示 #plt.show() #出力画像の拡張子 outext = input("Input extension type for output image: ") cv2.imwrite(fn + '.' + outext,img) # In[ ]: import os os._exit(00) # In[ ]: