nvim-telescope / telescope-media-files.nvim

Telescope extension to preview media files using Ueberzug.
MIT License
445 stars 46 forks source link

Images are pixelated #50

Open rodude123 opened 10 months ago

rodude123 commented 10 months ago

I'm using lunarvim and I have enabled this but images are pixelated in kitty. image I can share my wholej config if you'd like

lvim.builtin.telescope.on_config_done = function(telescope)
  pcall(telescope.load_extension, "media_files")
end
local previewers = require("telescope.previewers")

lvim.builtin.telescope.register_previewer = function(telescope)

    local new_maker = function(filepath, bufnr, opts)
      opts = opts or {}

      filepath = vim.fn.expand(filepath)
      job_id = vim.loop.spawn('kitty', {
        args = {'+kitten', 'icat', '--place', opts.x..'%', opts.y..'%', '--silent', filepath},
        detached = true
      }, function(code)
        -- command finished
      end)

      return bufnr
    end

    local get_command = function(filepath)
        return {
          "kitty",
          "+kitten", 
          "icat",
          "--silent",
          "--sacle",
          filepath
        }
    end

    telescope.extensions.media_files.previewer = previewers.new_termopen_previewer({
        get_bufnr = new_maker,
        get_command = get_command
    })

end

lvim.builtin.telescope.on_config_done = function(telescope)
  -- telescope.setup {
  --   defaults = {
  --       file_previewer = require('telescope.previewers').vim_buffer_cat.new,
  --   },  
    -- extensions = {
    --   media_files = {
    --     filetypes = {"png", "jpg", "mp4", "pdf", "gif"},
    --     file_previewer = require('telescope.previewers').ueberzug_maker({
    --         display_method = 'kitty'
    --     }),
    --     find_cmd = "fd"
    --   }
    -- }
  -- }
    local previewers = require('telescope.previewers')
    local new_maker = function(filepath, bufnr, opts)
      opts = opts or {}

      filepath = vim.fn.expand(filepath)
      job_id = vim.loop.spawn('kitty', {
        args = {'+kitten', 'icat', '--place', opts.x..'%', opts.y..'%', '--silent', filepath},
        detached = true
      }, function(code)
        -- command finished
      end)

      return bufnr
    end

    local get_command = function(filepath)
        return {
          "kitty",
          "+kitten", 
          "icat",
          "--silent",
          "--sacle",
          filepath
        }
    end

    telescope.setup {
      defaults = {
        file_previewer = require('telescope.previewers').vim_buffer_cat.new,

        media_files = {
          file_previewer = previewers.new_termopen_previewer({
            get_bufnr = new_maker,
            get_command = get_command
          })
        }
      },
        extensions = {
          media_files = {
            filetypes = {"png", "jpg", "mp4", "pdf", "gif"},
            find_cmd = "fd"
          }
        }
    }
    telescope.extensions.media_files.use_ueberzug = false
    telescope.extensions.media_files.previewer = previewers.new_termopen_previewer({
        get_bufnr = new_maker,
        get_command = get_command
    })
    telescope.load_extension("media_files") 
end
rodude123 commented 10 months ago

That's what I tried but same thing

stove-jeebs commented 9 months ago

duplicate of #46 I still haven't found a fix....

kamack38 commented 6 months ago

Looking at the chafa website, it seems to me that this is expected behaviour.

EDIT: Actually, when running the chafa command inside kitty terminal, images show up normally.

jchilders commented 6 months ago

This Neovim issue appears related: :term should forward unknown sequences to host

rodhash commented 4 months ago

all solutions I tried so far has this same issue of pixelated images, except for yazi that I found out recently.. from my long list of tested alternatives was the first one looking good under tmux

Hope we can have this fixed for telescope extensions .. would be really nice