lineyka_manager.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:lineyka 作者: volodya-renderberg 项目源码 文件源码
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 ------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号