how do you vertically stack every 4 images into 1 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?".
User
Posts: 13
Joined: 2013-05-19T01:13:51-07:00
Authentication code: 6789

Re: how do you vertically stack every 4 images into 1 image?

Post by User »

Image
transcript of part 1

Code: Select all

how do you vertically stack 4 images 
into 1 image? on mass. with 1000 images. 

on mass. fast. not manually. this example was made manually

they're all the same resolution 
and in the correct order in name and time

please explain it easily for a beginner. 
i can not into code

operating system is windows 7 64-bit

problem solved
1. imagemagick.org/script/binary-realeases/php
2. ImageMagick-6.8.5-6-Q16-x86-dll.exe
3. run "cmd.exe". windows command prompt
4. navigate to the directory with yoru images with: 
cd "[C:\][Copy Paste Directory with Images]"
5. copy paste the following command and press enter
montage *rect.png -tile 1x4 -geometry +0+0 vert-%d.png
transcript of part 2

Code: Select all

how do you stop files from being overwritten

1st set of files to convert. this
plus
montage *rect.png -tile 1x4 -geometry +0+0 vert-%d.png
equals
1st set of files converted. that

2nd set of files to convert. this
plus
montage *rect.png -tile 1x4 -geometry +0+0 vert-%d.png
equals
2nd set of files converted. that

