views:

168

answers:

4

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.

+1  A: 

Hey @tau,

I completely misunderstood your question.

You could use some command line tool to do this job. or write your own php extension to do it. have a look at this lib that would be useful: http://www.sno.phy.queensu.ca/~phil/exiftool/

Cheers,

vfn

vfn
thanks, but i dont see how you can use exif.php to remove the data.
tau
+1  A: 

Use gd to recreate the graphical part of the image in a new one, that you save with another name.

See PHP gd

ring0
wont this cause a recompression of the jpg?? thanks.
tau
Use `$res = imagecreatefromjpeg($filename)` to load the image, then `imagejpeg ($res, $filename, QUALITY)`, put 100 to Quality - the loss, if any, should be minimal.
ring0
@ring0: thanks! ill try this as soon as i have the chance (later today).
tau
@ring0: sorry for the late response, but this method does indeed work. unfortunately it does recompress, so ill have to figure out what is more important to me as long as i dont have imagemagick installed.
tau
+1  A: 

I'm not pretty sure about it, but if its possible using GD o ImageMagick, the first thing that come to my mind is to create a new Image and add the old image to the new one.

Garis Suero
+2  A: 

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";
    }   
}
?>
Bill H
thank you, but i dont have it installed.
tau