accept('cms/gross.png', $this->png(3000, 1500, transparent: true)); [$width, $height] = getimagesizefromstring(Storage::disk('media_derived')->get($element->thumbnail_path)); $this->assertSame([2400, 1200], [$width, $height]); $image = imagecreatefromstring(Storage::disk('media_derived')->get($element->thumbnail_path)); $this->assertGreaterThan(240, imagecolorat($image, 5, 5) & 0xFF, 'Transparenz wird weiß, nicht schwarz.'); } public function test_small_images_are_not_enlarged(): void { $element = $this->accept('cms/klein.png', $this->png(800, 450)); [$width, $height] = getimagesizefromstring(Storage::disk('media_derived')->get($element->thumbnail_path)); $this->assertSame([800, 450], [$width, $height]); } private function accept(string $path, string $bytes): ContentElement { Storage::disk('cms_incoming')->put($path, $bytes); return app(WebsiteIntake::class)->acceptImage($path, 'Testbild')->refresh(); } private function png(int $width, int $height, bool $transparent = false): string { $image = imagecreatetruecolor($width, $height); if ($transparent) { imagesavealpha($image, true); imagefill($image, 0, 0, imagecolorallocatealpha($image, 0, 0, 0, 127)); } else { imagefill($image, 0, 0, imagecolorallocate($image, 30, 90, 160)); } ob_start(); imagepng($image); return (string) ob_get_clean(); } }