# Imagemagick trouble.



## pasc (Jun 21, 2014)

So, I thought of this script (inorder to paste a "background.png" behind each of the gifs in a folder)


@echo off
timeout 1 > nul
for %%x in (*.gif) do convert -page +0+0 background.png -page +0+0 %%x -flatten %%x


However it will stay stuck on the first image.

Ideas ?


----------



## foxidrive (Oct 20, 2012)

I suspect that you have called the batch file convert and it is calling itself.
Pick another name like convertgif.bat and your loop also needs to change so that some files aren't processed more than once.

The double quotes are to handle spaces etc in filenames.


```
@echo off
for /f "delims=" %%x in ('dir *.gif /b /a-d ') do (
convert -page +0+0  "background.png"   -page +0+0 "%%x" -flatten "%%x"
)
pause
```


----------



## pasc (Jun 21, 2014)

actually I called the "imagemagick" function "convert"


----------



## foxidrive (Oct 20, 2012)

Did my answer help you?


----------



## pasc (Jun 21, 2014)

Sadly not...

like I said, the script calls an function called convert.

If you want to try yourself, download imagemagick, create a folder with similar sized gifs and one similar sized png:
http://www.imagemagick.org/script/download.php


----------



## foxidrive (Oct 20, 2012)

That is indeed sad.

I tested it with imagemagick before I posted it. You have no clue.


----------

