def set_image(self, filename):
raise NotImplementedError()
+ def convert_image_format(self, filename, format='BMP', allowAlpha=False, extension='.bmp'):
+ """Convert the image to another format, and store it in a local place"""
+ import PIL, PIL.Image
+
+ self.remove_old_image_cache()
+ output_name = os.path.join(self._ConvertedWallpaperLocation, '%s%s' % (time.time(), extension))
+ img = PIL.Image.open(filename)
+
+ # Remove the alpha channel if the user doens't want it
+ if not allowAlpha and img.mode == 'RGBA':
+ img = img.convert('RGB')
+ img.save(output_name, format)
+
+ return output_name, True
+
+
class WMakerChanger(BaseChanger):
name = "WindowMaker"
_ConvertedWallpaperLocation = '/tmp/wallpapers_wmaker/'
self.remove_old_image_cache()
output_name = os.path.join(self._ConvertedWallpaperLocation, '%s.png' % time.time())
try:
- import PIL, PIL.Image
- img = PIL.Image.open(file)
- img.save(output_name, "PNG")
- return output_name, True
+ return super(OSXChanger, self).convert_image_format(file, format='PNG', extension='.png')
except ImportError:
logging.debug('Could not load PIL, going to try just copying the image')
import shutil
for dirname in dirnames:
os.unlink(os.path.join(fullpath, dirname))
- def convert_image_format(self, file):
- """Convert the image to a bmp, and store it in a local place"""
- self.remove_old_image_cache()
- output_name = os.path.join(self._ConvertedWallpaperLocation, '%s.bmp' % time.time())
- import PIL, PIL.Image
- img = PIL.Image.open(file)
- if img.mode == 'RGBA':
- img = img.convert('RGB')
- img.save(output_name, 'BMP')
-
- return output_name, True
-
def set_image(self, filename):
import ctypes
user32 = ctypes.windll.user32