How to resize images (width = average of the width of all images) and merge them vertically from top-to-bottom?
1 Answer
This is the imergv.py script, in Python, that does just that. Imagemagick is required.
Note that before running the script, you need to cd into the directory with the images. Some image viewers suited to view large images are Viewnior, Nomacs and Gwenview. The script will generate some tmpfXXXX.png images and a file called output.png with the end result.
#!/usr/bin/python
import os
f = os.popen('/bin/ls -1')
fil = f.read()
arfils = fil.split("\n")
arfils.pop()
num = 0
tot = 0
for snc in arfils:
f = os.popen( "/usr/bin/identify -ping -format '%w %h' " + '\"' + snc + '\"' ) rslt = f.read() woh = rslt.split(" ") intvl = int(woh[0]) tot = tot + intvl num = num + 1
avg = tot // num
#resize images
num = 1
allfil = ""
for snc in arfils: nout = "tmpf" + str(num).zfill(4) + ".png" allfil = allfil + nout + " " convcmd = "convert " + '\"' + snc + '\"' + " -resize " + str(avg) + " -quality 100 " convcmd = convcmd + '\"' + nout + '\"' #print convcmd f = os.popen(convcmd) num = num + 1
mrg = "convert -append " + allfil + "output.png"
f = os.popen(mrg)