最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

如何使用draw.io插件在vscode中一體化導出高質量圖片

 更新時間:2022年08月06日 09:09:23   作者:zdlwhereyougo  
這篇文章主要介紹了draw.io插件在vscode中一體化導出高質量圖片需要的工具是vscode,?draw.io擴展,draw.io桌面版?、python,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒,需要的朋友可以參考下

‘’’
Author: zzx
Date: 2022-07-30 15:52:15
LastEditors: zdl
LastEditTime: 2022-07-30 16:03:20
FilePath: \matlabcodef:\BaiduNetdiskWorkspace\markdown寫雜談\python導出drawio文件
Description:

Copyright © 2022 by zdl, All Rights Reserved.
‘’’

vscode一體化導出drawio

需要的工具:vscode, draw.io擴展,draw.io桌面版 、python

提示:這個方法并沒有簡化流程,只是能夠減少打開窗口,在vscode中直接查看原始文件,導出文件,效率并沒有顯著提升。

啰嗦的部分:
drawio流程圖繪制軟件比visio好用。而且vscode有插件。vs插件的優(yōu)點在于支持mermaid流程圖,缺點非常明顯不支持指定分辨率圖像導出。
網(wǎng)上檢索發(fā)現(xiàn)drawio的桌面版可以在命令行操作。在drawio安裝目錄下運行cmd,然后通過draw.io -help 命令可以查看全部命令。
查看命令發(fā)現(xiàn)沒有針對性的dpi設置。我就想到給圖片輸入寬度和高度的方式。根據(jù)我猜測這個寬度和高度應該對應的就是像素點數(shù)量,所以我就按照實際尺寸,以及dpi的定義
寫了一個命令, 發(fā)現(xiàn)可用。但是每次都要計算寬度、高度、調(diào)用cmd命令窗口,太麻煩。功能強大的python加上插件齊全的vscode能不能全部實現(xiàn)呢?
折騰了幾個小時,終于搞定了。

進入正題:
1、安裝draw.io插件,和桌面版,記住桌面版的路徑
2、繪制好的圖片有一個實際的尺寸,記住實際尺寸的寬和高
3、python轉換 寬度

dpivalue=600#dpi
realwidth=89.4#mm
realheight=81.2#mm
width=round(dpivalue*realwidth/25.4)
height=round(dpivalue*realheight/25.4)

4、 構造命令行,不嫌麻煩可以自己寫完整目錄

inputfilepath=r'F:\BaiduNetdiskWorkspace\00typora\大論文\drawio\算法流程圖.drawio'
outputfilepath=r'F:\BaiduNetdiskWorkspace\00typora\大論文\drawio\test.png'
starttext=r'draw.io -x '
midletext=r" -f png -t --width "+str(width)+r" --height " +str(height)+r" -o "
commandtext1=starttext+inputfilepath+midletext+outputfilepath

5、 改變python文件工作目錄并執(zhí)行命令

path="D:/draw.io/"#安裝文件夾
os.chdir( path )# 修改當前工作目錄
v2=os.system(commandtext1)

完整的代碼

代碼量并不大,非常簡單

'''
Author: zzx
Date: 2022-07-27 10:12:38
LastEditors: zdl
LastEditTime: 2022-07-30 16:10:22
FilePath: \matlabcodef:\BaiduNetdiskWorkspace\00typora\大論文\drawio\output.py
Description: 

Copyright (c) 2022 by zdl, All Rights Reserved. 
'''
import os
dpivalue=600#dpi
realwidth=89.4#mm
realheight=81.2#mm
width=round(dpivalue*realwidth/25.4)
height=round(dpivalue*realheight/25.4)
inputfilepath=r'F:\BaiduNetdiskWorkspace\00typora\大論文\drawio\算法流程圖.drawio'
outputfilepath=r'F:\BaiduNetdiskWorkspace\00typora\大論文\drawio\test.png'
starttext=r'draw.io -x '
midletext=r" -f png -t --width "+str(width)+r" --height " +str(height)+r" -o "
commandtext1=starttext+inputfilepath+midletext+outputfilepath
path="D:/draw.io/"#安裝文件夾
os.chdir( path )# 修改當前工作目錄
v2=os.system(commandtext1)

# 快速運行F5
# print(v2)

#關于python權限的問題
# https://blog.csdn.net/qq_33731081/article/details/103812749
# 如何在python中運行命令行命令
# https://blog.csdn.net/qq_34769162/article/details/119037908
#報錯為空值的問題
# https://blog.csdn.net/xiaoxiaogh/article/details/88320102

