def tm_paste_image_from_clipboard(self, img_label):
rand = hex(random.randint(0, 1000000000)).replace('0x', '')
img_path = os.path.normpath(os.path.join(self.db_chat.tmp_folder, ('tmp_image_' + rand + '.png')))
clipboard = QtGui.QApplication.clipboard()
img = clipboard.image()
if img:
img.save(img_path)
cmd = '%s %s -resize 300 %s' % (os.path.normpath(self.db_chat.convert_exe), img_path, img_path)
cmd2 = '%s %s -resize 300x300 %s' % (os.path.normpath(self.db_chat.convert_exe), img_path, img_path)
cmd3 = '\"%s\" \"%s\" -resize 300 \"%s\"' % (os.path.normpath(self.db_chat.convert_exe), img_path, img_path)
print(cmd)
print(cmd2)
print(cmd3)
try:
os.system(cmd)
except:
try:
os.system(cmd2)
except:
try:
os.system(cmd3)
except:
return(False, 'in tm_paste_image_from_clipboard - problems with conversion resize.png')
else:
self.message('Cannot Image!', 2)
return(False, 'Cannot Image!')
image = QtGui.QImage(img_path)
img_label.setPixmap(QtGui.QPixmap.fromImage(image))
self.makePreviewDialog.img_path = img_path
评论列表
文章目录