log = logging.getLogger(APP_NAME)
verbose = 1
-fsize_title = 16
-fsize_subtitle = 11
+fsize_title = 20
+fsize_subtitle = 12
+ssize_title = 2
+ssize_subtitle = 1
font = '/usr/share/fonts/corefonts/verdanab.ttf'
if not os.path.exists(font):
font = '/usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf'
+opacity = 0.6
#-------------------------------------------------------------------------
def init_logging():
title = os.path.basename(wpaper)
title = re.sub(r'\.[^\.]*$', '', title)
+title = re.sub(r'_+', ' ', title)
new_img_fname = '/tmp/wallpaper.jpg'
old_img = Image(filename = wpaper)
screen_height = get_max_monitor_height()
new_width = int(float(old_img.width) / float(old_img.height) * float(screen_height))
-log.debug("Resizing image to %d x %d.", new_width, screen_height)
-new_img.resize(new_width, screen_height)
+log.debug("Old image size: %d x %d.", old_img.width, old_img.height)
-black = Color('srgba(0,0,0,0.5)')
-white = Color('srgba(255,255,255,0.5)')
+x_plus = int(float(new_width) * 1.01)
+x_minus = int(float(new_width) * 0.99)
+y_plus = int(float(screen_height) * 1.01)
+y_minus = int(float(screen_height) * 0.99)
+
+if (old_img.width < x_minus or old_img.width > x_plus or
+ old_img.height < y_minus or old_img.height > y_plus):
+ log.debug("Resizing image to %d x %d.", new_width, screen_height)
+ new_img.resize(new_width, screen_height)
+
+black = Color('srgba(0,0,0,%0.1f)' % (opacity))
+white = Color('srgba(255,255,255,%0.1f)' % (opacity))
draw = Drawing()
draw.stroke_color = black
draw.text_antialias = True
draw.text_alignment = 'center'
-draw.stroke_width = 1
+draw.stroke_width = ssize_title
draw.text_encoding = 'utf-8'
draw.font = font
draw.font_size = fsize_title
draw.text(x, y, title)
draw.font_size = fsize_subtitle
+draw.stroke_width = ssize_subtitle
fm = draw.get_font_metrics(new_img, wpaper, False)
x = int(new_img.width / 2)
y = int(fm.text_height) + y + 5