Over a million developers have joined DZone.

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
Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}