From 518321c911b0341f08d8ecc6405a3f2458692136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Harnes?= Date: Sun, 24 Mar 2024 11:57:56 +0100 Subject: [PATCH] refactor: clean up process_image function --- lua/img-clip/fs.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/img-clip/fs.lua b/lua/img-clip/fs.lua index 6e6b821..ad22a8d 100644 --- a/lua/img-clip/fs.lua +++ b/lua/img-clip/fs.lua @@ -169,17 +169,20 @@ M.process_image = function(file_path, opts) if util.has("win32") then util.warn("Windows does not support image processing yet.") - return nil, 1 + return "", 0 end + -- create temp file local tmp_file_path = file_path .. ".tmp" - M.copy_file(file_path, tmp_file_path) + -- process image local output, exit_code = util.execute(string.format("cat '%s' | %s > '%s'", file_path, process_cmd, tmp_file_path), true) if exit_code == 0 then M.copy_file(tmp_file_path, file_path) end + + -- remove temp file util.execute(string.format("rm '%s'", tmp_file_path), true) return output, exit_code