Search code examples
batch-fileimagemagick-convert

Multiple Image conversion using ImageMagick


Problem: I want to be able to convert multiple images at a time by simply dragging multiple images onto my batch file.

Here's my programming code because I am resizing EACH image:

convert "%1" -thumbnail 50x -unsharp 1.5x1.2+1.0+0.10 "%~p1%~n1"
convert "%1" -thumbnail 80x -unsharp 1.5x1.2+1.0+0.10 "%~p1%~n1"
convert "%1" -thumbnail 120x -unsharp 1.5x1.2+1.0+0.10 "%~p1%~n1"

Each of these lines above are in a separate file, so I made another file to call each of these files. (Educational purposes)

All lines below are in ONE file:

call ImageConvert120x.bat %*
call ImageConvert80x.bat %*
call ImageConvert50x.bat %*

Now, when I highlight over multiple images, and drop it onto this file where it's calling each of them, it only converts the top one. I would like it to be able to convert multiple images at a time after highlighting them and dropping it onto the batch file.

This should be able to work for ALL file types.

EDIT:

I've added:

for %%i in (%*) do (
call ImageConvert120x.bat %*
call ImageConvert80x.bat %*
call ImageConvert50x.bat %*
)

But it will take the first image, and try it again and replace it again.


Solution

  • the for translates %* (list of files) to %%i (single file), so it's of no use to call ImageConvert120x.bat %* (with the list of files). Use %%i (one single file at a time):

    for %%i in (%*) do (
      call ImageConvert120x.bat %%i
      ...
    )