From 278f091aa2231d0272bf51eaaab46a7a9080b3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Busse?= Date: Mon, 23 Jan 2017 22:07:32 +0100 Subject: [PATCH] Convert jpg to png --- xkcdlock | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/xkcdlock b/xkcdlock index ef882d2..e7c7a4e 100755 --- a/xkcdlock +++ b/xkcdlock @@ -23,7 +23,6 @@ # # TODO: # - Make sure we do not exceed screen boundaries in x and y -# - Convert non-png to png # - Improve tooltip text border overflow prevention # wrt display resolution (and font size?) # - Add support for other screen lockers @@ -164,11 +163,15 @@ xkcd_get_all_images() { continue fi - log "Downloading ${i} ${img_url_hotlink} (${img_name})" + log "Downloading #${i} ${img_url_hotlink} (${img_name})" $(curl -s $img_url_hotlink -o $img_name) if (( 0 != "$?" )); then error "Failed to download ${i}" fi + + if [ "${img_name: -3}" == "jpg" ]; then + convert_image $img_name + fi done echo 0 @@ -231,6 +234,14 @@ get_random_image() { echo "$img_fn" } +convert_image() { + local img_name_len=$((${#img_name} - 4)) + local img_name_png=${img_name:0:$img_name_len}".png" + log "Converting $img_name to $img_name_png" + $(convert $img_name $img_name_png) + $(rm -f $img_name) +} + image_add_text() { local tmp_file=$(mktemp)