ExifTool Forum

ExifTool => Newbies => Topic started by: khav on September 18, 2016, 06:05:13 AM

Title: Removing exif data from images
Post by: khav on September 18, 2016, 06:05:13 AM
Hello ,
          I want to remove all exif data from a specific image upon upload.I coded this small function for it but it doesn't work as exif data is still present.I am pretty sure i am missing something in the command

function DeleteExif(&$path)
    {
        return shell_exec('exiftool -overwrite_original -P -q -all= '. $path);

    }


$path is just the PHP global file array here  i.e $_FILES['upfile']['tmp_name'] . $path should contain the uploaded image without the exif data
Title: Re: Removing exif data from images
Post by: Stephen Marsh on September 18, 2016, 07:12:59 AM
Have you tested the commands purely in ExifTool without using your PHP function?

What about removing the space after = ' to ='

These are the ones that usually work for me, with the second command often working better on mixed formats:

exiftool -overwrite_original_in_place -all= DIR

exiftool -overwrite_original_in_place -all= -CommonIFD0= DIR
Title: Re: Removing exif data from images
Post by: Phil Harvey on September 18, 2016, 07:27:17 AM
I would suggest quoting the file name in case it contains special characters.

- Phil
Title: Re: Removing exif data from images
Post by: khav on September 18, 2016, 07:54:57 AM
@Phil Harvey - The filename of the image don't contain any special characters
@Stephen

I tried the following command on ssh but i get `No file specified`


exiftool -overwrite_original_in_place -P -fast -q -all=/var/www/website.com/public_html/www/images/Ctt9oQsq.jpg

Title: Re: Removing exif data from images
Post by: Heiko on September 18, 2016, 08:03:04 AM
a space is missing after -all=
Title: Re: Removing exif data from images
Post by: FixEUser on September 18, 2016, 08:25:00 AM
Remove the -q (quiet) and check the answer from Exiftool.exe.
You should see why it doesn't remove the tags.
Title: Re: Removing exif data from images
Post by: khav on September 18, 2016, 08:55:22 AM
@FixEUser

Thanks for pointing that out....

With SSH on my centos 7 server
exiftool -overwrite_original_in_place -P -fast  -all= -CommonIFD0= /var/www/website.com/public_html/www/0XIWB7CQ.jpg
    1 image files updated


I reuploaded the original file back to try with php this time

With php

$image_content_or_path = '/var/www/website.com/public_html/www/0XIWB7CQ.jpg';
echo shell_exec('exiftool -overwrite_original_in_place -P -fast  -all= -CommonIFD0= '. $image_content_or_path .'2>&1');


I get the following errors with php

test 0 image files updated 1 files weren't updated due to errors
Title: Re: Removing exif data from images
Post by: FixEUser on September 18, 2016, 09:03:52 AM
I see the following problems (not sure if they are the reason for your problem)
1.) You have a two spaces between -fast and -all=
2.) I'm not sure what you try with the combination -all= and -CommonIFD0=
-all= removes completely ALL tags, including -CommonIFD0=
3.) Why do you use -overwrite_original_in_place?
  -overwrite_original              Overwrite original by renaming tmp file
  -overwrite_original_in_place     Overwrite original by copying tmp file
4.) Are you sure that your script has enough access rights to
a) execute the exiftool
b) modify the picture /var/www/website.com/public_html/www/0XIWB7CQ.jpg
Title: Re: Removing exif data from images
Post by: khav on September 18, 2016, 09:29:59 AM
@FixEUser

Thanks a ton for helping me out thus far

1) I remove the extra space
2) Simplified the command
3) -overwrite_original_in_place   was a suggestion i got from Stephen
4) a).Yes i execute other command tools the same way (graphicsmagick , pngquant etc...)
    b) Try to modify the picture with graphics magick to decrease quality and it worked fine
Title: Re: Removing exif data from images
Post by: FixEUser on September 18, 2016, 09:41:05 AM
Sorry, I don't have any other ideas :(
Title: Re: Removing exif data from images
Post by: StarGeek on September 18, 2016, 11:38:36 AM
Your spacing at this point: $image_content_or_path .'2>&1');
is incorrect.  You are concating the 2 directly onto the end of the value of $image_content_or_path.

To take the file from your example, it ends up being /var/www/website.com/public_html/www/0XIWB7CQ.jpg2>&1.