php - remove Exiff from UploadedFile Symfony


I have form that use to upload picture. I can't save this picture on my server, But I send it to another service ( external)

I have to encode base 64

my code is:

$base_img = base64_encode(file_get_contents($data["image"]));

where $data['image'] is UploadedFile

How can Remove all Exiff from $data['image'] before encode?




Recently I needed exactly that and I achieved it with passing$uploadedFile->getRealPath() to the Imagick. Complete function:

 * @param UploadedFile $uploadedFile
 * @throws \ImagickException
public function stripMeta(UploadedFile $uploadedFile): void
    $img = new Imagick($uploadedFile->getRealPath());
    $profiles = $img->getImageProfiles("icc", true);
    if(!empty($profiles)) {
        $img->profileImage("icc", $profiles['icc']);

I took saving icc profile idea from comments here:

People are also looking for solutions to the problem: php - How to use array_filter in Node.js


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.