9q13nh 发表于 2024-7-26 15:47:52

加强效率!早早下班!Sharp+Picgo实现压缩后上传并替换外链的命令行工具


    <h2 style="color: black; text-align: left; margin-bottom: 10px;">引言</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">大众</span>好啊, 我是枣把儿!</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">近期</span>写作比较多,而要发平台又好几个,<span style="color: black;">插进</span><span style="color: black;">照片</span>的时候就很不方便。一<span style="color: black;">起始</span>我是白嫖掘金的<span style="color: black;">照片</span><span style="color: black;">位置</span>,<span style="color: black;">然则</span><span style="color: black;">每一个</span>平台都会自动打个水印上去...</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">于是我又把之前写的命令行工具拿出来翻新了<span style="color: black;">有些</span>,加入了Sharp<span style="color: black;">照片</span>压缩、Picgo上传图床、markdown文件内容替换这三大内容,<span style="color: black;">极重</span>的改善了我的<span style="color: black;">发帖</span>体验,并且感觉在<span style="color: black;">平常</span>中<span style="color: black;">亦</span>比较实用。和<span style="color: black;">大众</span>分享一下~</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">功能一览</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1.&nbsp;国际化文件翻译 -&nbsp;<strong style="color: blue;">translate</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1.&nbsp;<span style="color: black;">日前</span>用于<span style="color: black;">机构</span>内部批量翻译国际化文件, <span style="color: black;">因此</span>需要遵循<span style="color: black;">必定</span>的规则</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2.&nbsp;基于百度翻译, 需要自定义自己的appId和key</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3.&nbsp;支持指定单个文件翻译</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">4.&nbsp;支持指定文件夹, 批量翻译所有文件</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">2.</span><span style="color: black;">压缩文件 -&nbsp;</span><strong style="color: blue;">tiny</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp; 1.&nbsp;基于<span style="color: black;">sharp</span>, sharp支持的文件(png/jpeg/jpg/gif等等)都<span style="color: black;">能够</span>压缩</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp; 2.&nbsp;输出目录: 所有参数下, 压缩后文件都会输出到同级目录中</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3.&nbsp;输出时<span style="color: black;">表示</span><span style="color: black;">体积</span>及压缩比例 如: ✔ 190.4 KB =&gt; 115.2 KB (↓39.52%)【 demo1-zz-tiny-1702631665830.gif 】</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp; 4.&nbsp;支持自定义名<span style="color: black;">叫作</span>输出 --name=xxx.png</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp; 5.&nbsp;支持自定义压缩质量 --quality=70 (1-100)</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp; 6.&nbsp;支持单个文件压缩 --file=xxx.png</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp; 7.&nbsp;支持批量文件压缩</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;模糊匹配 所有<span style="color: black;">包括</span>abc且支持的文件类型都会被压缩</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;<span style="color: black;">倘若</span><span style="color: black;">无</span>指定--dir , 则--condition会在当前目录下<span style="color: black;">查询</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;模糊匹配到的内容, 会标红处理</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;支持相对路径</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;支持绝对路径</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;指定文件夹 --dir=./demo (基于当前命令运行的目录)</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;指定文件名 --condition=abc</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;若批量压缩时, 指定了name(第四条), 则自定义名<span style="color: black;">叫作</span>后会自动拼接一个序号, 避免覆盖</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">8.&nbsp;<strong style="color: blue;">支持和picgo联动, 压缩完后直接上传到图床</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1.&nbsp;需要先安装picgo, <span style="color: black;">起步</span>, 并配置好图床配置</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2.&nbsp;限制文件<span style="color: black;">体积</span>, 超过 max 的文件不会被上传</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3.&nbsp;<span style="color: black;">经过</span> Picgo 上传到图床 -&nbsp;<strong style="color: blue;">picgo</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1.&nbsp;支持指定文件 -f 上传</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2.&nbsp;支持指定文件夹 -d 批量上传<span style="color: black;">所有</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3.&nbsp;支持限制<span style="color: black;">体积</span> -m 默认只上传60kb以内的<span style="color: black;">照片</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">4.&nbsp;支持模糊匹配 -co 文件名中含有co的<span style="color: black;">照片</span>, 且满足<span style="color: black;">体积</span>限制, 都会被上传</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">4. 究极联动:&nbsp;<strong style="color: blue;">tiny压缩 -&gt; 自动传给picgo -&gt; 自动把obsidian里的本地<span style="color: black;">照片</span>链接替换为上传后的url</strong></p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">安装</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">先安装<span style="color: black;">sharp</span>的两个前置依赖包。@img/<span style="color: black;">sharp-darwin-arm64@0.33.0</span>&nbsp;、 @img/<span style="color: black;">sharp-win32-x64@0.33.0</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">我的系统是macos M2,<span style="color: black;">因此</span>需要安装@img/sharp-darwin-arm64</p>npm&nbsp;i&nbsp;-g&nbsp;@img/sharp-darwin-arm64@0.33.0<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">windows10/11 (win32-x64)用户请安装 @img/<span style="color: black;">sharp-win32-x64@0.33.0</span></p>&nbsp;npm&nbsp;i&nbsp;-g&nbsp;@img/sharp-win32-x64@0.33.0<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">而后</span>安装工具本体</p>npm&nbsp;i&nbsp;-g&nbsp;zzoffduty-cli@latest<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">运行 -h <span style="color: black;">瞧瞧</span><span style="color: black;">是不是</span>成功</p>zz&nbsp;-h<h2 style="color: black; text-align: left; margin-bottom: 10px;">tiny命令 实现压缩</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">运用</span>help命令查看所有支持的功能</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">zz&nbsp;tiny&nbsp;--help</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;-f,&nbsp;--file&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;要压缩的<span style="color: black;">照片</span>文件&nbsp;(default:&nbsp;null)
    </p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;-d,&nbsp;--dir&nbsp;</p>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;压缩文件夹内所有文件&nbsp;(default:&nbsp;null)
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;-co,&nbsp;--condition&nbsp;压缩文件夹内所有名<span style="color: black;">叫作</span><span style="color: black;">包括</span>[--condition]的<span style="color: black;">照片</span>文件&nbsp;(default:&nbsp;null)
    </p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;-q,&nbsp;--quality&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;压缩质量(1-100)&nbsp;(default:&nbsp;75)
    </p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;-c,&nbsp;--colours&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GIF色彩<span style="color: black;">保存</span>(2-256)&nbsp;(default:&nbsp;128)
    </p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;-n,&nbsp;--name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;指定文件名输出&nbsp;(default:&nbsp;"")
    </p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;-m,&nbsp;--max&nbsp;限制要上传的文件<span style="color: black;">体积</span>(kb)(仅当开启&nbsp;--picgo&nbsp;时会用到)&nbsp;(default:&nbsp;50)
    </p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;--picgo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;调用picgo&nbsp;(无参数)&nbsp;(default:&nbsp;null)</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">--no-picgo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;不调用picgo&nbsp;(无参数)&nbsp;(default:&nbsp;null)</p>&nbsp;&nbsp;-h,&nbsp;--help&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display&nbsp;help&nbsp;for&nbsp;command<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">压缩功能演示:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;指定目录压缩,并指定名<span style="color: black;">叫作</span>输出</p><img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQEdVxkE0ruFmJDDjr4S9ahomXt8IpbxnpARPoMibdLa9ZQ7Kn9OxpDxHg21b3rHZ3xiaEmy4TL5TKgw/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">picgo命令 实现上传图床</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">PicGo在2.2.0版本<span style="color: black;">起始</span>内置了一个小型的服务器,用于接收来自其他应用的HTTP请求来上传<span style="color: black;">照片</span>。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">默认监听<span style="color: black;">位置</span>:&nbsp;127.0.0.1,默认监听端口:36677</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">以POST请求去上传</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;method:&nbsp;POST</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;url:&nbsp;http://127.0.0.1:36677/upload&nbsp;(此处以默认配置为例)</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;request body:&nbsp;{list: }&nbsp;必须是JSON格式</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">返回的数据:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">{</p>&nbsp;&nbsp;<span style="color: black;">"success"</span>:&nbsp;<span style="color: black;">true</span>,&nbsp;<span style="color: black;">//&nbsp;or&nbsp;false</span>&nbsp;&nbsp;<span style="color: black;">"result"</span>:&nbsp;[<span style="color: black;">"url"</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">]</p>}<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">因此</span><strong style="color: blue;">此功能<span style="color: black;">经过</span>Http请求的方式调用Picgo Server, <span style="color: black;">因此</span>需要本地<span style="color: black;">已然</span>安装并<span style="color: black;">起步</span>Picgo, 并<span style="color: black;">已然</span>配置好了图床</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span><span style="color: black;">运用</span>picgo-core的话,手动配置json文件我觉得更痛苦<span style="color: black;">有些</span>。<span style="color: black;">因此</span>还是基于<span style="color: black;">已然</span>有了Picgo客户端的<span style="color: black;">状况</span>下,简化<span style="color: black;">有些</span>流程</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">运用</span>help命令查看所有支持的功能</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Options:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;-f,&nbsp;--file&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;要上传的<span style="color: black;">照片</span>文件&nbsp;(default:&nbsp;null)
    </p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;-d,&nbsp;--dir&nbsp;</p>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;上传文件夹内所有<span style="color: black;">照片</span>文件&nbsp;(default:&nbsp;null)
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;-co,&nbsp;--condition&nbsp;上传文件夹内所有名<span style="color: black;">叫作</span><span style="color: black;">包括</span>[--condition]的<span style="color: black;">照片</span>文件&nbsp;(default:&nbsp;null)
    </p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;-m,&nbsp;--max&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;大于指定<span style="color: black;">体积</span>(kb)的<span style="color: black;">照片</span>不会被上传&nbsp;(default:&nbsp;50)
    </p>&nbsp;&nbsp;-h,&nbsp;--help&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display&nbsp;help&nbsp;for&nbsp;command<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">上传文件夹内所有<span style="color: black;">体积</span>符合限制的<span style="color: black;">照片</span>文件</p><img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQEdVxkE0ruFmJDDjr4S9aho0EueGnZL2whSPNbnfS9mwLibU5STvSWOPkI4EkLeNgJr4v7ZiaPVQDdA/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">上传所有名<span style="color: black;">叫作</span>中含有指定文字且<span style="color: black;">体积</span>符合限制的<span style="color: black;">照片</span>文件。<span style="color: black;">无</span>匹配到会有提示</p><img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQEdVxkE0ruFmJDDjr4S9ahoUSHjb0U9d6KZ4vgq3cYZp9rxIMfMcHqIz3ItVibSJxpiaqyh0dSgwmgg/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">tiny 联动 picgo</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在tiny命令后<span style="color: black;">运用</span>--picgo 开启压缩后调用picgo</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;压缩单个<span style="color: black;">照片</span>文件 并 <span style="color: black;">经过</span>picgo上传 (<span style="color: black;">这儿</span><span style="color: black;">亦</span>校验了max)</p>zz&nbsp;tiny&nbsp;-f&nbsp;./demo/demo2.png&nbsp;--picgo<img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQEdVxkE0ruFmJDDjr4S9aho3L61m1CorADzLvJdhlBRIr379WzIicR5TTPktIhic1Y3FqG3eNR7V2AQ/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;压缩文件夹内所有<span style="color: black;">照片</span>文件,并<span style="color: black;">经过</span>picgo上传所有符合<span style="color: black;">体积</span>限制的<span style="color: black;">照片</span>文件</p>zz&nbsp;tiny&nbsp;-d&nbsp;./demo&nbsp;--picgo<img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQEdVxkE0ruFmJDDjr4S9aholvPBhTx8fXt47ibiaOmhRxwb33wkP6a5r1le7hKiaFPVCkNzcYZd6rtJA/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;压缩文件夹内名<span style="color: black;">叫作</span>含有指定文字的,且符合<span style="color: black;">体积</span>限制的<span style="color: black;">照片</span>,并<span style="color: black;">经过</span>picgo上传</p>zz&nbsp;tiny&nbsp;-d&nbsp;./demo&nbsp;-co&nbsp;mo2&nbsp;--picgo<img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQEdVxkE0ruFmJDDjr4S9ahob3LaWopsfEpMuqROOrXyDqauibn4THXF3QYzJ1vXibcrbpw2KaU7e1Tg/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;压缩文件夹内名<span style="color: black;">叫作</span>含有指定文字的,且符合<span style="color: black;">体积</span>限制的<span style="color: black;">照片</span>,并指定输出的文件名,并<span style="color: black;">经过</span>picgo上传</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">ps: <span style="color: black;">由于</span>名<span style="color: black;">叫作</span>含有指定文字这个指令是个批量操作,<span style="color: black;">因此</span>输出文件名必定会带一个后缀防止重复</p>zz&nbsp;tiny&nbsp;-d&nbsp;./demo&nbsp;-co&nbsp;mo2&nbsp;-n&nbsp;自定义&nbsp;--picgo<img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQEdVxkE0ruFmJDDjr4S9ahoVOM38FNjQmkmc56aFAQZWdr5ttSDumtzU56BBRrSPRFrvicSSP8OM0g/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">究极联动,一条龙服务</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">压缩 =&gt; 上传 =&gt; 自动替换markdown<span style="color: black;">照片</span>链接</p>./src/index.js&nbsp;tiny&nbsp;-d&nbsp;./demo/md/配图&nbsp;--picgo&nbsp;--replace&nbsp;-ref&nbsp;./demo/md/demo4.md<img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQEdVxkE0ruFmJDDjr4S9ahoz7tibO0lfc01hCXQNMiaIUwS3zp12NbTXI3icWtXc8uYg96BzUWMSFs6w/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">此命令<span style="color: black;">日前</span>支持替换Obsidian里的Wiki链接, 即&nbsp;![]&nbsp;如下图所示:</p><img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQEdVxkE0ruFmJDDjr4S9ahob5lLk0ribsia8Rl5flO5Q9wzNcNJicHIeZU1bWgzYRKrFbrp0zZO6JkmA/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">被压缩的<span style="color: black;">照片</span>里只要有demo2.png 就会替换成demo2.png压缩后的,上传到图床的url。&nbsp;![]&nbsp;替换为&nbsp;![](http://www.baidu.com/demo2.png)</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">尤其</span><span style="color: black;">重视</span>,有<span style="color: black;">有些</span>Obsidian配置的前置<span style="color: black;">要求</span>:</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1. 需要开启Wiki链接。<span style="color: black;">由于</span><span style="color: black;">日前</span>版本我<strong style="color: blue;">只实现了替换wiki链接对应的文本</strong></p><img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQEdVxkE0ruFmJDDjr4S9ahoNyly4z2hovmHjScibVoWaKmQvZfHujelR6xkPoqv8bauTwYkfIJM6Xw/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2. Obsidian默认<span style="color: black;">状况</span>下,粘贴来的<span style="color: black;">照片</span>会<span style="color: black;">表示</span>成 paste img 2023123123.png 这种格式。<span style="color: black;">因此</span><span style="color: black;">意见</span>安装 paste image rename 这个插件。<span style="color: black;">原由</span>是:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;<span style="color: black;">由于</span>它名<span style="color: black;">叫作</span>自带空格,和命令行工具<span style="color: black;">没法</span>兼容!<span style="color: black;">倘若</span>你批量上传过程中,有一个文件不符合<span style="color: black;">体积</span>限制,<span style="color: black;">无</span>被上传,<span style="color: black;">亦</span>没被替换。此时你想<span style="color: black;">运用</span>zz tiny -f ./paste img 2023123123.png -m 100 --picgo --repalce -ref ../xxx.md&nbsp;继续放大限制,上传+替换时,文件就<span style="color: black;">没法</span>被解析了!</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">•&nbsp;<span style="color: black;">况且</span>本身的名字比较长,<span style="color: black;">欠好</span>找</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">以下是我的插件配置</span></p><img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQGZmrSdjopZiatBCYTAg6oIhWSVcEq1RC3YwMBfXoN8q3oF8seg4LjYSPOk5J6lcyMRxiakNiavxlIgg/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">当我截图后粘贴到md中时<span style="color: black;">表示</span>如下:</p><img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQEdVxkE0ruFmJDDjr4S9aho7v5ZJ2w32qG4xLqtnzLmfKw3tgib1uiaHsufMhwGVGibJRfn2P5XgLeow/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在粘贴<span style="color: black;">照片</span>时,文件存放路径配置:</p><img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQEdVxkE0ruFmJDDjr4S9aho3WZsjW1ZokFUWpvaZAaeE7xp6ZWcIkpPL1aHby4RNUA1QquFNtU4UA/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在目录中展示为:</p><img src="https://mmbiz.qpic.cn/mmbiz_png/IM4e61UWjQEdVxkE0ruFmJDDjr4S9ahoYicR56uGUGLeDqhwcAJNahUJUeRs4RpyMvWc2Bib8EfCHI1wEIu4FOuA/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">ok,以上<span style="color: black;">便是</span>我的obsidian配置,及我是<span style="color: black;">怎样</span><span style="color: black;">运用</span>zzoffduty-cli的<span style="color: black;">所有</span>内容!</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">zz tiny -d ./&nbsp;-q 60&nbsp;-m 100&nbsp;--picgo --replace -ref ../

不锈钢厂家 发表于 2024-8-24 12:54:47

“沙发”(SF,第一个回帖的人)‌

nqkk58 发表于 2024-10-11 19:00:57

i免费外链发布平台 http://www.fok120.com/

nqkk58 发表于 2024-10-19 17:22:58

你的话深深触动了我,仿佛说出了我心里的声音。

m5k1umn 发表于 2024-11-5 09:10:29

我们有着相似的经历,你的感受我深有体会。
页: [1]
查看完整版本: 加强效率!早早下班!Sharp+Picgo实现压缩后上传并替换外链的命令行工具