-1
私のシステムでは、次の形式の画像ファイルを使用できます:png、jpg、gif。異なるメタデータセットを使用して同じファイルがシステムに届く可能性があり、そのメタデータに関係なくメタデータを一意に識別する必要があります。メタデータに関係なく画像をハッシュする
私は、PHPモジュールImagickを使って画像を読んで、メタデータを取り除いてハッシュしてみました。
// example_image: https://ibb.co/bVkanv
$original_image = ‘Example.jpg’;
$image1_path = ‘example1.jpg’;
$image2_path = ‘example2.jpg’;
$stripped_image1_path = ‘stripped_example1.jpg’;
$stripped_image2_path = ‘stripped_example2.jpg’;
$imagick_1 = new Imagick($original_image);
$imagick_1->setImageProperty('Exif:Make', 'Imagick_1');
$imagick_1->writeImage($image1_path);
$imagick_2 = new Imagick($original_image);
$imagick_2->setImageProperty('Exif:Make', 'Imagick_2');
$imagick_2->writeImage($image2_path);
// Now example1.jpg and example2.jpg SHOULD be the same image with different metadata
$imagick_1 = new Imagick($image1_path);
$imagick_1->stripImage();
$imagick_1->writeImage($stripped_image1_path);
$imagick_2 = new Imagick($image2_path);
$imagick_2->stripImage();
$imagick_2->writeImage($stripped_image2_path);
$hash = sha1_file($image_path);
$stripped_hash1 = sha1_file($stripped_image1_path);
$stripped_hash2 = sha1_file($stripped_image2_path);
$hash
88f454a5f768d633f9d5b8fbba73cdc9dfa46f59
$stripped_hash1
fd385aa6ebcf8018a725598df945f925d8e05d58
$stripped_hash2
d9c9bca4f4433556d5c4c0d62ce06de06920e69b
どのように私は私の目標を達成することができます:ハッシュが異なるため
// example_image: https://ibb.co/bVkanv
$image_path = ‘example.jpg’;
$stripped_image_path = ‘stripped_example.jpg’;
$img = new Imagick($image_path);
$img->stripImage();
$img->writeImage($stripped_image_path);
$image_hash = sha1_file($stripped_image_path);
それにもかかわらず、このアプローチは適切に動作していませんか?
あなたは自分でコードを書き込もうとします**。あなたが問題を抱えている場合は** [もっと研究している**](https://meta.stackoverflow.com/q/261592/1011527)の後**あなたが試したものを投稿してください** **動作しておらず、[最小、完全、および検証可能な例](http://stackoverflow.com/help/mcve)を提供しています。 [質問する](http://stackoverflow.com/help/how-to-ask)の良い質問をお読みください。 [ツアーに参加する](http://stackoverflow.com/tour)と[this](https://meta.stackoverflow.com/q/347937/1011527)を必ず読んでください。 –
@JayBlanchard完了! –