epwalsh / obsidian.nvim

Obsidian 🤝 Neovim
Apache License 2.0
4.22k stars 189 forks source link

Using `ObsidianPasteImg` sometimes makes obsidian render poorly #469

Open uthmanmoh opened 8 months ago

uthmanmoh commented 8 months ago

🐛 Describe the bug

After using ObsidianPasteImg a couple of times, it gets into this state where when I paste an image using the command it renders poorly in just Obsidian.

Hard to describe this issue because it seems very specific to Obsidian.

So when I paste the image using ObsidianPasteImg, it shows up in the file tree and everything works as expected, but Obsidian just renders it with some extra brightness and bad contrast. However, when I use finder or preview to open that exact image, it looks perfectly fine, which tells me that this probably isn't an image problem(?), but Obsidian just isn't dealing with it well. The reason I'm submitting an issue here and not to Obsidian though is if I paste the exact same thing I have in my clipboard at the time directly in Obsidian it pastes perfectly fine and the image it adds gets rendered perfectly. Below is an example of first what ObsidianPasteImg's image rendered as, and second what the exact same image pasted from my clipboard shows up as in Obsidian.

image image

I literally just copied this image from google images from this link: https://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Instagram_icon.png/480px-Instagram_icon.png

Sorry if my explanation wasn't super clear. This seems like a very weird bug to me that I don't understand. Let me know if you want further clarification on anything. I also searched for a while if there were any Obsidian issues out there related to this, but didn't find anything.

Config

{
    "epwalsh/obsidian.nvim",
    version = false, -- get latest version
    lazy = true,
    ft = "markdown",
    dependencies = {
      "nvim-lua/plenary.nvim",
      "hrsh7th/nvim-cmp",
      "nvim-telescope/telescope.nvim",
      "nvim-treesitter/nvim-treesitter",
    },
    keys = {
      { "<leader>oo", "<cmd>ObsidianOpen<cr>", desc = "Open Obsidian" },
      { "<leader>on", "<cmd>ObsidianNew<cr>", desc = "Create a new Obsidian Document" },
      { "<leader>os", "<cmd>ObsidianSearch<cr>", desc = "Search Obsidian" },
      { "<leader>of", "<cmd>ObsidianQuickSwitch<cr>", desc = "Obsidian Find Files" },
      { "<leader>op", "<cmd>ObsidianPasteImg<cr>", desc = "Obsidian Paste Image" },
      { "<leader>or", "<cmd>ObsidianRename<cr>", desc = "Obsidian Rename current note" },
      { "<leader>ot", "<cmd>ObsidianTemplate<cr>", desc = "Insert Obsidian Template into file" },
    },

    opts = {
      workspaces = {
        {
          name = "Obsidian Vault",
          path = "~/Documents/Obsidian Vault",
        },
      },
      open_app_foreground = true,
      completion = {
        nvim_cmp = true, -- with this set to true, it automatically configures completion on its own
      },
      disable_frontmatter = true,
      templates = {
        subdir = "templates",
        date_format = "%Y-%m-%d",
      },
      note_id_func = function(title)
        if title ~= nil then
          -- Convert title to lowercase and replace spaces with hyphens, e.g. "My Note" -> "my-note"
          return title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower()
        else
          return "untitled"
        end
      end,
    },
  }

Environment

❯ nvim --version
NVIM v0.10.0-dev-2501+gdbf6be296-Homebrew
Build type: Release
LuaJIT 2.1.1703358377
❯ nvim --headless -c 'lua require("obsidian").info()' -c q
Obsidian.nvim v3.6.1 (099ef3dc0c0882fb4f10ebce8283c368c58bd06b)
Dependencies:
   plenary.nvim: 4f71c0c4a196ceb656c824a70792f3df3ce6bb6d
   nvim-cmp: 04e0ca376d6abdbfc8b52180f8ea236cbfddf782
   telescope.nvim: dc1ea28cc2a02cd1cebb9d80e967807d668f78f8
Integrations:
   picker: TelescopePicker()
   completion: enabled (nvim-cmp)
Tools:
   rg: ripgrep 14.1.0
Environment:
   operating system: Darwin
Config:
   notes_subdir: nil
❯ pngpaste -v
pngpaste 0.2.3

Obsidian v1.5.8 (Installer version v1.4.16)

aaronmcadam commented 8 months ago

I've been seeing this a lot too. Sometimes, after reopening Obsidian, the image isn't washed out anymore. It's a very strange bug.

dlvandenberg commented 5 months ago

I am also having the same problem.

mburazin commented 3 months ago

Same here...