Files
fewo-stommer/app/Console/Commands/StripPhotoMetadata.php

30 lines
973 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Console\Commands;
use App\Models\Photo;
use App\Support\StripImageMetadata;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
#[Signature('photos:strip-metadata {--force : Auch bereits bereinigte Fotos erneut bearbeiten}')]
#[Description('Remove metadata (GPS position, camera data) from all stored original photos – new uploads are cleaned automatically')]
class StripPhotoMetadata extends Command
{
/**
* Execute the console command.
*/
public function handle(): int
{
$cleaned = Media::query()->where('collection_name', Photo::COLLECTION)->get()
->filter(fn (Media $media): bool => StripImageMetadata::strip($media, (bool) $this->option('force')))
->count();
$this->info("{$cleaned} Original-Foto(s) bereinigt.");
return self::SUCCESS;
}
}