Big seamless Image

You want to create something as cool as this automatically? And i dont mean the Quadrokopter. 😉 Its about creating the big seamless image out of single images.

Now you can. And here is the  python code:

# Description:
# This small programm copies all images in a given directory to one big image allong the Horizontal axis
# and aligns them at top
#
# Author: Norbert Feurle
# Date: 13.1.2012
# Filename: figadd.py
# Copyright by Norbert
#
# usage: python figadd.py Imagedirectory

import os,sys
import Image

ImageDir="./"

if __name__ == "__main__":
  if len(sys.argv)>1:
    ImageDir=sys.argv[1]

  FilelistDir=os.listdir(ImageDir)

  SumSizeX=0
  MaxY=0
  ImageList=[]
  for indImg in FilelistDir:
	  try:
		  Data=Image.open(ImageDir+indImg)
		  xSize=Data.size[0]
		  ySize=Data.size[1]
		  SumSizeX=SumSizeX+xSize
		  ImageList.append(ImageDir+indImg)
		  if MaxY<ySize:
			  MaxY=ySize
	  except IOError:
		  print "cannot convert ", indImg

  Fullimage=Image.new("RGB",(SumSizeX,MaxY))
  aktualX=0
  for index,infile in enumerate(ImageList):
	  #f, e = os.path.splitext(infile)

	  try:
		  Data=Image.open(infile)
		  Fullimage.paste(Data,(aktualX,0,aktualX+Data.size[0],Data.size[1]))
		  aktualX=aktualX+Data.size[0]
		  print "Adding ", infile
	  except IOError:
		  print "cannot convert", infile

  Fullimage.save(ImageDir+"Fullimage.jpg")
  print "-"*30
  print "Fullimage.jpg created"

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: