80cdac18dc
CI / test (push) Has been cancelled
cropThumbnailImage was filling the target box by aspect-cover — for a portrait crop served to a landscape device (or vice versa), that meant slicing a thin band through the photo, which the user correctly called out as unacceptable on the screen. Switching to thumbnailImage(... bestfit=true) + composite onto a white canvas of exact target dims means the photo always shows up upright and recognizable: matching aspect renders byte-identically to before (no padding, no zoom change), mismatched aspect shows the photo fit-to-box with white bars instead of a cropped slice. Adds an app:rerender-assets console command to reset every Ready asset to Pending and re-dispatch its render message — needed once after this deploy so existing bins (rendered with the old cropThumbnail logic) get regenerated with the letterbox pipeline. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
59 lines
1.8 KiB
PHP
59 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Command;
|
|
|
|
use App\Entity\RenderedAsset;
|
|
use App\Enum\RenderStatus;
|
|
use App\Message\RenderImageMessage;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Symfony\Component\Console\Attribute\AsCommand;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
use Symfony\Component\Messenger\MessageBusInterface;
|
|
|
|
/**
|
|
* Resets every Ready RenderedAsset to Pending and re-dispatches a render
|
|
* message for it. Use after a renderer change so existing on-disk bins get
|
|
* regenerated with the new pipeline.
|
|
*/
|
|
#[AsCommand(
|
|
name: 'app:rerender-assets',
|
|
description: 'Reset all rendered assets and re-dispatch render messages',
|
|
)]
|
|
final class RerenderAssetsCommand extends Command
|
|
{
|
|
public function __construct(
|
|
private readonly EntityManagerInterface $em,
|
|
private readonly MessageBusInterface $bus,
|
|
) {
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
{
|
|
$io = new SymfonyStyle($input, $output);
|
|
|
|
$assets = $this->em->getRepository(RenderedAsset::class)->findAll();
|
|
$count = 0;
|
|
|
|
foreach ($assets as $asset) {
|
|
$asset->setStatus(RenderStatus::Pending)->setFilePath(null);
|
|
$this->bus->dispatch(new RenderImageMessage(
|
|
$asset->getImage()->getId(),
|
|
$asset->getDeviceModel()->value,
|
|
$asset->getOrientation()->value,
|
|
));
|
|
$count++;
|
|
}
|
|
|
|
$this->em->flush();
|
|
|
|
$io->success("Reset and re-dispatched $count rendered assets.");
|
|
return Command::SUCCESS;
|
|
}
|
|
}
|