Add command to reprocess existing media with correct aspect-ratio scaling

ProcessMedia was using resize(), which distorts images that aren't the
target aspect ratio; scale() preserves it. Existing medium/small
variants generated before this fix need regenerating, so add an
artisan command (with --dry-run) to do that, plus feature tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Jonny Barnes 2026-07-02 20:00:30 +01:00
commit 4569abc351
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
3 changed files with 175 additions and 2 deletions

View file

@ -56,10 +56,10 @@ class ProcessMedia implements ShouldQueue
// foo.bar.png => ['foo', 'bar', 'png'] => ['foo', 'bar'] => foo.bar
$basename = trim(implode('.', $filenameParts), '.');
$medium = $image->resize(width: 1000);
$medium = $image->scale(width: 1000);
Storage::disk('public')->put($basename.'-medium.'.$extension, (string) $medium->encode());
$small = $image->resize(width: 500);
$small = $image->scale(width: 500);
Storage::disk('public')->put($basename.'-small.'.$extension, (string) $small->encode());
}