{"id":5181,"date":"2025-11-25T09:00:24","date_gmt":"2025-11-25T00:00:24","guid":{"rendered":"https:\/\/comcent.co.jp\/blog\/?p=5181"},"modified":"2025-11-04T00:55:48","modified_gmt":"2025-11-03T15:55:48","slug":"gemini%e3%82%92%e5%88%a9%e7%94%a8%e3%81%97%e3%81%9f%e7%94%bb%e5%83%8f%e3%81%b8%e3%81%aeiptc%e3%82%ad%e3%83%bc%e3%83%af%e3%83%bc%e3%83%89%ef%bc%88%e3%82%bf%e3%82%b0%ef%bc%89%e3%81%ae%e5%9f%8b%e3%82%81","status":"publish","type":"post","link":"https:\/\/comcent.co.jp\/blog\/archives\/5181\/","title":{"rendered":"Gemini\u3092\u5229\u7528\u3057\u305f\u753b\u50cf\u3078\u306eIPTC\u30ad\u30fc\u30ef\u30fc\u30c9\uff08\u30bf\u30b0\uff09\u306e\u57cb\u3081\u8fbc\u307f"},"content":{"rendered":"\n<p>JPEG\u753b\u50cf\u306a\u3069\u306b\u306f\u3001Exif\u60c5\u5831\u306bIPTC\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u57cb\u3081\u8fbc\u3080\u3053\u3068\u304c\u3067\u304d\u3001\u753b\u50cf\u7de8\u96c6\u30bd\u30d5\u30c8\u3084\u3001\u753b\u50cf\u30d3\u30e5\u30fc\u30ef\u30fc\u306a\u3069\u3067\u3001\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u5229\u7528\u3057\u305f\u691c\u7d22\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u5927\u91cf\u306b\u753b\u50cf\u304c\u3042\u308b\u5834\u5408\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u3060\u3051\u3067\u7279\u5b9a\u306e\u753b\u50cf\u3092\u63a2\u3059\u306e\u306f\u5927\u5909\u3067\u3059\u304c\u3001\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4ed8\u3051\u3066\u304a\u304f\u3053\u3068\u3067\u3001\u7279\u5b9a\u306e\u753b\u50cf\u3092\u7c21\u5358\u306b\u898b\u3064\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3057\u304b\u3057\u3001\u753b\u50cf\u7de8\u96c6\u30bd\u30d5\u30c8\u306a\u3069\u3067\u306f\u3001\u73fe\u6642\u70b9\u3067\u306f\u81ea\u52d5\u7684\u306b\u753b\u50cf\u306b\u5199\u3063\u3066\u3044\u308b\u3082\u306e\u3092\u8b58\u5225\u3057\u3066\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u57cb\u3081\u8fbc\u3080\u3001\u3068\u3044\u3046\u6a5f\u80fd\u306f\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u30af\u30e9\u30a6\u30c9\u306a\u3069\u3067\u306f\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u30b5\u30fc\u30d3\u30b9\u3082\u591a\u3044\u3067\u3059\u304c\u3001\u5927\u91cf\u306e\u753b\u50cf\u3068\u306a\u308b\u3068\u30af\u30e9\u30a6\u30c9\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u3001\u63a2\u3057\u3066\u5229\u7528\u3059\u308b\u3001\u3068\u3044\u3046\u306e\u306f\u30b1\u30fc\u30b9\u3068\u3057\u3066\u73fe\u5b9f\u7684\u3067\u306f\u7121\u3044\u30b1\u30fc\u30b9\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u3001\u753b\u50cf\u306b\u5199\u3063\u3066\u3044\u308b\u3082\u306e\u3092\u8b58\u5225\u3057\u3001IPTC\u30ad\u30fc\u30ef\u30fc\u30c9\u3068\u3057\u3066\u57cb\u3081\u8fbc\u3080\u3053\u3068\u304c\u3067\u304d\u308c\u3070\u3001\u5229\u4fbf\u6027\u304c\u9ad8\u307e\u308b\u3067\u3057\u3087\u3046\u3002\u30de\u30eb\u30c1\u30e2\u30fc\u30c0\u30eb\u5bfe\u5fdc\u306e\u751f\u6210AI\u3067\u3042\u308c\u3070\u3001\u753b\u50cf\u3092\u89e3\u6790\u3057\u3066\u3001\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u3001Gemini2.0\u3092\u5229\u7528\u3057\u3066\u3001\u753b\u50cf\u306b\u5bfe\u3057IPTC\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u57cb\u3081\u8fbc\u3080\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Gemini2.0\u3092\u5229\u7528\u3059\u308b\u7406\u7531<\/h3>\n\n\n\n<p>\u30de\u30eb\u30c1\u30e2\u30fc\u30c0\u30eb\u5bfe\u5fdc\u306e\u751f\u6210AI\u3067\u3042\u308c\u3070\u3001\u3069\u308c\u3067\u3082\u826f\u3044\u306e\u3067\u3001OpenAI\u306eAPI\u3092\u4f7f\u3063\u3066\u3082\u3001Cloude3\u306eAPI\u3092\u4f7f\u3063\u3066\u3082\u3082\u3061\u308d\u3093OK\u306a\u306e\u3067\u3059\u304c\u3001Gemini\u3067\u3042\u308c\u3070\u3001Google\u306b\u767b\u9332\u3059\u308b\u3053\u3068\u3067\u5236\u9650\u306f\u3042\u308a\u307e\u3059\u304c\u7121\u511f\u3067\u5229\u7528\u3067\u304d\u307e\u3059\u3002\u6642\u9593\u306f\u639b\u304b\u308a\u307e\u3059\u304c\u3001\u7121\u511f\u3067\u5229\u7528\u3067\u304d\u308b\u306e\u306f\u5927\u304d\u306a\u30e1\u30ea\u30c3\u30c8\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001Gemini\u306fGoogle\u304c\u958b\u767a\u3057\u3066\u3044\u308b\u305f\u3081\u3001Google\u306e\u753b\u50cf\u691c\u7d22\u30a8\u30f3\u30b8\u30f3\u3068\u9023\u643a\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u753b\u50cf\u306b\u5bfe\u3059\u308b\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u7cbe\u5ea6\u304c\u9ad8\u3044\u3068\u8003\u3048\u3089\u308c\u307e\u3059\uff08\u78ba\u8a3c\u306f\u3042\u308a\u307e\u305b\u3093\u304c\uff09\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">GeminiAPI\u3092\u7121\u511f\u3067\u5229\u7528\u3059\u308b<\/h3>\n\n\n\n<p><a href=\"https:\/\/aistudio.google.com\/\u3078\u30a2\u30af\u30bb\u30b9\u3057\u3001Google\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u30ed\u30b0\u30a4\u30f3\u3057\u307e\u3059\u3002\">https:\/\/aistudio.google.com\/<\/a>\u3078\u30a2\u30af\u30bb\u30b9\u3057\u3001Google\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u30ed\u30b0\u30a4\u30f3\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"660\" loading=\"lazy\" src=\"https:\/\/comcent.co.jp\/blog\/wp-content\/uploads\/2025\/04\/googleaistudio-1024x660.png\" alt=\"\" class=\"wp-image-5209\" srcset=\"https:\/\/comcent.co.jp\/blog\/wp-content\/uploads\/2025\/04\/googleaistudio-1024x660.png 1024w, https:\/\/comcent.co.jp\/blog\/wp-content\/uploads\/2025\/04\/googleaistudio-300x193.png 300w, https:\/\/comcent.co.jp\/blog\/wp-content\/uploads\/2025\/04\/googleaistudio-768x495.png 768w, https:\/\/comcent.co.jp\/blog\/wp-content\/uploads\/2025\/04\/googleaistudio-1536x990.png 1536w, https:\/\/comcent.co.jp\/blog\/wp-content\/uploads\/2025\/04\/googleaistudio-2048x1320.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u300c\u5229\u7528\u898f\u7d04\u30fb\u8ffd\u52a0\u5229\u7528\u898f\u7d04\u30fb\u30d7\u30e9\u30a4\u30d0\u30b7\u30fc\u30dd\u30ea\u30b7\u30fc\u300d\u3092\u78ba\u8a8d\u3057\u3001\u540c\u610f\u3057\u3066\u304b\u3089Get API Key\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3001\u300cAPI\u30ad\u30fc\u3092\u4f5c\u6210\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002API\u30ad\u30fc\u3092\u4f5c\u6210\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001API\u30ad\u30fc\u3092\u4f5c\u6210\u30e2\u30fc\u30c0\u30eb\u304c\u51fa\u3066\u304f\u308b\u306e\u3067\u3001\u300c\u65e2\u5b58\u306eGoogleCloud\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304b\u3089\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u9078\u629e\u3057\u307e\u3059\u300d\u304b\u3089\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u9078\u629e\u3057\u3001\u300c\u65e2\u5b58\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067API\u30ad\u30fc\u3092\u4f5c\u6210\u300d\u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>API\u30ad\u30fc\u304c\u767a\u884c\u3055\u308c\u308b\u306e\u3067\u3001\u30b3\u30d4\u30fc\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3066\u30b3\u30d4\u30fc\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>API\u30ad\u30fc\u3092\u767a\u884c\u3059\u308b\u3068\u3001API\u30ad\u30fc\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3001\u3068\u3044\u3046\u3068\u3053\u308d\u306b\u8868\u793a\u304c\u3055\u308c\u307e\u3059\u3002\u3053\u3053\u3067\u3001\u30d7\u30e9\u30f3\u304cFree\u3068\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304a\u304d\u307e\u3059\u3002\uff08\u3057\u3070\u3089\u304f\u6642\u9593\u304c\u639b\u304b\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\uff09<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">IPTC\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u57cb\u3081\u8fbc\u307f<\/h3>\n\n\n\n<p>IPTC\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u751f\u6210\u306fAPI\u3092\u901a\u3058\u305f\u751f\u6210AI\u3067\u884c\u306a\u3044\u307e\u3059\u304c\u3001\u753b\u50cf\u306e\u53d6\u5f97\u3001API\u3092\u901a\u3058\u3066\u753b\u50cf\u3092\u6e21\u3059\u3001\u7d50\u679c\u3092\u53d7\u3051\u53d6\u308b\u90e8\u5206\u306fPython\u3067\u30b3\u30fc\u30c9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u753b\u50cf\u306e\u53d6\u5f97\u306a\u3069\u306fPython\u306e\u6a19\u6e96\u7684\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u30fc\u3067\u53ef\u80fd\u3067\u3059\u304c\u3001IPTC\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u57cb\u3081\u8fbc\u307f\u3060\u3051\u306fPython\u306e\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u30fc\u3067\u306f\u3067\u304d\u306a\u3044\u305f\u3081\u3001exiftool\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>exiftool\u306f\u3001\u753b\u50cf\u306e\u30e1\u30bf\u30c7\u30fc\u30bf\u3092\u64cd\u4f5c\u3059\u308b\u305f\u3081\u306e\u30c4\u30fc\u30eb\u3067\u3001IPTC\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u57cb\u3081\u8fbc\u307f\u3082\u53ef\u80fd\u3067\u3059\u3002<a href=\"https:\/\/exiftool.org\/\">https:\/\/exiftool.org\/<\/a>\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u3002Windows\u7248\u3001mac\u7248\u304c\u3042\u308b\u306e\u3067\u3001\u74b0\u5883\u306b\u5408\u308f\u305b\u3066\u9078\u629e\u3057\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u304a\u304d\u307e\u3059\u3002Windows\u306e\u5834\u5408\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u3089\u3001\u89e3\u51cd\u3057\u3066\u3001exiftool(-k).exe\u3092exiftool.exe\u306b\u30ea\u30cd\u30fc\u30e0\u3057\u3066\u304a\u304d\u307e\u3059\u3002\u30d5\u30a9\u30eb\u30c0\u30fc\u3054\u3068\u9069\u5f53\u306a\u5834\u6240\u306b\u914d\u7f6e\u3057\u3001\u30d1\u30b9\u3092\u901a\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d1\u30b9\u3092\u901a\u3059\u65b9\u6cd5<\/h4>\n\n\n\n<p>\u4f8b\u3048\u3070\u3001exiftool\u30d5\u30a9\u30eb\u30c0\u30fc\u3092C:\u30c9\u30e9\u30a4\u30d6\u306e\u76f4\u4e0b\u306b\u914d\u7f6e\u3057\u305f\u5834\u5408\u3001\u300c\u8a2d\u5b9a\u300d\u2192\u300c\u30b7\u30b9\u30c6\u30e0\u300d\u2192\u300c\u30d0\u30fc\u30b8\u30e7\u30f3\u60c5\u5831\u300d\u2192\u300c\u30b7\u30b9\u30c6\u30e0\u306e\u8a73\u7d30\u8a2d\u5b9a\u300d\u2192\u300c\u8a73\u7d30\u8a2d\u5b9a\u300d\u30bf\u30d6\u2192\u300c\u74b0\u5883\u5909\u6570\u300d\u3092\u9078\u629e\u3057\u3001\u300c\u30b7\u30b9\u30c6\u30e0\u74b0\u5883\u5909\u6570\u300d\u306e\u300cPath\u300d\u3092\u9078\u629e\u3057\u3066\u3001\u300c\u7de8\u96c6\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002\u300c\u65b0\u898f\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001C:\\exiftool\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u3053\u308c\u3067\u3001exiftool.exe\u3092\u30b3\u30de\u30f3\u30c9\u540d\u3060\u3051\u3067\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Python\u30b3\u30fc\u30c9\u306e\u4f5c\u6210<\/h3>\n\n\n\n<p>Python\u3092\u5b9f\u884c\u3059\u308b\u306b\u306fPython\u672c\u4f53\u304c\u5fc5\u8981\u306a\u306e\u3067\u3001Python\u304c\u5165\u3063\u3066\u3044\u306a\u3044\u74b0\u5883\u3067\u3042\u308c\u3070\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>Python\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u3001<a href=\"https:\/\/www.python.org\/downloads\/\">https:\/\/www.python.org\/downloads\/<\/a>\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002Windows\u74b0\u5883\u3067\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6642\u306b\u300cAdd Python to PATH\u300d\u306b\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u3066\u304a\u304f\u3068\u3001\u30b3\u30de\u30f3\u30c9\u540d\u3060\u3051\u3067Python\u3092\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u306e\u3067\u3001\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u3066\u304a\u304d\u307e\u3059\uff08\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u30c1\u30a7\u30c3\u30af\u304c\u5165\u3063\u3066\u3044\u308b\u306f\u305a\u3067\u3059\u304c\u3001\u78ba\u8a8d\u3057\u3066\u304a\u304d\u307e\u3059\uff09\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u3044\u304f\u3064\u304b\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u30fc\u3092\u5229\u7528\u3059\u308b\u306e\u3067\u3001pip\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30bf\u30fc\u30df\u30ca\u30eb\u3092\u958b\u3044\u3066\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"pageCodeArea\"><pre><code>pip install google.generativeai Pillow<\/code><\/pre><\/div>\n\n\n\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5b8c\u4e86\u3057\u305f\u3089\u4ee5\u4e0b\u306ePython\u30b3\u30fc\u30c9\u3092\u8a18\u5165\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"pageCodeArea\"><pre><code>import google.generativeai as genai\nimport subprocess\nfrom PIL import Image\nimport os\nimport sys\nimport time\nimport configparser\n\n# Gemini API\u30ad\u30fc\u3092\u8a2d\u5b9a\ngenai.configure(api_key=\"\") # \u3053\u3053\u306b\u30b3\u30d4\u30fc\u3057\u305fAPI\u30ad\u30fc\u3092\u5165\u529b\n\n# Gemini\u30e2\u30c7\u30eb\u3092\u521d\u671f\u5316\nmodel = genai.GenerativeModel('gemini-2.0-flash') # \u5225\u30e2\u30c7\u30eb\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\n\ni = 0\nerror_count = 0\n\ndef analyze_image_and_embed_iptc_keywords(image_path,filename,folder_path,current_file_count):\n    try:\n        with Image.open(image_path) as img:\n            response = model.generate_content([\n                \"\u3053\u306e\u753b\u50cf\u306b\u5199\u3063\u3066\u3044\u308b\u3082\u306e\u3092\u4e00\u756a\u9069\u5207\u306a\u3082\u306e\u304b\u3089\u9806\u306b\u30ad\u30fc\u30ef\u30fc\u30c9\u3068\u3057\u3066\u62bd\u51fa\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30ad\u30fc\u30ef\u30fc\u30c9\u306f\u65e5\u672c\u8a9e\u3067\u8868\u8a18\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u307f\u3092\u62bd\u51fa\u3057\u3001\u4f59\u5206\u306a\u8a00\u8449\u3084\u30cf\u30a4\u30d5\u30f3\u3001\u30fb\u306a\u3069\u306e\u8a18\u53f7\u3001\u7b87\u6761\u66f8\u304d\u3084\u7b87\u6761\u66f8\u304d\u306e\u6570\u5b57\u306f\u4ed8\u3051\u8db3\u3055\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002\u3082\u3057\u753b\u50cf\u306e\u5199\u3063\u3066\u3044\u308b\u3082\u306e\u304c\u660e\u78ba\u3067\u306f\u7121\u3044\u5834\u5408\u306f\u3001\u753b\u50cf\u306e\u8272\u3068\u5370\u8c61\u3092\u30ad\u30fc\u30ef\u30fc\u30c9\u3068\u3057\u3066\u53d6\u308a\u4e0a\u3052\u3066\u304f\u3060\u3055\u3044\u3002\u305f\u3060\u3057\u3001\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u7dcf\u5408\u8a08\u306e\u6587\u5b57\u6570\u306f20\u6587\u5b57\u4ee5\u5185\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\",img\n            ])\n            keywords_str = response.text\n            keywords = keywords_str.split('\\n')\n            cleaned_keywords = [keyword.replace('* ', '').replace('- ','').replace('\u30fb ','').replace('\u30fb','').replace('\u3001 ',',').replace('\u3001',',').strip() for keyword in keywords if keyword.strip()]\n        keywords_csv = ','.join(cleaned_keywords)\n        print(f\"{keywords_csv}\")\n        subprocess.run([\n            'exiftool',\n            '-overwrite_original_in_place',\n            '-charset', 'iptc=utf8',\n            f'-IPTC:Keywords={keywords_csv}',\n            image_path\n        ], check=True)\n        print(f\"IPTC\u30ad\u30fc\u30ef\u30fc\u30c9\u304c {image_path} \u306b\u57cb\u3081\u8fbc\u307e\u308c\u307e\u3057\u305f\u3002\")\n        config = configparser.ConfigParser()\n        config['DEFAULT'] = {\n            'current_file': str(current_file_count),\n            'filename': filename,\n            'folder_path': folder_path\n        }\n        # \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u8fbc\u307f\n        with open('config.ini', 'w', encoding='utf-8') as configfile:\n            config.write(configfile)\n        return True\n    except subprocess.CalledProcessError as e:\n        print(f\"exiftool\u5b9f\u884c\u30a8\u30e9\u30fc: {e}\")\n        sys.exit(1)\n    except Exception as e:\n        error_message = str(e)\n        if \"429\" in error_message:\n            return False\n        else:\n            print(f\"\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f: {e}\")\n            sys.exit(1)\n\nfolder_path = r\"\"#\u8aad\u307f\u8fbc\u307f\u305f\u3044\u30d5\u30a9\u30eb\u30c0\u30fc\u30d1\u30b9\u3092\u6307\u5b9a\ntry:\n    config = configparser.ConfigParser()\n    config.read('config.ini', encoding='utf-8')\n    current_file_count = int(config['DEFAULT']['current_file'])\nexcept (FileNotFoundError, KeyError):\n    current_file_count = 0\n    \nfor filename in sorted(os.listdir(folder_path)):\n    if filename.lower().endswith((\".jpg\", \".jpeg\")):\n        if( i < current_file_count):\n            i += 1\n            continue\n        current_file_count += 1\n\ti += 1\n        image_path = os.path.join(folder_path, filename)\n        while True:\n            try:\n                if analyze_image_and_embed_iptc_keywords(image_path,filename,folder_path,current_file_count):\n                    error_count = 0\n                    break\n                else :\n                    error_count += 1\n                    if error_count >= 3:\n                        print(\"Gemini API\u306e\u30a8\u30e9\u30fc\u304c3\u56de\u7d9a\u3044\u305f\u305f\u3081\u3001\u51e6\u7406\u3092\u4e2d\u65ad\u3057\u307e\u3059\u3002\")\n                        sys.exit(1)\n                    print(\"Gemini API\u306e\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u305f\u3081\u30011\u5206\u5f85\u6a5f\u3057\u307e\u3059\u3002\")\n                    time.sleep(60)\n            except Exception as e:\n                print(\"Gemini API\u306e\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u305f\u3081\u30011\u5206\u5f85\u6a5f\u3057\u307e\u3059\u3002\")\n                time.sleep(60)\n<\/code><\/pre><\/div>\n\n\n\n<p>\u5f8c\u306f\u9069\u5f53\u306a\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u4fdd\u5b58\u3057\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u306a\u3069\u304b\u3089python \u4fdd\u5b58\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u540d.py\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u30b3\u30e1\u30f3\u30c8\u3067\u8a18\u5165\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u306b\u3001API\u30ad\u30fc\u3084\u8aad\u307f\u53d6\u308a\u305f\u3044\u30d5\u30a9\u30eb\u30c0\u30fc\u30d1\u30b9\u306a\u3069\u306f\u3001\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u5185\u306b\u9069\u5b9c\u8a18\u8ff0\u3092\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3001\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u30fc\u5185\u306eJPEG\u753b\u50cf\u306b\u5bfe\u3057\u3066\u3001IPTC\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u57cb\u3081\u8fbc\u307e\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>Gemini2.0\u306fAPI\u3067\u5229\u7528\u3057\u305f\u5834\u5408\u30011\u5206\u5f53\u305f\u308a\u306e\u5229\u7528\u4e0a\u9650\u5236\u9650\uff0815\u56de\u307e\u3067\uff09\u30681\u65e5\u5f53\u305f\u308a\u306e\u5229\u7528\u4e0a\u9650\u5236\u9650\uff081500\u56de\u307e\u3067\uff09\u53ca\u3073\u30b3\u30f3\u30c6\u30af\u30b9\u30c8\u9577\u5236\u9650\u304c\u3042\u308b\u305f\u3081\u5236\u9650\u306b\u62b5\u89e6\u3057\u305f\u3068\u304d\u306f\u30011\u5206\u9593\u5f85\u3064\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u305d\u308c\u304c3\u56de\u7d9a\u3044\u305f\u5834\u5408\u306f1\u65e5\u306e\u5229\u7528\u4e0a\u9650\u5236\u9650\u306b\u62b5\u89e6\u3057\u305f\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001\u51e6\u7406\u3092\u4e2d\u65ad\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u51e6\u7406\u304c\u5b8c\u4e86\u3057\u305f\u5834\u5408\u306f\u3001config.ini\u306b\u73fe\u5728\u306e\u51e6\u7406\u30d5\u30a1\u30a4\u30eb\u6570\u304c\u4fdd\u5b58\u3055\u308c\u308b\u306e\u3067\u3001\u6b21\u56de\u5b9f\u884c\u6642\u306fconfig.ini\u3092\u8aad\u307f\u8fbc\u307f\u3001\u524d\u56de\u306e\u7d9a\u304d\u304b\u3089\u51e6\u7406\u3092\u958b\u59cb\u3057\u307e\u3059\u3002\u305f\u3060\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u6570\u306b\u5909\u66f4\u304c\u3042\u3063\u305f\u308a\u3001\u51e6\u7406\u304c\u7d42\u308f\u3063\u305f\u3068\u3053\u308d\u306e\u524d\u306b\u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u304c\u8ffd\u52a0\u3055\u308c\u305f\u3068\u3057\u3066\u3082\u3001\u305d\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u5bfe\u8c61\u5916\u306b\u306a\u308b\u305f\u3081\u3001\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002\u6700\u521d\u304b\u3089\u5168\u3066\u3084\u308a\u76f4\u3059\u5834\u5408\u306f\u3001config.ini\u3092\u524a\u9664\u3057\u3066\u304b\u3089\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u57cb\u3081\u8fbc\u307f<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"555\" loading=\"lazy\" src=\"https:\/\/comcent.co.jp\/blog\/wp-content\/uploads\/2025\/04\/terminal-1024x555.png\" alt=\"\" class=\"wp-image-5208\" srcset=\"https:\/\/comcent.co.jp\/blog\/wp-content\/uploads\/2025\/04\/terminal-1024x555.png 1024w, https:\/\/comcent.co.jp\/blog\/wp-content\/uploads\/2025\/04\/terminal-300x162.png 300w, https:\/\/comcent.co.jp\/blog\/wp-content\/uploads\/2025\/04\/terminal-768x416.png 768w, https:\/\/comcent.co.jp\/blog\/wp-content\/uploads\/2025\/04\/terminal-1536x832.png 1536w, https:\/\/comcent.co.jp\/blog\/wp-content\/uploads\/2025\/04\/terminal-2048x1109.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Gemini2.0\u306f\u3042\u308b\u7a0b\u5ea6\u6b63\u3057\u304f\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u8fd4\u3057\u3066\u304d\u307e\u3059\u304c\u3001\u30d7\u30ed\u30f3\u30d7\u30c8\u3067\u6307\u5b9a\u3057\u3066\u3082\u8a18\u53f7\u6df7\u3058\u308a\u3060\u3063\u305f\u308a\u3059\u308b\u305f\u3081\u3001Python\u5074\u3067\u5165\u3063\u3066\u304f\u308b\u53ef\u80fd\u6027\u306e\u3042\u308b\u8a18\u53f7\u306a\u3069\u3092\u9664\u53bb\u3057\u3066\u3044\u307e\u3059\u3002IPTC\u30ad\u30fc\u30ef\u30fc\u30c9\u306f\u30ab\u30f3\u30de\u533a\u5207\u308a\u3067\u6307\u5b9a\u53ef\u80fd\u306a\u305f\u3081\u3001\u30ab\u30f3\u30de\u533a\u5207\u308a\u3067\u5165\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u9577\u3055\u306b\u5236\u9650\u304c\u3042\u308b\u305f\u3081\u300120\u6587\u5b57\u4ee5\u5185\u306b\u53ce\u3081\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30de\u30ec\u306bIPTC\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u57cb\u3081\u8fbc\u307f\u306b\u5931\u6557\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u306e\u5834\u5408\u306f\u3001\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3057\u3066\u3001\u51e6\u7406\u3092\u4e2d\u65ad\u3057\u307e\u3059\u3002\u753b\u50cf\u304c\u6b63\u3057\u3044JPEG\u753b\u50cf\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u753b\u50cf\u306e\u5165\u3063\u3066\u3044\u308b\u30d5\u30a9\u30eb\u30c0\u30fc\u3084\u30d5\u30a1\u30a4\u30eb\u540d\u306b\u65e5\u672c\u8a9e\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u3068\u30a8\u30e9\u30fc\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u304c\u3001\u7279\u306b\u51e6\u7406\u306b\u306f\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>\u753b\u50cf\u306e\u51e6\u7406\u306f1\u679a\u305a\u3064\u884c\u306a\u308f\u308c\u307e\u3059\u3002\u74b0\u5883\u306b\u3082\u3088\u308a\u307e\u3059\u304c\u3001Gemini2.0-Flash\u30671\u679a\u5f53\u305f\u308a3\uff5e4\u79d2\u7a0b\u5ea6\u639b\u304b\u308b\u306e\u3067\u3001\u51e6\u7406\u306f\u65e9\u304f\u3042\u308a\u307e\u305b\u3093\u3002\u4e2d\u65ad\u3082\u3067\u304d\u307e\u3059\u304c\u3001\u6c17\u9577\u306b\u5f85\u3064\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u4e2d\u65ad\u3057\u305f\u3044\u3068\u304d\u306f\u3001Ctrl+C\uff08Control+C\uff09\u3092\u62bc\u3059\u3068\u4e2d\u65ad\u3067\u304d\u307e\u3059\u3002\u3061\u306a\u307f\u306b\u3001Gemini2.0-Pro\u3082\u5229\u7528\u53ef\u80fd\u3067\u3059\u304c\u3001\u5236\u9650\u304c\u53b3\u3057\u3044\u305f\u3081\uff081\u5206\u5f53\u305f\u308a2\u56de\u307e\u3067\uff09\u76f8\u5f53\u306a\u7cbe\u5ea6\u304c\u6b32\u3057\u3044\u3068\u304d\u4ee5\u5916\u306f\u4f7f\u308f\u306a\u3044\u65b9\u304c\u826f\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<p>2025\u5e744\u67081\u65e5\u73fe\u5728\u3067\u306f\u3001\u4e0a\u8a18\u30b3\u30fc\u30c9\u3067\u52d5\u4f5c\u3057\u307e\u3059\u304c\u3001Gemini2.0\u306eAPI\u306f\u5909\u66f4\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001\u4eca\u5f8c\u52d5\u4f5c\u3057\u306a\u304f\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u306e\u5834\u5408\u306f\u3001Gemini2.0\u306eAPI\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u78ba\u8a8d\u3057\u3066\u3001\u9069\u5b9c\u4fee\u6b63\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h3>\n\n\n\n<p>\u9ad8\u901f\u306b\u52d5\u4f5c\u3059\u308b\u3053\u3068\u306f\u73fe\u72b6\u4e0d\u53ef\u80fd\u3067\u3059\u304c\u3001\u751f\u6210AI\u306eAPI\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u306b\u4fdd\u5b58\u3057\u3066\u3044\u308b\u753b\u50cf\u306b\u5bfe\u3057\u3066\u3001\u6bd4\u8f03\u7684\u5bb9\u6613\u306b\u6b63\u3057\u3044\u30bf\u30b0\u3092\u4ed8\u4e0e\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u30bf\u30b0\u4ed8\u3051\u3057\u305f\u753b\u50cf\u306f\u3001AdobeBridge\u3084Eagle\u306a\u3069\u306e\u753b\u50cf\u7ba1\u7406\u30bd\u30d5\u30c8\u3067\u691c\u7d22\u304c\u5bb9\u6613\u306b\u3067\u304d\u307e\u3059\u3002\u4e0a\u624b\u304f\u6d3b\u7528\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>JPEG\u753b\u50cf\u306a\u3069\u306b\u306f\u3001Exif\u60c5\u5831\u306bIPTC\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u57cb\u3081\u8fbc\u3080\u3053\u3068\u304c\u3067\u304d\u3001\u753b\u50cf\u7de8\u96c6\u30bd\u30d5\u30c8\u3084\u3001\u753b\u50cf\u30d3\u30e5\u30fc\u30ef\u30fc\u306a\u3069\u3067\u3001\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u5229\u7528\u3057\u305f\u691c\u7d22\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u5927\u91cf\u306b\u753b\u50cf\u304c\u3042\u308b\u5834\u5408\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u3060\u3051\u3067\u7279\u5b9a\u306e\u753b\u50cf\u3092\u63a2\u3059\u306e\u306f\u5927\u5909 [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":5207,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,14,13],"tags":[155,170,233,299,300,204,203],"coauthors":[52],"class_list":["post-5181","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","category-backend","category-frontend","tag-ai","tag-exif","tag-gemini","tag-image","tag-iptc","tag-llm","tag-python"],"author_meta":{"nickname":"sekiguchi","position":"CTO","icon_url":"https:\/\/comcent.co.jp\/blog\/images\/authorSk-150x150.png","author_url":"https:\/\/comcent.co.jp\/blog\/archives\/author\/sekiguchi\/"},"tag_names":["AI","EXIF","Gemini","Image","IPTC","LLM","Python"],"thumbnail_url":"https:\/\/comcent.co.jp\/blog\/wp-content\/uploads\/2025\/04\/title-300x200.png","_links":{"self":[{"href":"https:\/\/comcent.co.jp\/blog\/wp-json\/wp\/v2\/posts\/5181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/comcent.co.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/comcent.co.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/comcent.co.jp\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/comcent.co.jp\/blog\/wp-json\/wp\/v2\/comments?post=5181"}],"version-history":[{"count":6,"href":"https:\/\/comcent.co.jp\/blog\/wp-json\/wp\/v2\/posts\/5181\/revisions"}],"predecessor-version":[{"id":5328,"href":"https:\/\/comcent.co.jp\/blog\/wp-json\/wp\/v2\/posts\/5181\/revisions\/5328"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/comcent.co.jp\/blog\/wp-json\/wp\/v2\/media\/5207"}],"wp:attachment":[{"href":"https:\/\/comcent.co.jp\/blog\/wp-json\/wp\/v2\/media?parent=5181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/comcent.co.jp\/blog\/wp-json\/wp\/v2\/categories?post=5181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/comcent.co.jp\/blog\/wp-json\/wp\/v2\/tags?post=5181"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/comcent.co.jp\/blog\/wp-json\/wp\/v2\/coauthors?post=5181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}