views:

38

answers:

0

I have written this code which inserts the fonts according to user inputed phrase in to the main image (srcImage), i am not getting any errors, but i am not seeing the result not sure where the logic error is? The arguments was the image and phrase Hi. I have tested that letter fonts do open and correct rgb values are extracted, the fonts are white but are surrounded by pure green so i need to remove the green, use only the white text. Fonts are around w = 20 and h = 40 and srcImage is w = 400 h= 300. I am new to python, having nested loops is little hard to make it bound in such as there is no end or C way of saying this is inside the loop and this is outside. Note also i could have used paste or write functions of image but this assignment forbids me to use those functions (can only use load, save, putpixel, getpixel).

Edited: Sx = letter image x , Sw = letter image width
Sy = letter image y, Sh = letter image height
Dx = big image (srcImage) x
Dy = big image y

Dx = 10
Dy = 35
for index,value in enumerate(phrase):
  if value in letters:
     image = letters[value]
     Sw,Sh = image.size
     for Sy in range(Sh):
         for Sx in range(Sw):
             r,g,b = image.getpixel((Sx,Sy))
             if g == 0:
                srcImage.putpixel((Dx,Dy),(r,g,b))
                Dx = Dx + 1
             else: Dx = Dx + 1
         Dx = 10
         Dy = Dy + 1 


srcImage.save('lolmini2.png')