[Ilugc] to truncate a long rectangular image into several smaller imageusing php and gd

  • From: lawgon@xxxxxxxxxxxxxxx (Kenneth Gonsalves)
  • Date: Sat Jan 23 16:14:49 2010

On Friday 22 Jan 2010 12:46:10 pm Mahalingam Subramaniam wrote:

the aim is to cut and append one below other a long rectangular image of
 4500*80 pixels png image using php script with g


just to experiment - cut a 1000 by 100 image into 10 and pasted in a fresh 
image 100 by 1000

#!/usr/bin/python

from PIL import Image

#create image in red 1000x100
am = Image.new('RGB',(1000,100),'red')

#create image in black 100x1000
im = Image.new('RGB',(100,1000))
#slice first image and paste into second
for x in range(0,1000,100):
    sm = am.crop((x,0,x+100,100))
    ym = im.paste(sm,(0,x,100,x+100))
im.show()

I'm sure perl guys can do it in one line ;-)
-- 
regards
kg
http://lawgon.livejournal.com

Other related posts: