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:
parent
dd203f6f31
commit
4569abc351
3 changed files with 175 additions and 2 deletions
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue