mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-25 18:20:24 +08:00
Added: clipboard image handler for picgo-core
This commit is contained in:
16
static/linux.sh
Normal file
16
static/linux.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
# from https://github.com/favers/vscode-qiniu-upload-image/blob/master/lib/linux.sh
|
||||
|
||||
#!/bin/sh
|
||||
|
||||
# require xclip(see http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script/677212#677212)
|
||||
command -v xclip >/dev/null 2>&1 || { echo >&1 "no xclip"; exit 1; }
|
||||
|
||||
# write image in clipboard to file (see http://unix.stackexchange.com/questions/145131/copy-image-from-clipboard-to-file)
|
||||
if
|
||||
xclip -selection clipboard -target image/png -o >/dev/null 2>&1
|
||||
then
|
||||
xclip -selection clipboard -target image/png -o >$1 2>/dev/null
|
||||
echo $1
|
||||
else
|
||||
echo "no image"
|
||||
fi
|
||||
38
static/mac.applescript
Normal file
38
static/mac.applescript
Normal file
@@ -0,0 +1,38 @@
|
||||
-- From https://github.com/mushanshitiancai/vscode-paste-image
|
||||
property fileTypes : {{«class PNGf», ".png"}}
|
||||
|
||||
on run argv
|
||||
if argv is {} then
|
||||
return ""
|
||||
end if
|
||||
|
||||
set imagePath to (item 1 of argv)
|
||||
set theType to getType()
|
||||
|
||||
if theType is not missing value then
|
||||
try
|
||||
set myFile to (open for access imagePath with write permission)
|
||||
set eof myFile to 0
|
||||
write (the clipboard as (first item of theType)) to myFile
|
||||
close access myFile
|
||||
return (POSIX path of imagePath)
|
||||
on error
|
||||
try
|
||||
close access myFile
|
||||
end try
|
||||
return ""
|
||||
end try
|
||||
else
|
||||
return "no image"
|
||||
end if
|
||||
end run
|
||||
|
||||
on getType()
|
||||
repeat with aType in fileTypes
|
||||
repeat with theInfo in (clipboard info)
|
||||
if (first item of theInfo) is equal to (first item of aType) then return aType
|
||||
end repeat
|
||||
end repeat
|
||||
return missing value
|
||||
end getType
|
||||
|
||||
26
static/windows.ps1
Normal file
26
static/windows.ps1
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
param($imagePath)
|
||||
|
||||
# Adapted from https://github.com/octan3/img-clipboard-dump/blob/master/dump-clipboard-png.ps1
|
||||
|
||||
Add-Type -Assembly PresentationCore
|
||||
$img = [Windows.Clipboard]::GetImage()
|
||||
|
||||
if ($img -eq $null) {
|
||||
"no image"
|
||||
Exit 1
|
||||
}
|
||||
|
||||
if (-not $imagePath) {
|
||||
"no image"
|
||||
Exit 1
|
||||
}
|
||||
|
||||
$fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0)
|
||||
$stream = [IO.File]::Open($imagePath, "OpenOrCreate")
|
||||
$encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder
|
||||
$encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($fcb)) | out-null
|
||||
$encoder.Save($stream) | out-null
|
||||
$stream.Dispose() | out-null
|
||||
|
||||
$imagePath
|
||||
Reference in New Issue
Block a user