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
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
I would suggest quoting the file name in case it contains special characters.
- Phil
@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
a space is missing after -all=
Remove the -q (quiet) and check the answer from Exiftool.exe.
You should see why it doesn't remove the tags.
@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
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
@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
Sorry, I don't have any other ideas :(
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.