Skip to content

Instantly share code, notes, and snippets.

@dogancelik
Last active February 21, 2021 23:48
Show Gist options
  • Save dogancelik/221ea6a1683ea0541d55cc59b9d69a54 to your computer and use it in GitHub Desktop.
Save dogancelik/221ea6a1683ea0541d55cc59b9d69a54 to your computer and use it in GitHub Desktop.
ImgOps CLI Upload from Clipboard #Windows

ImgOps CLI Upload from Clipboard

with NirCmd

Run imgops_clip.bat without any arguments and it will upload the image from the clipboard to ImgOps and open the URL in your default web browser. If you run imgops_clip.bat with argument copy_url, it will copy the URL to the clipboard.

⚠ It requires NirCmd nircmdc.exe to be in PATH.

with NirCmd & IrfanView

If you want faster uploads, you should use imgops_clip_iv.bat which uses IrfanView to compress and resize the images.

⚠ Additionally you need i_view32.exe (IrfanView) to be in PATH.

@echo off
set "tempfile=%TEMP%\imgops_clip_%random%.png"
forfiles /p "%TEMP%" /s /m imgops_clip_* /D -1 /C "cmd /c del @path" 2>nul
nircmdc.exe clipboard saveimage %tempfile%
if exist %tempfile% (
if "%~1" == "copy_url" (
imgops.exe search -r %tempfile% 1>%~dpn0.stdout.log 2>%~dpn0.stderr.log
nircmdc.exe beep 300 500
nircmdc.exe clipboard readfile %~dpn0.stdout.log
) else (
imgops.exe search %tempfile% 2>%~dpn0.stderr.log
)
) else (
echo File doesn't exist
nircmdc.exe beep 750 250
nircmdc.exe beep 750 250
timeout 3
)
@echo off
set "TEMP_FILE=%TEMP%\imgops_clip.txt"
copy /y nul "%TEMP_FILE%"
nircmdc.exe clipboard writefile "%TEMP_FILE%"
set /P TEMP_CLIP=<%TEMP_FILE%
if "%TEMP_CLIP:~0,4%" == "http" (
imgops.exe search %TEMP_CLIP%
goto :end
)
:image
set TEMP_RANDOM=%random%
set "TEMP_FILE=%TEMP%\imgops_clip_%TEMP_RANDOM%.png"
set "TEMP_FILE_SMALL=%TEMP%\imgops_clip_%TEMP_RANDOM%_small.jpg"
forfiles /p "%TEMP%" /s /m imgops_clip_* /D -1 /C "cmd /c del @path" 2>nul
nircmdc.exe clipboard saveimage %TEMP_FILE%
i_view32.exe "%TEMP_FILE%" /resize_short=300 /aspectratio /convert="%TEMP_FILE_SMALL%"
if exist %TEMP_FILE% (
if "%~1" == "copy_url" (
imgops.exe search -r %TEMP_FILE_SMALL% 1>%~dpn0.stdout.log 2>%~dpn0.stderr.log
nircmdc.exe beep 300 500
nircmdc.exe clipboard readfile %~dpn0.stdout.log
) else (
imgops.exe search %TEMP_FILE_SMALL% 2>%~dpn0.stderr.log
)
) else (
echo File doesn't exist
nircmdc.exe beep 750 250
nircmdc.exe beep 750 250
timeout 3
)
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment