How to copy and paste images from the browser to any video editor on Mac with a clipboard faster

It was a surprise for me that most video editors do not allow adding images from the browser directly, like you can copy and paste them in Microsoft Word or WhatsApp. As for me, I am a user who can get distracted easily, so many steps to add images to my video is such a loss of time. That’s why I try as much as possible to find a solution.

The solution is using a special script that saves your image to the folder and replaces it with the local one automatically, so you will be able to paste it to the video editor more easily.

  1. Install the Hammerspoon - free open source software that helps to run and manage the script. Download the zip from the github, unpack it and run.
    https://github.com/Hammerspoon/hammerspoon/releases/tag/1.0.0

  1. The software will ask for Accessibility permissions; unfortunately, it is required to use macOs clipboard.

  2. After the software is installed, you can click on the hammer logo and Open a Config.

  1. In the config please insert the next code, which will make our magic by replacing the images in clipboard.

local saveDir = os.getenv("HOME") .. "/Pictures/ClippedImages/"
os.execute("mkdir -p " .. saveDir)

local function saveClipboardImage()
  local img = hs.pasteboard.readImage()
  if not img then return end

  -- Default values
  local ext, format = "png", "PNG"

  -- Try to detect original format more accurately
  if hs.pasteboard.readDataForUTI("public.jpeg") then
    ext, format = "jpg", "JPEG"
  elseif hs.pasteboard.readDataForUTI("com.compuserve.gif") then
    ext, format = "gif", "GIF"
  elseif hs.pasteboard.readDataForUTI("public.png") then
    ext, format = "png", "PNG"
  elseif hs.pasteboard.readDataForUTI("public.tiff") then
    ext, format = "tiff", "TIFF"
  else
    -- Fallback: normalize everything else to PNG
    ext, format = "png", "PNG"
  end

  local timestamp = os.date("%Y%m%d_%H%M%S")
  local filename = "clipboard_" .. timestamp .. "." .. ext
  local fullPath = saveDir .. filename

  -- Save image in chosen format
  local success = img:saveToFile(fullPath, format)
  
  if not success then
    hs.notify.new({
      title = "Clipboard Image Save Failed",
      informativeText = "Could not save image to " .. filename,
      withdrawAfter = 3
    }):send()
    return
  end

  -- Clear the pasteboard first
  hs.pasteboard.clearContents()
  
  -- Copy the actual file to clipboard using shell command (works reliably with Finder)
  local copyCommand = string.format('echo "file://%s" | pbcopy', fullPath:gsub(" ", "\\ "))
  os.execute(copyCommand)
  
  -- Alternative method: use osascript to copy file for Finder
  local osascriptCmd = string.format('osascript -e \'set the clipboard to POSIX file "%s"\'', fullPath)
  os.execute(osascriptCmd)
  
  -- Notify with more details
  local notification = hs.notify.new({
    title = "Clipboard Image Saved",
    informativeText = "Saved as " .. filename .. "\nReady to paste in Finder or other apps",
    withdrawAfter = 5,
    soundName = "default"
  })
  
  notification:send()
  
  -- Debug: print to console
  print("Image saved: " .. fullPath)
end

-- Add a manual hotkey for saving clipboard images (optional)
hs.hotkey.bind({"cmd", "shift"}, "s", function()
  saveClipboardImage()
end)

-- Add a test function to verify everything works
hs.hotkey.bind({"cmd", "shift"}, "t", function()
  hs.notify.new({
    title = "Hammerspoon Test",
    informativeText = "Hammerspoon is working! Script directory: " .. saveDir,
    withdrawAfter = 3,
    soundName = "default"
  }):send()
  print("Test notification sent")
end)

local watcher = hs.pasteboard.watcher.new(saveClipboardImage)
watcher:start()

-- Show startup notification
hs.notify.new({
  title = "Hammerspoon Ready",
  informativeText = "Clipboard image saver active\nHotkey: Cmd+Shift+S",
  withdrawAfter = 4,
  soundName = "default"
}):send()

print("Hammerspoon clipboard saver initialized")
  1. Save the file and click reload script in the same Hammerspoon menu.

  2. After that you should be able to copy images directly from your browser to the iMovie and other editors.

  1. You can easily turn off the script by exiting the Hammerspoon.
    Also, you can find all saved images by the path and clean them
    /Users/user/Pictures/ClippedImages.

Поділись своїми ідеями в новій публікації.
Ми чекаємо саме на твій довгочит!
Vadym
Vadym@vvadu

https://lombo.com.ua

261Прочитань
2Автори
4Читачі
На Друкарні з 26 вересня

Більше від автора

  • Про які жіночі імена найбільше співають Українці?

    Українська пісня багата на різні теми, але однією з найпоширеніших є тема кохання. І, звичайно ж, не обходиться без згадки імен коханих. Про які ж жіночі імена найчастіше співають українці?

    Теми цього довгочиту:

    Імена

Вам також сподобається

Коментарі (0)

Підтримайте автора першим.
Напишіть коментар!

Вам також сподобається