self::MAX_W || $is[1] > self::MAX_H) self::$error = Lang::account('selectAvatar'); } else self::$error = Lang::account('selectAvatar'); if (!self::$error) return true; self::$fileName = ''; return false; } /* create icon texture atlas * ****************************** * * LARGE * MEDIUM * * * * * * * * * * * ************* * * * SMOL * * * * * * * * * ********* * * ****************************** * * as static/uploads/avatars/.jpg */ public static function createAtlas(string $fileName) : bool { if (!self::$img) return false; $sizes = [ICON_SIZE_LARGE, ICON_SIZE_MEDIUM, ICON_SIZE_SMALL]; $dest = imagecreatetruecolor(ICON_SIZE_LARGE + ICON_SIZE_MEDIUM, ICON_SIZE_LARGE); $srcW = imagesx(self::$img); $srcH = imagesx(self::$img); $destX = $destY = 0; foreach ($sizes as $idx => $dim) { imagecopyresampled($dest, self::$img, $destX, $destY, 0, 0, $dim, $dim, $srcW, $srcH); if ($idx % 2) $destY += $dim; else $destX += $dim; } if (!imagejpeg($dest, sprintf(self::PATH_AVATARS, $fileName), self::JPEG_QUALITY)) return false; self::$img = null; $dest = null; return true; } /*************/ /* Admin Mgr */ /*************/ // unsure yet how that's supposed to work // for now pending uploads can be used right away } ?>