Auto rotate and remove EXIF


is there a Kirby way to auto-rotate an uploaded image (see also) and remove selected exif-information?


Update: I found the required command to strip selected exif-data from a folder.

exiftool -geotag= foo.jpg
exiftool -geotag= -r FOLDERNAME 

How would I execute this command on all images as soon as I change status to visible?

You can use the hook:

When is this hook called? I am not sorting anything?

The sort hook is called when a page is sorted and when a page is made visible (i.e. make visible = sort)

Great, this is what I came up with:

kirby()->hook('', function($page) {
    //base_dir = '/var/www/ge/content/';
    $files = glob('/var/www/ge/content/' . $page->diruri() . '/*.{jpg,jpeg,JPG,JPEG}', GLOB_BRACE);
    foreach($files as $file) {
        exec ('/usr/bin/exiftool -overwrite_original -P -geotag= ' . $file);

Is there a better way to put the base_dir in?

You can get the root of the content folder like this:

<?php echo kirby()->urls()->content() ?>

But you might just as well use $page->files() and with a filter.