unable to open image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jojocague
Posts: 2
Joined: 2016-06-16T05:16:13-07:00
Authentication code: 1151

unable to open image

Post 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?
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: unable to open image

Post 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
jojocague
Posts: 2
Joined: 2016-06-16T05:16:13-07:00
Authentication code: 1151

Re: unable to open image

Post by jojocague »

Thank you very much !
Post Reply