DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Picture To Excel
// description of your code here
import Image
from win32com.client import Dispatch
e=Dispatch('Excel.Application')
e.visible=0
q=1
try:
im=Image.open(r'D:\picture.jpg')
w,h=im.size
print w
for i in range(1,w/q):
print i
for ii in range(1,h/q):
col=im.getpixel((i*q,ii*q))
rgb=hex(col[2])[2:]+hex(col[1])[2:]+hex(col[0])[2:]
e.cells(ii,i).Interior.Color=int(rgb,16)
except:
e.visible=1
e. visible=1





