Hi All
I am using this batch script extensively to collates images side by side:
SETLOCAL EnableDelayedExpansion
SET IMCONV="%PROGRAMFILES%\ImageMagick-7.0.4-Q16\Convert"
SET COUNT=0
setlocal ENABLEDELAYEDEXPANSION
FOR /R %%T IN (*.jpg) DO (
SET /A COUNT=!COUNT!+1
REN %%T A!COUNT!.jpg
)
:EOF
@echo off
set count=0
for %%x in (*.jpg) do set /a count+=1
set /a demi=%count% / 2
FOR /L %%x IN (1,2,%count%) DO (
set /a y = %%x + 1
%IMCONV% A%%x.jpg A!y!.jpg +append B%%x.jpg
)
endlocal
However I would like to collate also images in a grid of 2x2, and I do not know how.
PS. another mini problem in my script is that is it is unable to renumber correctly images if they start with a digit, but this may be for another time..
How to join images in a 2x2 grid using "convert"
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to join images in a 2x2 grid using "convert"
A convert command to append 4 images in a 2x2 grid is (Windows BAT syntax):
When inside a "for (...)" loop, you need to escape the parentheses or quote them:
Code: Select all
convert ^
( a.jpg b.jpg +append ) ^
( c.jpg d.jpg +append ) ^
-append ^
out.jpg
Code: Select all
convert ^
^( a.jpg b.jpg +append ^) ^
^( c.jpg d.jpg +append ^) ^
-append ^
out.jpg
snibgo's IM pages: im.snibgo.com
Re: How to join images in a 2x2 grid using "convert"
Snibgo, Inspired by your answer, and trying to incorporate it in my humble program, I manage no better than:
SETLOCAL EnableDelayedExpansion
SET IMCONV="%PROGRAMFILES%\ImageMagick-7.0.4-Q16\Convert"
SET COUNT=0
setlocal ENABLEDELAYEDEXPANSION
FOR /R %%T IN (*.jpg) DO (
SET /A COUNT=!COUNT!+1
REN %%T A!COUNT!.jpg
)
:EOF
@echo off
set count=0
for %%x in (*.jpg) do set /a count+=1
set /a demi=%count% / 2
FOR /L %%x IN (1,4,%count%) DO (
set /a y = %%x + 1
set /a w = %%x + 2
set /a z = %%x + 3
%IMCONV% A%%x.jpg A!y!.jpg +append
A!w!.jpg A!x!.jpg +append
B%%x.jpg +append
)
endlocal
However it is making an error... Could you help me please?
SETLOCAL EnableDelayedExpansion
SET IMCONV="%PROGRAMFILES%\ImageMagick-7.0.4-Q16\Convert"
SET COUNT=0
setlocal ENABLEDELAYEDEXPANSION
FOR /R %%T IN (*.jpg) DO (
SET /A COUNT=!COUNT!+1
REN %%T A!COUNT!.jpg
)
:EOF
@echo off
set count=0
for %%x in (*.jpg) do set /a count+=1
set /a demi=%count% / 2
FOR /L %%x IN (1,4,%count%) DO (
set /a y = %%x + 1
set /a w = %%x + 2
set /a z = %%x + 3
%IMCONV% A%%x.jpg A!y!.jpg +append
A!w!.jpg A!x!.jpg +append
B%%x.jpg +append
)
endlocal
However it is making an error... Could you help me please?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to join images in a 2x2 grid using "convert"
Your convert command is very different to mine.
snibgo's IM pages: im.snibgo.com
Re: How to join images in a 2x2 grid using "convert"
The fact that I renamed Convert into IMCONV in the line: SET IMCONV="%PROGRAMFILES%\ImageMagick-7.0.4-Q16\Convert"
was been advised by IM itself so that there will be no conflict with Windows System own Convert operation...
Please disregard this line and provide your own lines of codes as you would normally do...
was been advised by IM itself so that there will be no conflict with Windows System own Convert operation...
Please disregard this line and provide your own lines of codes as you would normally do...
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to join images in a 2x2 grid using "convert"
What error message do you get? Some errors are obvious:
Your convert has 5 inputs and no output.
You have three "+append" instead of two "+append and one "-append"
You have no parentheses.
Most importantly, you have no line continuation characters.
Your convert has 5 inputs and no output.
You have three "+append" instead of two "+append and one "-append"
You have no parentheses.
Most importantly, you have no line continuation characters.
snibgo's IM pages: im.snibgo.com
Re: How to join images in a 2x2 grid using "convert"
Success! Based on Snibgo help, I managed the successful:
SETLOCAL EnableDelayedExpansion
SET IMCONV="%PROGRAMFILES%\ImageMagick-7.0.4-Q16\Convert"
SET COUNT=0
setlocal ENABLEDELAYEDEXPANSION
FOR /R %%T IN (*.jpg) DO (
SET /A COUNT=!COUNT!+1
REN %%T A!COUNT!.jpg
)
:EOF
set count=0
for %%x in (*.jpg) do set /a count+=1
FOR /L %%x IN (1,4,%count%) DO (
set /a y = %%x + 1
set /a w = %%x + 2
set /a z = %%x + 3
%IMCONV% ^
^( A%%x.jpg A!y!.jpg +append ^) ^
^( A!w!.jpg A!z!.jpg +append ^) ^
-append ^
B%%x.jpg
)
endlocal
SETLOCAL EnableDelayedExpansion
SET IMCONV="%PROGRAMFILES%\ImageMagick-7.0.4-Q16\Convert"
SET COUNT=0
setlocal ENABLEDELAYEDEXPANSION
FOR /R %%T IN (*.jpg) DO (
SET /A COUNT=!COUNT!+1
REN %%T A!COUNT!.jpg
)
:EOF
set count=0
for %%x in (*.jpg) do set /a count+=1
FOR /L %%x IN (1,4,%count%) DO (
set /a y = %%x + 1
set /a w = %%x + 2
set /a z = %%x + 3
%IMCONV% ^
^( A%%x.jpg A!y!.jpg +append ^) ^
^( A!w!.jpg A!z!.jpg +append ^) ^
-append ^
B%%x.jpg
)
endlocal