From b403f8f97a97f9f55205d57149fd355a09727bd4 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sat, 31 Dec 2022 15:20:17 +0000 Subject: [PATCH] Support the generation of icons from uniformly-coloured screenshots The square.pl script removed all pixels that were the same colour as the edge ones, even if that meant removing all of the pixels. Now it stops removing pixels at 1x1 so that there will be something left for ImageMagick to work on. --- icons/square.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/icons/square.pl b/icons/square.pl index 8a9a4bf..0a9352b 100755 --- a/icons/square.pl +++ b/icons/square.pl @@ -42,13 +42,13 @@ $back = $plist[0]; # Crop rows and columns off the image to find the central rectangle # of non-background stuff. $ystart = 0; -$ystart++ while $ystart < $h and scalar(grep { $_ ne $back } map { $data->[$ystart*$w+$_] } 0 .. ($w-1)) == 0; +$ystart++ while $ystart < $h - 1 and scalar(grep { $_ ne $back } map { $data->[$ystart*$w+$_] } 0 .. ($w-1)) == 0; $yend = $h-1; -$yend-- while $yend >= $ystart and scalar(grep { $_ ne $back } map { $data->[$yend*$w+$_] } 0 .. ($w-1)) == 0; +$yend-- while $yend > $ystart and scalar(grep { $_ ne $back } map { $data->[$yend*$w+$_] } 0 .. ($w-1)) == 0; $xstart = 0; -$xstart++ while $xstart < $w and scalar(grep { $_ ne $back } map { $data->[$_*$w+$xstart] } 0 .. ($h-1)) == 0; +$xstart++ while $xstart < $w - 1 and scalar(grep { $_ ne $back } map { $data->[$_*$w+$xstart] } 0 .. ($h-1)) == 0; $xend = $w-1; -$xend-- while $xend >= $xstart and scalar(grep { $_ ne $back } map { $data->[$_*$w+$xend] } 0 .. ($h-1)) == 0; +$xend-- while $xend > $xstart and scalar(grep { $_ ne $back } map { $data->[$_*$w+$xend] } 0 .. ($h-1)) == 0; # Decide how much border we're going to put back on to make the # image perfectly square.