Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hankei6km/3d09d3573b0ce4233c91f20f7c88b635 to your computer and use it in GitHub Desktop.
Save hankei6km/3d09d3573b0ce4233c91f20f7c88b635 to your computer and use it in GitHub Desktop.
Windows でコピーした画像を Bes64 形式のテキストで VcXsrv のクリップボードに渡す

Windows でコピーした画像を Bes64 形式のテキストで VcXsrv のクリップボードに渡す

※ 2018-12 に記述したメモです。Gist にアップロードした時点と比べて内容が古い可能性があります

画像を扱うのにクリップボード経由で扱えた方が楽かなということでメモ.

いろいろ実験した経緯等は クリップボードにコピーされた画像を cli ツールで読み出す を参照.

まず Windows 側では Powershell で以下のように画像をBase64でエンコードしてから 再度クリップボードへテキストとしてコピーする.

$ms=[System.IO.MemoryStream]::new()
(Get-Clipboard -Format Image).Save($ms, [System.Drawing.Imaging.ImageFormat]::Jpeg)
[System.Convert]::ToBase64String($ms.ToArray()) | Set-Clipboard

linux 側では以下のような感じでデコードする.

xsel -o | base64 -d > test_decode1.jpg

License: CC0 1.0 http://creativecommons.org/publicdomain/zero/1.0/deed.ja

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment