Skip to content

Commit e7d83d9

Browse files
authored
Imported submodule explicitly from PIL to fix bug (#10955)
When running the Account Details app directly ($ cinnamon-settings user), user is unable to change their user picture using the "Browse for more pictures..." option. This is because the Image submodule is not automatically imported with PIL (https://stackoverflow.com/questions/11911480/python-pil-has-no-attribute-image), and produces an " AttributeError: module 'PIL' has no attribute 'Image' " on line 204. This change is already present in cinnamon-settings/modules/cs_backgrounds.py
1 parent fc09a50 commit e7d83d9

File tree

1 file changed

+5
-5
lines changed
  • files/usr/share/cinnamon/cinnamon-settings/modules

1 file changed

+5
-5
lines changed

files/usr/share/cinnamon/cinnamon-settings/modules/cs_user.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import os
1515
import subprocess
1616

17-
import PIL
17+
from PIL import Image
1818
import gi
1919
gi.require_version('AccountsService', '1.0')
2020
from gi.repository import AccountsService, GLib, GdkPixbuf
@@ -146,7 +146,7 @@ def _on_face_photo_menuitem_activated(self, menuitem):
146146
path = "/tmp/temp-account-pic07.jpeg"
147147

148148
# Crop the image to thumbnail size
149-
image = PIL.Image.open(path)
149+
image = Image.open(path)
150150
width, height = image.size
151151

152152
if width > height:
@@ -165,7 +165,7 @@ def _on_face_photo_menuitem_activated(self, menuitem):
165165
bottom = (height + new_height) / 2
166166

167167
image = image.crop((left, top, right, bottom))
168-
image.thumbnail((255, 255), PIL.Image.ANTIALIAS)
168+
image.thumbnail((255, 255), Image.ANTIALIAS)
169169

170170
face_path = os.path.join(self.accountService.get_home_dir(), ".face")
171171

@@ -201,8 +201,8 @@ def _on_face_browse_menuitem_activated(self, menuitem):
201201
response = dialog.run()
202202
if response == Gtk.ResponseType.OK:
203203
path = dialog.get_filename()
204-
image = PIL.Image.open(path)
205-
image.thumbnail((255, 255), PIL.Image.ANTIALIAS)
204+
image = Image.open(path)
205+
image.thumbnail((255, 255), Image.ANTIALIAS)
206206
face_path = os.path.join(self.accountService.get_home_dir(), ".face")
207207
image.save(face_path, "png")
208208
self.accountService.set_icon_file(face_path)

0 commit comments

Comments
 (0)