interactive icon indicating copy to clipboard operation
interactive copied to clipboard

Picture in html and markdown is not refreshed

Open marckruzik opened this issue 3 years ago • 2 comments

Describe the bug

After modifying a picture, the old version of the picture is still displayed. It's happening with the following commands (in their respective cells): HTML("<img src=\"data_output/picture.png\" />")

<img src="data_output/picture.png" />

![](data_output/picture.png)

I tried to restart the current notebook's Kernel (C#), but the pictures stay the same.

If I close and restart Visual Studio Code, it clears the cache. But if I have a markdown cell which displays the picture before the new version is generated, the old picture will be displayed everywhere.

The only get around I found is to render a base64 encoded html version of the picture. I'm looking for a better way to refresh the pictures.

using System.Drawing;
using System.IO;

public static void from_bmp_filepath_display_bmp(string bmp_filepath)
{
    Bitmap bmp = new Bitmap(bmp_filepath);
    string bmp64;
    using (var ms = new MemoryStream())
    {
        bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
        bmp64 = Convert.ToBase64String(ms.GetBuffer()); //Get Base64
    }
    bmp.Dispose();
    string str = $"<img src=\"data:image/png;base64,{bmp64}\" />";
    display(HTML(str));
}

from_bmp_filepath_display_bmp(@"data_output\picture.png");

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ): 1.0.325601+1743a009db9b6b64e33146e1681731acc785a7cf

  • OS
    • [ ] Windows 11
    • [x] Windows 10
    • [ ] macOS
    • [ ] Linux (Please specify distro)
    • [ ] iOS
    • [ ] Android
  • Browser
    • [ ] Chrome
    • [ ] Edge
    • [ ] Firefox
    • [ ] Safari
  • Frontend
    • [ ] Jupyter Notebook
    • [ ] Jupyter Lab
    • [ ] nteract
    • [x] Visual Studio Code
    • [ ] Visual Studio Code Insiders
    • [ ] Visual Studio
    • [ ] Other (please specify)

Screenshots

If applicable, add screenshots to help explain your problem.

marckruzik avatar Sep 04 '22 09:09 marckruzik

@marckruzik Could you clarify whether you saw this in Visual Studio or Visual Studio Code? Thanks!

jonsequitur avatar Sep 06 '22 17:09 jonsequitur

I saw this in Visual Studio Code. (just saw I used the wrong term in the textual description, I edited my first message to be more clear)

marckruzik avatar Sep 07 '22 09:09 marckruzik