def tm_save_preview_image_action(self, window):
# self.preview_img_path
if not os.path.exists(self.db_chat.preview_img_path):
try:
os.mkdir(self.db_chat.preview_img_path)
except:
print(self.db_chat.preview_img_path)
# copyfile
save_path = os.path.join(self.db_chat.preview_img_path, (self.current_task['asset'] + '.png'))
icon_path = os.path.join(self.db_chat.preview_img_path, (self.current_task['asset'] + '_icon.png'))
tmp_icon_path = window.img_path.replace('.png','_icon.png')
# -- copy
shutil.copyfile(window.img_path, save_path)
# -- resize
cmd = '%s %s -resize 100 %s' % (os.path.normpath(self.db_chat.convert_exe), window.img_path, tmp_icon_path)
cmd2 = '%s %s -resize 100x100 %s' % (os.path.normpath(self.db_chat.convert_exe), window.img_path, tmp_icon_path)
cmd3 = '\"%s\" \"%s\" -resize 100 \"%s\"' % (os.path.normpath(self.db_chat.convert_exe), window.img_path, tmp_icon_path)
try:
os.system(cmd)
except:
try:
os.system(cmd2)
except:
try:
os.system(cmd3)
except:
self.message('problems with conversion _icon.png', 2)
return(False, 'in tm_save_preview_image_action - problems with conversion resize.png')
shutil.copyfile(tmp_icon_path, icon_path)
# load to preview image_label
image = QtGui.QImage(save_path)
self.myWidget.image_label.setPixmap(QtGui.QPixmap.fromImage(image))
self.close_window(window)
# ------ show tz ------------
评论列表
文章目录