config->getAppValue('theming', 'logoDimensions'); if (preg_match('/^\d+x\d+$/', $logoDimensions)) { $output->info('Logo dimensions are already known'); return; } try { /** @var ImageManager $imageManager */ $imageManager = Server::get(ImageManager::class); } catch (\Throwable) { $output->info('Theming is disabled'); return; } if (!$imageManager->hasImage('logo')) { $output->info('Theming is not used to provide a logo'); return; } try { try { $simpleFile = $imageManager->getImage('logo', false); $image = @imagecreatefromstring($simpleFile->getContent()); } catch (NotFoundException|NotPermittedException) { $simpleFile = $imageManager->getImage('logo'); $image = false; } } catch (NotFoundException|NotPermittedException) { $output->info('Theming is not used to provide a logo'); return; } $dimensions = ''; if ($image !== false) { $dimensions = imagesx($image) . 'x' . imagesy($image); } elseif (str_starts_with($simpleFile->getMimeType(), 'image/svg')) { $matched = preg_match('/viewbox=["\']\d* \d* (\d*\.?\d*) (\d*\.?\d*)["\']/i', $simpleFile->getContent(), $matches); if ($matched) { $dimensions = $matches[1] . 'x' . $matches[2]; } } if (!$dimensions) { $output->warning('Failed to read dimensions from logo'); $this->config->deleteAppValue('theming', 'logoDimensions'); return; } $dimensions = imagesx($image) . 'x' . imagesy($image); $this->config->setAppValue('theming', 'logoDimensions', $dimensions); $output->info('Updated logo dimensions: ' . $dimensions); } }