🐛 Fix(custom): fix uppercase issue

This commit is contained in:
Kuingsmile
2026-01-25 17:22:03 +08:00
parent 800c9be311
commit 9c78c54800
16 changed files with 82 additions and 82 deletions

View File

@@ -1,26 +1,26 @@
param($imagePath) param($imagePath)
# Adapted from https://github.com/octan3/img-clipboard-dump/blob/master/dump-clipboard-png.ps1 # Adapted from https://github.com/octan3/img-clipboard-dump/blob/master/dump-clipboard-png.ps1
Add-Type -Assembly PresentationCore Add-Type -Assembly PresentationCore
$img = [Windows.Clipboard]::GetImage() $img = [Windows.Clipboard]::GetImage()
if ($img -eq $null) { if ($img -eq $null) {
"no image" "no image"
Exit 1 Exit 1
} }
if (-not $imagePath) { if (-not $imagePath) {
"no image" "no image"
Exit 1 Exit 1
} }
$fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0) $fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0)
$stream = [IO.File]::Open($imagePath, "OpenOrCreate") $stream = [IO.File]::Open($imagePath, "OpenOrCreate")
$encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder $encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder
$encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($fcb)) | out-null $encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($fcb)) | out-null
$encoder.Save($stream) | out-null $encoder.Save($stream) | out-null
$stream.Dispose() | out-null $stream.Dispose() | out-null
$imagePath $imagePath

View File

@@ -1,45 +1,45 @@
# Adapted from https://github.com/octan3/img-clipboard-dump/blob/master/dump-clipboard-png.ps1 # Adapted from https://github.com/octan3/img-clipboard-dump/blob/master/dump-clipboard-png.ps1
param($imagePath) param($imagePath)
# https://github.com/PowerShell/PowerShell/issues/7233 # https://github.com/PowerShell/PowerShell/issues/7233
# fix the output encoding bug # fix the output encoding bug
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
Add-Type -Assembly PresentationCore Add-Type -Assembly PresentationCore
function main { function main {
$img = [Windows.Clipboard]::GetImage() $img = [Windows.Clipboard]::GetImage()
if ($img -eq $null) { if ($img -eq $null) {
"no image" "no image"
Exit 1 Exit 1
} }
if (-not $imagePath) { if (-not $imagePath) {
"no image" "no image"
Exit 1 Exit 1
} }
$fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0) $fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0)
$stream = [IO.File]::Open($imagePath, "OpenOrCreate") $stream = [IO.File]::Open($imagePath, "OpenOrCreate")
$encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder $encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder
$encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($fcb)) | out-null $encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($fcb)) | out-null
$encoder.Save($stream) | out-null $encoder.Save($stream) | out-null
$stream.Dispose() | out-null $stream.Dispose() | out-null
$imagePath $imagePath
Exit 1 Exit 1
} }
try { try {
# For WIN10 # For WIN10
$file = Get-Clipboard -Format FileDropList $file = Get-Clipboard -Format FileDropList
if ($file -ne $null) { if ($file -ne $null) {
Convert-Path $file Convert-Path $file
Exit 1 Exit 1
} }
} catch { } catch {
# For WIN7 WIN8 WIN10 # For WIN7 WIN8 WIN10
main main
} }
main main

View File

@@ -1,12 +1,12 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PicList</title> <title>PicList</title>
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
<script type="module" src="./main.ts"></script> <script type="module" src="./main.ts"></script>
</body> </body>
</html> </html>