Undefined variable $dif
https://github.com/SimpleMachines/SMF2.1/blob/release-2.1/Sources/Class-Graphics.php#L304
if (($idx == -1) || ($d < $dif))
{
$idx = $i;
$dif = $d;
}
$dif is undefined anywhere in scope.
This is old code that was written by someone else not involved with SMF (see the information in the file header comments). It's only used if you don't have the appropriate GIF functions via GD. I don't know that there's much SM can do about this.
make GD required PHP extension and remove old code from repo forever.
Could try to define $dif = null; before the for loop and see if that resolves it. It should be how PHP would handle this before.
Indeed this is only an issue on host with weird configurations, ie, when they explicitly need a var to be set, not a bad policy or bad configuration, in fact I favor var declaration for everything
vars must be defined always. Silent definition is bad practice