#關于drawio導出命令,靈感來源https://j2r2b.github.io/2019/08/06/drawio-cli.html
'''
Options:
  -V, --version                      output the version number
  -c, --create                       creates a new empty file if no file is
                                     passed
  -k, --check                        does not overwrite existing files
  -x, --export                       export the input file/folder based on the
                                     given options
  -r, --recursive                    for a folder input, recursively convert
                                     all files in sub-folders also
  -o, --output <output file/folder>  specify the output file/folder. If
                                     omitted, the input file name is used for
                                     output with the specified format as
                                     extension
  -f, --format <format>              if output file name extension is
                                     specified, this option is ignored (file
                                     type is determined from output extension,
                                     possible export formats are pdf, png, jpg,
                                     svg, vsdx, and xml) (default: "pdf")
  -q, --quality <quality>            output image quality for JPEG (default:
                                     90)
  -t, --transparent                  set transparent background for PNG
  -e, --embed-diagram                includes a copy of the diagram (for PNG,
                                     SVG and PDF formats only)
  --embed-svg-images                 Embed Images in SVG file (for SVG format
                                     only)
  -b, --border <border>              sets the border width around the diagram
                                     (default: 0)
  -s, --scale <scale>                scales the diagram size
  --width <width>                    fits the generated image/pdf into the
                                     specified width, preserves aspect ratio.
  --height <height>                  fits the generated image/pdf into the
                                     specified height, preserves aspect ratio.
  --crop                             crops PDF to diagram size
  -a, --all-pages                    export all pages (for PDF format only)
  -p, --page-index <pageIndex>       selects a specific page, if not specified
                                     and the format is an image, the first page
                                     is selected
  -g, --page-range <from>..<to>      selects a page range (for PDF format only)
  -u, --uncompressed                 Uncompressed XML output (for XML format
                                     only)
  --enable-plugins                   Enable Plugins
  -h, --help                         display help for command
'''

到此這篇關于draw.io插件在vscode中一體化導出高質量圖片的文章就介紹到這了,更多相關draw.io vscode一體化導出圖片內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:

相關文章

  • Python實現(xiàn)在一行中交換兩個變量

    Python實現(xiàn)在一行中交換兩個變量

    這篇文章主要為大家詳細介紹了如何利用Python語言實現(xiàn)在一行中交換兩個變量功能,文中的示例代碼講解詳細,感興趣的小伙伴可以了解一下
    2022-08-08
  • PyCharm接入DeepSeek實現(xiàn)AI編程的操作流程

    PyCharm接入DeepSeek實現(xiàn)AI編程的操作流程

    DeepSeek 是一家專注于人工智能技術研發(fā)的公司,致力于開發(fā)高性能、低成本的 AI 模型,接下來,我們把DeepSeek接入到PyCharm中,并利用其能力輔助我們進行代碼開發(fā),感興趣的小伙伴跟著小編一起來看看吧
    2025-01-01
  • Python字符串拼接的幾種方法整理

    Python字符串拼接的幾種方法整理

    這篇文章主要介紹了Python字符串拼接的幾種方法整理的相關資料,這里提供了五種方法及實現(xiàn),需要的朋友可以參考下
    2017-08-08
  • 用Python生成N層的楊輝三角的實現(xiàn)方法

    用Python生成N層的楊輝三角的實現(xiàn)方法

    這篇文章主要介紹了用Python生成N層的楊輝三角的實現(xiàn)方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2021-04-04
  • 以SQLite和PySqlite為例來學習Python DB API

    以SQLite和PySqlite為例來學習Python DB API

    本文將以SQLite和PySqlite為例來學習Python DB API,pysqlite是一個sqlite為python 提供的api接口,它讓一切對于sqlit的操作都變得異常簡單
    2020-02-02
  • Python中使用Lambda函數(shù)的5種用法

    Python中使用Lambda函數(shù)的5種用法

    這篇文章主要介紹了Python中使用Lambda函數(shù)的5種用法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-04-04
  • Python+uiautomator2實現(xiàn)手機鎖屏解鎖功能

    Python+uiautomator2實現(xiàn)手機鎖屏解鎖功能

    python-uiautomator2封裝了谷歌自帶的uiautomator2測試框架,提供便利的python接口,這篇文章給大家介紹使用Python+uiautomator2實現(xiàn)手機鎖屏解鎖(期望輸入的鎖屏密碼,基于滑動解鎖),感興趣的朋友一起看看吧
    2021-04-04
  • 解決Python報錯Valueerror: Expected 2d Array Got 1d Array Instead

    解決Python報錯Valueerror: Expected 2d Array 

    如您所知,每種編程語言都會遇到很多錯誤,有些是在運行時,有些是在編譯時,下面我就來看看當發(fā)生錯誤 ValueError: Expected 2D array, got 1D array instead時該如何解決吧
    2024-01-01
  • Python實現(xiàn)繪制雙柱狀圖并顯示數(shù)值功能示例

    Python實現(xiàn)繪制雙柱狀圖并顯示數(shù)值功能示例

    這篇文章主要介紹了Python實現(xiàn)繪制雙柱狀圖并顯示數(shù)值功能,涉及Python數(shù)值運算及基于matplotlib的圖形繪制相關操作技巧,需要的朋友可以參考下
    2018-06-06
  • python搶購軟件/插件/腳本附完整源碼

    python搶購軟件/插件/腳本附完整源碼

    這篇文章主要介紹了python搶購軟件/插件/腳本附完整源碼,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-03-03

最新評論

班戈县| 日照市| 弥勒县| 平邑县| 石首市| 霍城县| 二连浩特市| 宾川县| 德昌县| 梅州市| 垫江县| 武陟县| 阳春市| 广安市| 常山县| 宁强县| 天柱县| 长春市| 西乌| 磐石市| 山阳县| 邵阳市| 翁牛特旗| 彝良县| 小金县| 彩票| 永顺县| 河间市| 焦作市| 白水县| 辽源市| 宜城市| 定日县| 呼玛县| 弋阳县| 清苑县| 绥芬河市| 临沭县| 汉川市| 兴文县| 镇坪县|