V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
xuelang
V2EX  ›  OpenAI

GPT4 帮我实现 Mac 图片自动压缩上传 COS

  •  
  •   xuelang ·
    selfboot · 321 天前 · 1009 次点击
    这是一个创建于 321 天前的主题,其中的信息可能已经有所发展或是发生改变。

    把个人博客放在了 netilfy 托管,它给了一个优化建议,可以压缩图片节省带宽。但是每次截图后都要再压缩下图片有点麻烦,于是想着应该可以偷偷懒。目标很明确,截图后图片传到我的 git 仓库 images 目录后,能给我自动压缩,并且上传 COS ,这样我就只用在 markdown 文件里面拼链接就好了。

    效果图

    脚本

    on run {input, parameters}
    	set currentDate to do shell script "date '+%Y%m%d'"
    	tell application "System Events"
    		repeat with i in input
    			set filePath to POSIX path of i
    			set fileExtension to name extension of i
    			set folderName to do shell script "dirname " & filePath
    			if fileExtension is "png" then
    				set fileName to name of i
    				set AppleScript's text item delimiters to "."
    				set baseName to first text item of fileName
    				if baseName does not start with currentDate then
    					do shell script "/opt/homebrew/bin/pngquant --force --ext .png " & quoted form of filePath
    					set newBaseName to currentDate & "_" & baseName
    					set newFileName to newBaseName & "." & fileExtension
    					set name of i to newFileName
    					set newFilePath to folderName & "/" & newFileName
    					set uploadCommand to "/opt/homebrew/Caskroom/miniconda/base/bin/coscmd upload " & quoted form of newFilePath & " /"
    					do shell script uploadCommand
    				end if
    			end if
    		end repeat
    	end tell
    end run
    

    完整内容

    xuelang
        1
    xuelang  
    OP
       321 天前
    V2ex 请求 cos 图片,为啥不带 referer ,这里防盗链白名单加了也没用
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2307 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 16:11 · PVG 00:11 · LAX 09:11 · JFK 12:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.