the problem is that they overwrite the 1st set of files converted
i think it overwrites it because the filename output is the same
[/code
questions

how do you get it to input filenames with specific numbers? 
for example have it input 01 to 04 but not input 05 to 16

how do you get it to output filenames with specific numbers? 
for example have it output vert-05 to vert-08 but not vert-0 to vert-03

how do you get imagemagick convert to do what montage has done here? 
people keep giving me code that only works for convert and not montage

notes

the images in this image were made and used as examples
and the non example images i need to convert are 1000

i'd rather not create a bunch of folders for input and output directories
i'd rather have all of the images in 1 folder
but i dont know how to do either yet so if i find that out i may have to do that
thanks!
note this post was edited after replies were made to it
so if they don't seem like good replies then that's the reason
fmw42 wrote: montage rose*.jpg -geometry +0+0 -tile 1x2 results_%d.jpg
thanks. ''rectvert'' actually is an example i made for this.
what i'm really working with is 1000 images

the actual images are formatted like this

Code: Select all

YYYY-MM-DD-filename.png
problem solved
how to vertically stack every 4 images into single images
this code works in windows 7 64-bit power shell imagemagick montage

Code: Select all

montage *rect.png  -tile 1x4 -geometry +0+0 vert-%d.png
problem not solved
how do you stop overwriting old output files?
problem now is overwriting output files because they're the same filename

how do you stop files from overwriting eachother?

i don't know what i'm doing

Code: Select all

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 *.png

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 *.png

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 vert-%d.png

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 [filename]ve
rt-%d.png

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 %[filename]v
ert-%d.png

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 [filename]ve
rt-%d.png

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 %%[filename]
vert-%%d.png

C:\Users\User\1\rectvert>
please help, anyone.
Last edited by User on 2013-05-19T20:39:12-07:00, edited 2 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how do you vertically stack every 4 images into 1 image?

Post by fmw42 »

montage *rect.png -tile 1x4 -geometry +0+0 vert-%d.png
That works fine for me on my Mac (unix). I get a different -0,-1,-2 etc for each pair. Sorry I do not know Windows to know if it supports _%d syntax. Perhaps see http://www.imagemagick.org/Usage/windows/

On Windows, perhaps you need to escape the % as %%

montage *rect.png -tile 1x4 -geometry +0+0 vert-%%d.png
User
Posts: 13
Joined: 2013-05-19T01:13:51-07:00
Authentication code: 6789

Re: how do you vertically stack every 4 images into 1 image?

Post by User »

fmw42 wrote:
montage *rect.png -tile 1x4 -geometry +0+0 vert-%d.png
That works fine for me on my Mac (unix). I get a different -0,-1,-2 etc for each pair. Sorry I do not know Windows to know if it supports _%d syntax. Perhaps see

http://www.imagemagick.org/Usage/windows/

On Windows, perhaps you need to escape the % as %%

montage *rect.png -tile 1x4 -geometry +0+0 vert-%%d.png
this code words

Code: Select all

montage *rect.png  -tile 1x4 -geometry +0+0 vert-%d.png
i also get a different -0, -1, -2, etc. for each pair

it's just when i run it again for the next 100 files it overwrites the last 25 files made

since when i tried to do all 1000 at once my computer couldn't take it.
so i'm trying make vertical images with every 4 images with 100 images at a time

so i'm thinking the output file needs to use the input filename.
so it doesn't overwrite the old images because they're the same filename

still don't know what i'm doing

Code: Select all

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 *.png

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 *.png

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 vert-%d.png

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 [filename]ve
rt-%d.png

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 %[filename]v
ert-%d.png

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 [filename]ve
rt-%d.png

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 %%[filename]
vert-%%d.png

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 vert-%%d.png


C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 vert-%d.png

C:\Users\User\1\rectvert>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how do you vertically stack every 4 images into 1 image?

Post by fmw42 »

montage *rect.png -tile 1x4 -geometry +0+0 vert-%d.png

i also get a different -0, -1, -2, etc. for each pair
I thought you could do the following. (see http://www.imagemagick.org/Usage/files/#read_meta)
But it does not seem to limit the frames. So perhaps I am making a mistake or this trick only works with convert and not montage.

Anthony may be able to point out how to make this work. He knows wildcards much better than I.

You can make 10 montage commands to choose the 100 images you need and change the output name as well. You can use frame numbers to control the images to choose. For example,

montage '*.jpg[0-99]' -geometry +0+0 -tile 1x4 result_1_%d.png
montage '*.jpg[100-199]' -geometry +0+0 -tile 1x4 result_2_%d.png
...
montage '*.jpg[900-999]' -geometry +0+0 -tile 1x4 result_10_%d.png

I tried with my 4 rose images

montage 'rose*.jpg[0-1]' -geometry +0+0 -tile 1x2 result.jpg

but I still got two resulting images.

EDIT: This works. The images must be put into a multi-frame format

convert rose*.jpg miff:- | montage -[0-1] -tile 1x2 result.png


So your commands should be:

convert rose*.jpg miff:- | montage -[0-99] -geometry +0+0 -tile 1x4 result_1_%d.png
convert rose*.jpg miff:- | montage -[100-199] -geometry +0+0 -tile 1x4 result_2_%d.png
...
convert rose*.jpg miff:- | montage -[900-999] -geometry +0+0 -tile 1x4 result_10_%d.png

However, that may need more memory than you have. If so then you can try http://www.imagemagick.org/Usage/files/#massive so that you use disk rather than memory. But I have little knowledge about this.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: how do you vertically stack every 4 images into 1 image?

Post by anthony »

When numbering images it is a good idea to ensure you have leading zeros on a fixed length number.
This way the filename will sort correctly alphabetically.

When generating images with IM you can use..
convert .... image_%04d.jpg

to generate 4 digit numbers with leading zeros


But if you already have images, I have a script that I use to 'fix' the numbers.
It is called mv_renum
http://www.ict.griffith.edu.au/anthony/ ... /#mv_renum

the script can also be named (or symbolic linked from) mv_reseq
which by default renumbers images in numerical order from 1 onwards. But has options to re-sequence image numbers from a specific number, and optionally leave numerical 'gaps' between images (useful for re-organizing an image sequence).

They are simple shell scripts, though you may need to edit the script slightly to use 'mv' rather than 'merge' (a safe never overwrite mv command).

I use these scripts all the time with numbered files (not just images).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how do you vertically stack every 4 images into 1 image?

Post by fmw42 »

I think you will have to create 10 lists of 100 images and then run those lists as input images to montage.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: how do you vertically stack every 4 images into 1 image?

Post by anthony »

IM v7 will allow you to read single images from a file stream, and controlled from a shell script using co-processing methods. At this time however, only simple 'test' methods have been attempted.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User
Posts: 13
Joined: 2013-05-19T01:13:51-07:00
Authentication code: 6789

Re: how do you vertically stack every 4 images into 1 image?

Post by User »

Image

update
new examples with 400 images to be better equated to my 1000 image problem
http://www.mediafire.com/download.php?2do6udd3htca232
fmw42 wrote:
You can make 10 montage commands to choose the 100 images you need and change the output name as well. You can use frame numbers to control the images to choose. For example,

montage '*.jpg[0-99]' -geometry +0+0 -tile 1x4 result_1_%d.png
montage '*.jpg[100-199]' -geometry +0+0 -tile 1x4 result_2_%d.png
...
montage '*.jpg[900-999]' -geometry +0+0 -tile 1x4 result_10_%d.png

EDIT: This works. The images must be put into a multi-frame format

convert rose*.jpg miff:- | montage -[0-1] -tile 1x2 result.png

So your commands should be:

convert rose*.jpg miff:- | montage -[0-99] -geometry +0+0 -tile 1x4 result_1_%d.png
convert rose*.jpg miff:- | montage -[100-199] -geometry +0+0 -tile 1x4 result_2_%d.png
...
convert rose*.jpg miff:- | montage -[900-999] -geometry +0+0 -tile 1x4 result_10_%d.png

Code: Select all

montage '*.png[001-100]' -geometry +0+0 -tile 1x4 vert_0%d.png
doesn't work. nothing happened

Code: Select all

convert *rect.png miff:- | montage -[001-100] -geometry +0+0 -tile 1x4 result_1-%d.png
doesn't work. the images are messed up. but it did only read 100 images

Code: Select all

convert *-rect.png miff:- | montage -[001-100] -geometry +0+0 -tile 1x4 result_1-%d.png
doesn't work. images messed up

Code: Select all

convert *-rect.png miff:- | montage -[0-99] -geometry +0+0 -tile 1x4 result_1-%d.png
doesn't work. images messed up

i don't know why it's not working on mine

Code: Select all

C:\Users\User\1\rectvert>montage *rect.png -tile 1x4 -geometry +0+0 vert.png

C:\Users\User\1\rectvert>montage '*.png[001-100]' -geometry +0+0 -tile 1x4 vert_
0%d.png
montage.exe: unable to open image `'*.png[001-100]'': Invalid argument @ error/b
lob.c/OpenBlob/2644.
montage.exe: unable to open module file `C:\Program Files (x86)\ImageMagick-6.8.
5-Q16\modules\coders\IM_MOD_RL_PNG[001-100]'_.dll': No such file or directory @
warning/module.c/GetMagickModulePath/683.
montage.exe: no decode delegate for this image format `'*.png[001-100]'' @ error
/constitute.c/ReadImage/552.
montage.exe: missing an image filename `vert_0%d.png' @ error/montage.c/MontageI
mageCommand/1778.

C:\Users\User\1\rectvert>convert *rect.png miff:- | montage -[001-100] -geometry
 +0+0 -tile 1x4 result_1-%d.png

C:\Users\User\1\rectvert>convert *-rect.png miff:- | montage -[001-100] -geometr
y +0+0 -tile 1x4 result_1-%d.png

C:\Users\User\1\rectvert>convert *-rect.png miff:- | montage -[0-99] -geometry +
0+0 -tile 1x4 result_1-%d.png

C:\Users\User\1\rectvert>convert *-rect.png | montage -[0-99] -geometry +0+0 -ti
le 1x4 result_1%d.png
montage.exe: no decode delegate for this image format `C:/Users/User/AppData/Loc
al/Temp/magick-844tMVY8N2YHwGb' @ error/constitute.c/ReadImage/552.
montage.exe: missing an image filename `result_1%d.png' @ error/montage.c/Montag
eImageCommand/1778.

C:\Users\User\1\rectvert>convert *-rect.png | montage -[0-99] -geometry +0+0 -ti
le 1x4 result_1%d.png
montage.exe: no decode delegate for this image format `C:/Users/User/AppData/Loc
al/Temp/magick-6988zEuMOZMslTYm' @ error/constitute.c/ReadImage/552.
montage.exe: missing an image filename `result_1%d.png' @ error/montage.c/Montag
eImageCommand/1778.

C:\Users\User\1\rectvert>convert *-rect.png miff:- | montage -[0-99] -geometry +
0+0 -tile 1x4 result_1-

C:\Users\User\1\rectvert>
C:\Users\User\1\rectvert>%d.png
'%d.png' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\User\1\rectvert>
C:\Users\User\1\rectvert>convert *-rect.png miff:- | montage -[0-99] -geometry +
0+0 -tile 1x4 result_1-%d.png

C:\Users\User\1\rectvert>
fmw42 wrote:I think you will have to create 10 lists of 100 images and then run those lists as input images to montage.
i think it has successfully only converted the specified 100 images
but there's the whole images not coming out right thing
anthony wrote:IM v7 will allow you to read single images from a file stream, and controlled from a shell script using co-processing methods. At this time however, only simple 'test' methods have been attempted.
oh well...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how do you vertically stack every 4 images into 1 image?

Post by fmw42 »

You are on Windows and I tested on Mac (unix). There may be different syntax issue with the two OS systems. I don't know windows so cannot help further. Does Windows support piping?

This should work on Unix, (but you may need to escape the % as %% on windows)

convert *rect.png miff:- | montage -[0-99] -geometry +0+0 -tile 1x4 result_1-%d.png

Note frame numbers do not use leading zeros. This is wrong [000-099].

The problem is that *rect.png will contain all 1000 images and put that into the miff:-. So you may still run out of memory. That is why I suggested you create 10 lists. You can use some windows command such as unix ls to get all the file names and put them into an array. Then you can filter the array for 10 sets of 100 images as lists. Then use the lists for input for montage.
Post Reply