Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'int' object has no attribute '__getitem__' #3

Open
lol768 opened this issue Jun 14, 2015 · 3 comments
Open

TypeError: 'int' object has no attribute '__getitem__' #3

lol768 opened this issue Jun 14, 2015 · 3 comments
Assignees
Labels

Comments

@lol768
Copy link

lol768 commented Jun 14, 2015

➜  gradify git:(master) ✗ python gradify.py -f bg.jpg      
Traceback (most recent call last):
  File "gradify.py", line 315, in <module>
    foo = Gradify()
  File "gradify.py", line 57, in __init__
    self.get_file(self.args.file)
  File "gradify.py", line 197, in get_file
    self.get_directions(filen)
  File "gradify.py", line 88, in get_directions
    col = self.get_colors()
  File "gradify.py", line 262, in get_colors
    return self.findBestColors()
  File "gradify.py", line 293, in findBestColors
    diff = self.get_RGB_diff(col_dict["col"], self.colors[i][1])
  File "gradify.py", line 266, in get_RGB_diff
    return abs(1.4*abs(old[0]-new[0])**(1/2.0) + .8*abs(old[1]-new[1])**(1/2.0) + .8*abs(old[2]-new[2])**(1/2.0))**(1/2.0)
TypeError: 'int' object has no attribute '__getitem__'
➜  gradify git:(master) ✗ md5sum bg.jpg 
d91c1f965139603990d138e39ba7b358  bg.jpg
➜  gradify git:(master) ✗ python -V
Python 2.7.6
➜  ~  lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:    14.04
Codename:   trusty
➜  ~  uname -a      
Linux gntpc 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:36:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Image: https://imgrush.com/2RwfllE5YDmQ.jpg

@fraser-hemp fraser-hemp self-assigned this Jun 14, 2015
@fraser-hemp
Copy link
Owner

As far as I can tell, because the image only contains greys (x,x,x) PIL compresses the tuples to ints for some reason? I'll check if there's a more elegant way of preventing this rather than a hacky if to check the length of the tuple/int and extend it

@lol768
Copy link
Author

lol768 commented Jun 14, 2015

Ah, that makes sense. To workaround this, I opened the image in GIMP and set the colour mode to RGB (was originally greyscale) then re-exported it.

@fraser-hemp
Copy link
Owner

yeah that'll work for now. i'll leave this open and fix it after my exams!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants