Affichage image .heic, liipimagine et upload

Par caema, il y a 6 ans


Bonjour a toutes et tous,

Je travaille sur le développement d'une web-app, principalement utilisée avec un smartphone.
Dans mon application, l'utilisateur peut télécharger une photo pour son profil.

Contexte technique: Symfony 4.4, liipimagine bundle.

En gros, mon upload fonctionne parfaitement bien.
Mon problème se situe lors de l'upload d'une photo depuis un iphone : je ne peux pas afficher le fichier .heic via le systeme de filters de liip

J'aimerais pouvoir convertir le fichier .heic, ou simplement l'afficher

Voici mon code :

// CONTROLLER if ($form->isSubmitted() && $form->isValid()) { $uploadedFile = $form['imageFilename']->getData(); if ($uploadedFile) { $newFilename = $uploaderHelper->uploadUserImage($uploadedFile, $currentUser); $currentUser->setImageFilename($newFilename); $entityManager->persist($currentUser); $entityManager->flush(); } return $this->redirectToRoute('users_participants_list'); } // CLASS UPLOADERHELPER class UploaderHelper { const USER_IMAGE = 'user_image'; /** @var string $uploadsPath */ private $uploadsPath; /** * @var RequestStackContext */ private $requestStackContext; /** * UploaderHelper constructor. * @param string $uploadsPath * @param RequestStackContext $requestStackContext */ public function __construct(string $uploadsPath, RequestStackContext $requestStackContext) { $this->uploadsPath = $uploadsPath; $this->requestStackContext = $requestStackContext; } /** * @param UploadedFile $uploadedFile * @param Users $user * @return string */ public function uploadUserImage(UploadedFile $uploadedFile, Users $user): string { /** @var string $destination */ $destination = $this->uploadsPath . '/' . self::USER_IMAGE; /** @var string $originalFilename */ $originalFilename = pathinfo($uploadedFile->getClientOriginalName(), PATHINFO_FILENAME); if ($uploadedFile->guessExtension() == 'heic') { // We need to convert the image ? } /** @var string $newFilename */ $newFilename = strtolower($user->getName()).'_'.strtolower($user->getSurname()).'-'.uniqid().'.'.$uploadedFile->guessExtension(); $uploadedFile->move($destination, $newFilename); return $newFilename; } /** * @param string $path * @return string */ public function getPublicPath(string $path): string { return $this->requestStackContext->getBasePath() . '/uploads/' . $path; } // Config liip liip_imagine: # valid drivers options include "gd" or "gmagick" or "imagick" driver: "imagick" filter_sets: squared_thumbnail_small: filters: thumbnail: size: [200, 200] // View {% if currentUser.imageFilename %} <img src="{{ uploaded_asset(currentUser.imagePath)|imagine_filter('squared_thumbnail_small') }}" alt="{{ currentUser.name }} {{ currentUser.surname }}">#} {% endif %}

Merci pour votre aide

Aucune réponse