mushanshitiancai / vscode-paste-image

paste image from clipboard to markdown/asciidoc directly!
MIT License
422 stars 127 forks source link

Images pasted are all blank (bug since 1.0.3) #40

Open walterlv opened 5 years ago

walterlv commented 5 years ago

Description

When pasting an image into Visual Studio Code markdown file, the image will be completely blank with every pixel transparent.

How to reproduce it?

  1. Copy an image into the clipboard;
  2. Press Ctrl+Alt+V and wait for the insertion of the image.

What's the environment?

What happened?

You can see that the image pasted is transparent.

image

And to reveal it in the explorer, it is also transparent.

image

But actually, it can be pasted into other applications such as what I'm writing on GitHub issues.

walterlv commented 5 years ago

描述

在 Visual Studio Code 里使用此插件粘贴的任何图片都是空白的,所有像素都是透明像素。

复现步骤

  1. 复制一张图片到剪贴板;
  2. 在 Visual Studio Code 里用 Ctrl+Alt+V 粘贴。

环境

现象

可以看到粘贴进来的图片是透明的。

image

在资源管理器中查看,它也是透明的(实际上粘贴的图片已经损坏不可恢复)。

image

但是在其他应用里面可以粘贴,例如我现在正在编写的 GitHub Issue 窗格中,是可以正常粘贴的。

NickSegalle commented 5 years ago

The issue appears to be how PowerShell is writing the image file. If you look at the following script: mushan.vscode-paste-image-1.0.3\res\pc.ps1

Line 18:

$fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgba64, $null, 0)

It doesn't seem to like the alpha code in 'Rgba64'. I've tried several formats here, but it seems to be the alpha code. Also appears to be a fix from Issue #29. If you just change it back to 'Rgb24', it will work again.

SeaDude commented 5 years ago

This is happening to me today, again, as well. It happened here and I reported it #38. Then went away. Now its back!

image But only every now and then! I'm not sold on the PowerShell fix. I feel like its a timestamp thing.

My workflow:

Please see #38 where I reported the same issue. To fix ( a SERIOUS pain) I had to go into SnagIt and copy the timestamps, then paste them into the image filenames in the /assets folder.

Please consider addressing this issue.

Thank you

stanstanwang commented 5 years ago

I swtich to 1.0.2 , hah..

SeaDude commented 5 years ago

@gaosjx how do you revert to previous version?

mushanshitiancai commented 5 years ago

hello, can you tell me the screenshots tool that you are using?

I guess some screenshots tool take image with alpha value(Rgba64 work well) and others not(Rgba24 work well).

Does anyone know how to take image from clipboard correctly by powershell?

stanstanwang commented 5 years ago

@SeaDude update the vscode version to 1.30.2 This version has a new feature : Choose extension version - Install earlier versions of Marketplace extensions.

SeaDude commented 5 years ago

@mushanshitiancai , I'm using TechSmith SnagIt. I used this workflow without issue up to 3-4 weeks ago.

@gaosjx , i'm on 1.30.2. I'll try rolling back to earlier version of Paste Image and see if that helps. image d

SeaDude commented 5 years ago

CONFIRMED: Rolling back to Paste Image 1.0.2 fixed this issue.

mushanshitiancai commented 5 years ago

@SeaDude @gaosjx @NickSegalle @walterlv Thank you for your attempt!

I try SnagIt and get blank image too, So I rollback the code to 1.0.2 to fix this bug. Now you can update PasteImage to 1.0.4.

walterlv commented 5 years ago

@mushanshitiancai 哈!刚刚收到了你的 1.0.4 的更新啦,感谢!