tags:

views:

86

answers:

2

Hi
I am tring to use the function ImageChops.dulpicate from the PIL module and I get an error I don't understand:

this is the code

import PIL import Image import ImageChops import os

PathDemo4a='C:/Documents and Settings/Ariel/My Documents/My Dropbox/lecture/demo4a' PathDemo4b='C:/Documents and Settings/Ariel/My Documents/My Dropbox/lecture/demo4b' PathDemo4c='C:/Documents and Settings/Ariel/My Documents/My Dropbox/lecture/demo4c' PathBlackBoard='C:/Documents and Settings/Ariel/My Documents/My Dropbox/lecture/BlackBoard.bmp'

Slides=os.listdir(PathDemo4a)

for slide in Slides: #BB=Image.open(PathBlackBoard) BB=ImageChops.duplicate(PathBlackBoard) #BB=BlackBoard

and this is the error;

Traceback (most recent call last): File "", line 1, in ImageChops.duplicate('c:/1.BMP') File "C:\Python26\lib\site-packages\PIL\ImageChops.py", line 57, in duplicate return image.copy() AttributeError: 'str' object has no attribute 'copy'

any help would be much appriciated

Ariel

+1  A: 

I think you should pass an actual image object to duplicate and not a string. So your code will probably become something like this for one image:

path = '...'
img = Image.open(path)
dup = ImageChops.duplicate(img)
muksie
+1  A: 

You need to pass a Image object into the duplicate function rather than a string. Something like:

img = Image.open(PathBlackBoard)
BB = ImageChops.duplicate(img) 
Andrew Cox