Remove EXIF data from JPG using PHP

tau picture tau · Sep 1, 2010 · Viewed 46.5k times · Source

Is there any way to remove the EXIF data from a JPG using PHP? I have heard of PEL, but I'm hoping there's a simpler way. I am uploading images that will be displayed online and would like the EXIF data removed.

Thanks!

EDIT: I don't/can't install ImageMagick.

Answer

Bill H picture Bill H · Sep 1, 2010

A fast way to do it in PHP using ImageMagick (Assuming you have it installed and enabled).

<?php

$images = glob('*.jpg');

foreach($images as $image) 
{   
    try
    {   
        $img = new Imagick($image);
        $img->stripImage();
        $img->writeImage($image);
        $img->clear();
        $img->destroy();

        echo "Removed EXIF data from $image. \n";

    } catch(Exception $e) {
        echo 'Exception caught: ',  $e->getMessage(), "\n";
    }   
}
?>