カスタムモジュールでのExif除去

Events happening in the community are now at Drupal community events on www.drupal.org.
birdaqua's picture

画像をアップロード時に,Exifデータを消去しようと思い,phpのimagick拡張モジュールとhook_file_presaveを用いて,下記のカスタムモジュールを作成しました。

function modulename_file_presave(Drupal\file\FileInterface $file) {
if ($file->getMimeType() == 'image/jpeg') {
$path = $file->getFileUri();
$img = new Imagick($path);
$img->stripImage();
$img->writeImage($path);
$img->clear;
}

}

  $img->writeImage($path);

の部分がよくないようで,実行すると,下記のエラーメッセージが表示されます。

Drupal\Core\Entity\EntityStorageException: unable to open image `public://filefield_paths/ファイル名.jpg': No such file or directory @ error/blob.c/OpenBlob/2643 in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 777 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

filefield_pathのモジュールを有効にしておりますが,使用しない設定にしても同様のエラーメッセージが表示されました。
また,ファイルのアップロード後に「public://filefield_paths/ファイル名.jpg」は存在しております。

何が問題で,どのようにすればExifなしの画像ファイルに置き換えられますでしょうか。
おわかりの方,ご教示いただけますと幸いです。よろしくお願いいたします。

日本 コミュニティ: Drupal Japan User Group

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: