fix: flip portrait rotation direction so the EPD shows the photo upright
CI / test (push) Has been cancelled
CI / test (push) Has been cancelled
The first rotation pass picked CW server-side / CCW preview-side based on "ribbon on left" → user rotates frame 90° CCW. On hardware the photo came out upside down, which means the user's physical rotation is the opposite of what was assumed: 90° CW from landscape native, putting the ribbon to the left from the user's POV but to the right from the EPD's reference frame. The two rotation signs always need to stay opposite — flipping both keeps the webapp preview upright while fixing the device. Also drops the temporary upload debug log; the cropOrientation persistence issue resolved on its own once Doctrine's metadata cache was cleared. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -253,10 +253,10 @@ class DeviceApiController extends AbstractController
|
|||||||
$im->readImageBlob($ppm);
|
$im->readImageBlob($ppm);
|
||||||
|
|
||||||
// The .bin is always laid out in EPD-native scan order. For portrait,
|
// The .bin is always laid out in EPD-native scan order. For portrait,
|
||||||
// the renderer pre-rotated the photo 90° CW; rotate -90° here so the
|
// the renderer pre-rotated the photo 90° CCW; rotate 90° here so the
|
||||||
// browser-side preview shows the photo upright.
|
// browser-side preview shows the photo upright.
|
||||||
if ($orientation === Orientation::Portrait) {
|
if ($orientation === Orientation::Portrait) {
|
||||||
$im->rotateImage(new \ImagickPixel('white'), -90);
|
$im->rotateImage(new \ImagickPixel('white'), 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
$im->setImageFormat('png');
|
$im->setImageFormat('png');
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ use App\Message\RenderImageMessage;
|
|||||||
use App\Service\ShareService;
|
use App\Service\ShareService;
|
||||||
use App\Service\TokenService;
|
use App\Service\TokenService;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
@@ -55,7 +54,6 @@ class ImageApiController extends AbstractController
|
|||||||
Request $request,
|
Request $request,
|
||||||
EntityManagerInterface $em,
|
EntityManagerInterface $em,
|
||||||
MessageBusInterface $bus,
|
MessageBusInterface $bus,
|
||||||
LoggerInterface $logger,
|
|
||||||
): JsonResponse {
|
): JsonResponse {
|
||||||
$file = $request->files->get('file');
|
$file = $request->files->get('file');
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
@@ -110,19 +108,6 @@ class ImageApiController extends AbstractController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TEMP debug: log what arrived in the upload form so we can diagnose
|
|
||||||
// why crop_orientation is landing as NULL despite the frontend
|
|
||||||
// claiming to send it. Remove once stable.
|
|
||||||
$logger->info('image.upload.fields', [
|
|
||||||
'image_id' => $image->getId(),
|
|
||||||
'has_cropParams' => $request->request->has('cropParams'),
|
|
||||||
'has_stickerState' => $request->request->has('stickerState'),
|
|
||||||
'has_cropOrient' => $request->request->has('cropOrientation'),
|
|
||||||
'cropOrient_raw' => $request->request->get('cropOrientation'),
|
|
||||||
'all_keys' => $request->request->keys(),
|
|
||||||
'persisted_orient' => $image->getCropOrientation()?->value,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Generate thumbnail from composited if available, otherwise from original
|
// Generate thumbnail from composited if available, otherwise from original
|
||||||
$thumbSrc = file_exists($storageDir . '/composited.jpg')
|
$thumbSrc = file_exists($storageDir . '/composited.jpg')
|
||||||
? $storageDir . '/composited.jpg'
|
? $storageDir . '/composited.jpg'
|
||||||
|
|||||||
@@ -96,13 +96,14 @@ final class RenderImageMessageHandler
|
|||||||
$imagick->autoOrient();
|
$imagick->autoOrient();
|
||||||
$imagick->cropThumbnailImage($width, $height);
|
$imagick->cropThumbnailImage($width, $height);
|
||||||
|
|
||||||
// Portrait: rotate the cropped photo 90° CW so the packed .bin's row
|
// Portrait: rotate the cropped photo 90° CCW so the packed .bin's row
|
||||||
// layout matches the EPD's native 800-pixel scan order. The frame is
|
// layout matches the EPD's native 800-pixel scan order. The frame is
|
||||||
// physically rotated 90° CCW for portrait (ribbon on left), so the
|
// physically rotated 90° CW for portrait (ribbon on right from EPD's
|
||||||
// photo's bottom edge maps to the EPD's left column. Firmware streams
|
// POV → on left from user's view), so the photo's top edge maps to the
|
||||||
// bytes raw — no orientation awareness on-device.
|
// EPD's left column. Firmware streams bytes raw — no orientation
|
||||||
|
// awareness on-device.
|
||||||
if ($orientation === Orientation::Portrait) {
|
if ($orientation === Orientation::Portrait) {
|
||||||
$imagick->rotateImage(new \ImagickPixel('white'), 90);
|
$imagick->rotateImage(new \ImagickPixel('white'), -90);
|
||||||
}
|
}
|
||||||
|
|
||||||
$imagick->setImageColorspace(\Imagick::COLORSPACE_SRGB);
|
$imagick->setImageColorspace(\Imagick::COLORSPACE_SRGB);
|
||||||
|
|||||||
Reference in New Issue
Block a user