Page 1 of 1

unable to open image

Posted: 2016-06-16T05:30:36-07:00
by jojocague

Code: Select all

@echo off
title = gif watermarking tool
goto :start

:start

SET FIRST=C:\Users\fff\Desktop\gifs
SET SECOND=C:\Users\fff\Desktop\gifs2

for /F "usebackq" %%F in (`dir /b %FIRST%\*.gif`) do (magick convert %%F -coalesce -gravity SouthEast -geometry +0+0 null: watermark.png -layers composite -layers optimize %SECOND%\%%~nxF)

pause
I wrote this code and got an error :

convert: unable to open image 'giphy.gif': No such file or directory @ error/blob.c/OpenBlob/2695.
convert: unable to open image 'watermark.png': No such file or directory @ error/blob.c/OpenBlob/2695.
convert: unable to open file `watermark.png' @ error/png.c/ReadPNGImage/3978.
convert: missing Null Image List Separator layers Composite @ error/mogrify.c/MogrifyImageList/8428.

Anyone know how I can resolve this problem?

Re: unable to open image

Posted: 2016-06-16T07:38:59-07:00
by GeeMack
jojocague wrote:Anyone know how I can resolve this problem?
Your "dir /b" command returns the file names of the contents of the "%FIRST%" directory, but doesn't include the directory name itself. That makes the "convert" command look for those file names in the current directory, and of course it can't find them. You could use "pushd" to change to the directory "%FIRST%" before the "for" loop, then "popd" to change back to the current directory when the command is finished. I haven't tested it, but something like this should get you closer...

Code: Select all

@echo off
title = gif watermarking tool
goto :start

:start

SET FIRST=C:\Users\fff\Desktop\gifs
SET SECOND=C:\Users\fff\Desktop\gifs2

pushd %FIRST%

for /F "usebackq" %%F in (`dir /b *.gif`) do (magick convert %%F -coalesce -gravity SouthEast -geometry +0+0 null: watermark.png -layers composite -layers optimize %SECOND%\%%~nxF)

popd

pause

Re: unable to open image

Posted: 2016-06-16T09:27:24-07:00
by jojocague
Thank you very much !