Page 1 of 1
ID passport
Posted: 2011-11-11T14:12:32-07:00
by shalmoo
I need to create a photo, containing four portraits, i.e. a classic ID passport photo.
FOr exmaple, I need to convert this photo:
I have constructed the following command:
Code: Select all
convert -size 300x400 xc:white -draw "image SrcOver 10,10 135,185 'src.jpg'" -draw "image SrcOver 10,205 135,185 'src.jpg'" -draw "image SrcOver 155,10 135,185 'src.jpg'" -draw "image SrcOver 155,205 135,185 'src.jpg'" id_passport.jpg
The result is:
As you can see, the photos are stretched.
How do I crop the photo inside one command? Something like this:
Of cource I can first do the crop command and save the intermediate photo to disk, but it is a waste of time and quality, I need everything in one single command. Thank you.
Re: ID passport
Posted: 2011-11-11T15:09:20-07:00
by fmw42
If I were doing it, I would do it as follows:
convert -size 300x400 xc:white \
\( src.jpg -gravity center -crop 243x333+0+0 +repage -resize 135x185! \) \
\( -clone 0 -clone 1 -gravity northwest -geometry +10+10 -composite \) \
\( -clone 2 -clone 1 -gravity northeast -geometry +10+10 -composite \) \
\( -clone 3 -clone 1 -gravity southeast -geometry +10+10 -composite \) \
\( -clone 4 -clone 1 -gravity southwest -geometry +10+10 -composite \) \
-delete 0-4 src_result1.jpg
or
convert -respect-parenthesis -size 300x400 xc:white \
\( src.jpg -gravity center -crop 243x333+0+0 +repage -resize 135x185! \) \
\( -page +10+10 -clone 1 \) \
\( -page +155+10 -clone 1 \) \
\( -page +155+205 -clone 1 \) \
\( -page +10+205 -clone 1 \) \
-delete 1 -background white -flatten src_result2.jpg
see
http://www.imagemagick.org/Usage/layers/#convert
http://www.imagemagick.org/Usage/layers/#flatten
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/basics/#sequence
http://www.imagemagick.org/Usage/basics/#clone
Re: ID passport
Posted: 2011-11-11T17:06:10-07:00
by shalmoo
Thank you very much, fmw!I like second variant.
OK, now If I want to do the set of three images, like this:
how do I construct the command? I tried to do this:
Code: Select all
convert -respect-parenthesis -size 300x400 xc:white
( src.jpg -gravity center -crop 243x333+0+0 +repage -resize 135x185! )
( -page +10+10 -clone 1 )
( -page +155+10 -clone 1 )
( src.jpg -gravity center -crop 391x258+0+0 +repage -resize 280x185! )
( -page +10+205 -clone 2 )
-delete 1 -delete 2 -background white -flatten -quality 99 id_passport.jpg
But it failed, although seems like I follow the syntax you suggest. What is wrong with my command?
Re: ID passport
Posted: 2011-11-11T18:27:01-07:00
by shalmoo
I got it!!!
Code: Select all
convert -respect-parenthesis -size 300x400 xc:white src.jpg
( -clone 1 -gravity center -crop 243x333+0+0 +repage -resize 135x185! )
( -clone 1 -crop 391x258+0+0 +repage -resize 280x185! )
( -page +10+10 -clone 2 )
( -page +155+10 -clone 2 )
( -page +10+205 -clone 3 )
-delete 1-3 -background white -flatten -quality 99 id_passport3.jpg
Re: ID passport
Posted: 2018-06-28T18:27:44-07:00
by ligongl
would you be kind enough to re-format the following command for MS-DOS ? Thank you.
magick convert -respect-parenthesis -size 300x400 xc:white src.jpg
( -clone 1 -gravity center -crop 243x333+0+0 +repage -resize 135x185! )
( -clone 1 -crop 391x258+0+0 +repage -resize 280x185! )
( -page +10+10 -clone 2 )
( -page +155+10 -clone 2 )
( -page +10+205 -clone 3 )
-delete 1-3 -background white -flatten -quality 99 id_passport3.jpg
Re: ID passport
Posted: 2018-06-28T19:36:15-07:00
by fmw42
try
Code: Select all
magick -respect-parenthesis -size 300x400 xc:white src.jpg ^
( -clone 1 -gravity center -crop 243x333+0+0 +repage -resize 135x185! ) ^
( -clone 1 -crop 391x258+0+0 +repage -resize 280x185! ) ^
( -page +10+10 -clone 2 ) ^
( -page +155+10 -clone 2 ) ^
( -page +10+205 -clone 3 ) ^
-delete 1-3 -background white -flatten -quality 99 id_passport3.jpg