ãã®ããã5æã®äŒæ¥ã®çŽåã«ããã¹ãã¿ã¹ã¯ã§çããè¿ã£ãŠããŸããã ä»äºã¯ç°¡åã«æããŸãããã2é±éåŸã«äœããã®çç±ã§æ°ããä»äºãèŠã€ããã©ãã·ã¥ãçµãããäŒæ¥ãæ¥ãã®ã§ãäžè¬çãªã³ãã¥ãã±ãŒã·ã§ã³ãæ念ããããšã«ããŸããã ããããåãæ¥ã«ç æ°ã«ãªããŸããã ããã¯ãã¹ãŠã®çµæã䌎ãéåžžã«æ·±å»ãªéŒ»æ°Žã§ãã ãããŠç¿æ¥ãç§ã¯ãã®ãã¹ãã¿ã¹ã¯ãåãäžããŠããã®çµæã確èªããããšã«ããŸããã ãããç§ã®è©±ã§ãã
ãã®å²ãåœãŠã®ããã¹ãã¯æ¬¡ã®ãšããã§ãã
ä»»æã®Webãã¬ãŒã ã¯ãŒã¯ïŒã§ããã°æãããç¥ã£ãŠãããã®ïŒã䜿çšããŠå°ããªWebã¢ããªã±ãŒã·ã§ã³ãäœæããå¿ èŠããããŸãã ã¬ã€ã¢ãŠãã¯éèŠã§ã¯ãããŸãããããã¯ãšã³ããã³ãŒãã®èšèšãããããªããšã«éäžããŠãã ããã
å®éãã¢ããªã±ãŒã·ã§ã³ã¯1ããŒãžã§æ§æããå¿ èŠããããŸãããå¿ èŠã«å¿ããŠè€æ°ã®ããŒãžã«åå²ããããšãã§ããŸãïŒåå¥ã®ããŠã³ããŒããã©ãŒã ïŒã
å¿ èŠãªèŠçŽ -åçã¢ããããŒããã©ãŒã ãšãã¢ããããŒããããåçã®ãªã¹ããå«ãããŒãã«ã æ¿èªã¯ãªãã·ã§ã³ã§ãã
ããŠã³ããŒããã©ãŒã ïŒ
åçåãå ¥åããããã®ããã¹ãããã¯ã¹
ãã¡ã€ã«éžæ
è¡šïŒ
åçã®ãã¬ãã¥ãŒïŒåçïŒãµã ãã€ã«ïŒã®å°ããªã³ããŒãäœæããå¿ èŠããããŸãããŸãããã®ãã¬ãã¥ãŒã¯ããã¬ãã¥ãŒãã¯ãªãã¯ãããšéãå ã®/ãã«ã€ã¡ãŒãžãžã®ãªã³ã¯ã§ããå¿ èŠããããŸãïŒ
åçã®ååïŒãŠãŒã¶ãŒãã¢ããããŒãæã«æå®ããïŒ
ã«ã¡ã©ã®ã¡ãŒã«ãŒãšã¢ãã«ïŒEXIFãããå ŽåïŒ
ãã¡ã€ã«ãµã€ãº
åçäœææ¥ïŒEXIFããïŒ
åçã®ã¢ããããŒãæ¥
åé€ãã¿ã³
èŠä»¶ïŒ
æ¢åã®åçãä¿åããªãã§ãã ããã éè€ãã¡ã€ã«ã確èªããæ€åºãããå Žåã¯ãšã©ãŒãè¿ããŸãã
ããŠã³ããŒããããã¡ã€ã«ãã€ã¡ãŒãžãã©ããã確èªããã€ã¡ãŒãžã§ãªãå Žåã¯ãšã©ãŒãåºããŸãã ïŒEXIFããŒã¿æ€èšŒãæ€èšŒãšããŠäœ¿çšããªãã§ãã ããïŒ
1幎以äžåã«äœæãããåçã®ä¿åãèš±å¯ããªãã§ãã ããïŒåçãEXIFããäœæãããæ¥ä»ã確èªããŠãã ããïŒã
EXIFã§åçãäœæããæ¥ä»ããªãå Žåã¯ããšã©ãŒãäžããŠãã¡ã€ã«ãè¿œå ããªãã§ãã ããã
ãã®ãããTornadoã¯Pythonã®Webãã¬ãŒã ã¯ãŒã¯ãšããŠéžæãããŸãããç§ã¯é·ãéãããã«ç²ŸéããŠããŸããã è€æ°ã®ããã¯ãšã³ããµãŒããŒãäžããããããã©ã³ãµãŒãšã¹ãŒããŒãã€ã¶ãŒãå¿ èŠã§ãã åœåãç§ã¯HAProxyããã©ã³ãµãŒãšèããŠããŸããããNGINXãåçãããŸãé ä¿¡ã§ããããšãæãã€ããŸããã ãã®çµæãåœåãã¢ãŒããã¯ãã£ã¯æ¬¡ã®ããã«æããŸãããNGINXã¯æ¥ç¶ã®ãã©ã³ã¹ãåãããã£ã¹ã¯ããéçã«åæ£ããŸãã4å°ã®TornadoãµãŒããŒããªã¯ãšã¹ããåŠçããRedisãããã¯ãšã³ããåæããŸãã
å ¥ã£ãŠããç»åãåæãããµã ãã€ã«ãäœæããè² æ ã¯ãã«ããŒãã«ããã£ãã å²ãåœãŠã§ã¯ãã©ã®åœ¢åŒããµããŒãããå¿ èŠããããã瀺ãããŠããªããããTIFFããã³JPEG圢åŒã«èšåããŠããWikipediaã§EXIFã®èª¬æãæ¢ããŸããã ããã ãã§ããã°ãäºæ ã¯ããã»ã©æªããããŸãããPythonçšPillowã©ã€ãã©ãªã¯ããã©ãŒããããšEXIFã¡ã¿ããŒã¿ã®äž¡æ¹ããµããŒãããŠããŸãã ãã ãã埮åŠãªéãããããŸããTIFFç»åã¯ãã©ãŠã¶ã§éãããŸããã ããã«ããããã©ãŠã¶ãŒã§å ã®ãã¡ã€ã«ãéãããšãã§ããªããªãããããããã®ç»åãJPEGã«ãã©ã³ã¹ã³ãŒãããåä¿¡ããEXIFãã¡ã€ã«ãšãšãã«ããŒã¿ãè¿œå ä¿åããŠãããŒãã«ã«è¡šç€ºããããã«å¿ èŠãªãã¹ãŠã®æ å ±ã埩å ããããšã«ããŸããã
ããŒãã«èªäœãRedisã«ä¿åããŸãã ãŸããRedisã¯ã¡ã¢ãªã«å®å šã«ããŒããããŠãããç·æ¥åæ¢ãçºçããå Žåãææ°ã®ããŒã¿ããŒã¹ã®å€æŽã埩å ããå¯èœæ§ã¯é«ããããŸããããéåžžã«å€ãã®ã€ã¡ãŒãžã®èª¬æã«å¯Ÿå¿ã§ããé·æéç¶ããšæããŸãã ãŸããç·æ¥ã®å ŽåãJPEGãã¡ã€ã«ã®ã¡ã¿ããŒã¿ããæ¬ èœããŠããæ å ±ã埩å ã§ããŸãã
JPEGã¡ã¿ããŒã¿ãœãªã¥ãŒã·ã§ã³ã¯çŸããèŠããŸãããPillowã¯EXIFãJPEGã«ä¿åã§ããŸãããã¡ã¿ããŒã¿èªäœã¯æ¢ã«ãã€ããªåœ¢åŒã«ãªã£ãŠããã¯ãã§ãã ã€ãŸããPillowã¯èŸæžã®åœ¢ã§ã¡ã¿ããŒã¿ãçæããŸãããèŸæžããã¡ã¿ããŒã¿ãŸã§äœãã§ããŸããã Gexiv2ã©ã€ãã©ãªãèŠã€ãããŸãããããã¯ã¡ã¿ããŒã¿ã§ãæ©èœããŸããããã®ã€ã³ã¹ããŒã«ã«ã¯ã¹ãã«ãå¿ èŠã§ããã
ãœãŒã¹ããGexiv2ãäœåºŠããã«ãããããšãããšãã©ã€ãã©ãªãèŠã€ãããªããšãããšã©ãŒãçºçããŸããã ãã®ãããªã©ã€ãã©ãªãæ¢ããŠãUbuntuçšã®ãã®ã©ã€ãã©ãªã®ã€ã³ã¹ããŒã«ããã±ãŒãžã«åºäŒããŸããã ããããããã§åé¡ãçºçããŸããã pyenvãä»ããŠã·ã¹ãã ã«Pythonãã€ã³ã¹ããŒã«ããvirtualenvããã¹ã¯ãªãããå®è¡ããããšããŸãããããã®å Žåãã€ã³ã¹ããŒã«ãããGexiv2ã·ã¹ãã ã¯å©çšã§ããŸããã ãã®ãããã¯ã§ã¯ã¿ã³ããªã³ãšã®ç¹å®ã®ãã³ã¹ããããŸãããGexiv2ã§1æééãããåŸãvirtualenvãæŸæ£ããŠã·ã¹ãã Python 2.7.6ã䜿çšããããšã«ããŸããã
Gexiv2ã¯ãã¡ã€ã«å ã®EXIFãæ£åžžã«ç·šéããŸãããã¡ã¢ãªå ã®ããŒã¿ã䜿çšãããšã¿ã€ãã«ãªããŸãã ãŸããåºæ¬çã«ãã¡ã€ã«ã«2åã¢ã¯ã»ã¹ããããããŸããã§ããã1åç®ã¯JPEGã®èšé²çšã2åç®ã¯åãã¡ã¿ããŒã¿ãã¡ã€ã«ãžã®æžã蟌ã¿çšã§ãã äœãç§ãåŸ ã£ãŠããã®ãåãããŸããã§ããã ãããŠã次ã®ããšãåŸ ã£ãŠããŸãã-Gexiv2ã®ããã¥ã¡ã³ãã«ã¯ãEXVãCR2ãCRWãªã©ã®ãµããŒããããŠãã圢åŒããªã¹ããããŠããŸããã ãã®ãããPillowã¯ããŠã³ããŒãå¯èœãªç»åãèªã¿åãã¿ã¹ã¯ã«å¯ŸåŠã§ããªããªããŸããã ããã§ImageMagickãèŠã€ããŸãããPythonã«å¯Ÿå¿ããã¢ããã¿ãŒã¯Wandã§ãã
ã¯ã³ãã¯ææã«èŠããŸãã-å€ãã®ãã©ãŒãããã®ãµããŒããEXIFã®èªã¿åããæ¯èŒçç°¡åãªã€ã³ã¹ããŒã«ã ããããJPEGãã¡ã¿ããŒã¿ãšãšãã«ä¿åããã«ã¯ãPillowãå¿ èŠã§ãã ãã°ããéãããåŸãPillowã§ã¡ã¿ããŒã¿ãç·šéããã®ã«åœ¹ç«ã€piexifã©ã€ãã©ãªãèŠã€ããããšãã§ããã®ã¯å¹žéã§ãããã1ã€ã®åé¡ãå°ãªããªããŸããã æ°æééãããåŸã座ã£ãŠããã°ã©ã ã§ããŸãã
ã¢ã«ãŽãªãºã ã¯åçŽã§ãã¯ã³ãã¯ã¡ã¢ãªããç»åãããŒãããEXIFããŒã¿ãæäŸããã¯ã³ãã¯RGBãããã¡ãŒãæäŸãããã®md5ããã·ã¥ãèæ ®ããŠéè€ããã§ãã¯ãããããã¡ãŒãJPEGã«å€æããŠã¡ã¿ããŒã¿ãšãšãã«ä¿åãããµã ãã€ã«ãä¿åããŸãã ãã¡ãããããã«å¿ããŠRedisã®ããŒã¿ãæŽæ°ããŸãã 確èªããå¿ èŠããããŸãã ãã ããã¡ã¿ããŒã¿ã䜿çšããŠã€ã³ã¿ãŒãããäžã§ç»åãæ€çŽ¢ããããšããæ°ãããã®ã§ãã£ãŠãåé¡ã§ãã ãããŠãEXIFããŒã¿ãé©åã«ç·šéããããã°ã©ã ãæ¢ãã®ã«å€ãã®æéãè²»ãããŸããã
ããã§ãæåã®JPEGãµã³ãã«ã®æºåãã§ããŸãããããŠã³ããŒãããŠãã ããã 次ã«ã2çªç®ã®ãµã³ãã«ããµã€ãºã7MBã®CR2ãã¡ã€ã«ã瀺ããŸãããããã€ãã®é©ãããããŸããã æåã®-ã¯ã³ãã¯ãããã¡ãããããèªã¿åãããšãã§ããŸããã§ããããœãŒã¹ãã¡ã€ã«ã®æ¡åŒµåã®åœ¢åŒã®ãã©ãŒããããã³ããå¿ èŠã§ããã ããããããã«åé¡ããããŸããã©ã€ãã©ãªã¯äžæãã¡ã€ã«ãèŠã€ããããªããšæžããŠããŸãã å床æ€çŽ¢ãããšãufrawãŠãŒãã£ãªãã£ãã€ã³ã¹ããŒã«ããå¿ èŠãããããã¡ã€ã«ãèªã¿åãããŸããã 11ç§ã§ã ãããŠãå ã®ç»åããããã€ãºã®ãããªãã®ãJPEGã§èœã¡ãŸããã
æåã¯ãWandã«çœªãç¯ããŸãããç»åãRGBãããã¡ãŒã«äžæ£ã«å€æããŠããããã«èŠããŸããããé»åãå®è¡ãããšããããã¡ãŒãå¿ èŠãªãµã€ãºã®ã¡ããã©2åã§ããããšãããããŸãããã€ãŸãããã£ãã«ã¯8ãããã§ã¯ãªã16ããããå ããŠããŸãã ããããã1è¡ã§ãã¹ãŠãæ©èœããŸãã ããããé·ããã¡ã€ã«ã®ããŠã³ããŒããã©ããããïŒ 4ã€ã®ãµãŒããŒãååšããå Žåã§ããåãæ°ã®å€§ããªCR2ãã¡ã€ã«ã«ããããµãŒãã¹ãå©çšã§ããªããªããŸãã
æåã®æ¥ã¯ãã·ã¹ãã ã®ã€ã³ã¹ããŒã«ãããŸããŸãªã©ã€ãã©ãªã®æ€çŽ¢ãšã€ã³ã¹ããŒã«ãäž»é¡åéã®èª¿æ»ã«ããªãã®æéãè²»ãããŸããããæçµçã«ã¯150è¡ã®ã³ãŒãããæžããŸããã§ããã ãããŠæçµçã«ããã¹ãã¿ã¹ã¯ã¯å€±æããŸãã-ã¢ããªã±ãŒã·ã§ã³ã®çµæã¯åãå ¥ããããŸããã§ããã ç æ°ã®äœãäŒæ¯ãæ±ããã
2æ¥ç®ã«ããªã¯ãšã¹ãäžã«ç»åã®åŠçãæåŠããNGINXã«ç»åãå²ãåœãŠãããã¯ãšã³ãã«ãµãŒããŒã1ã€ã ãæ®ããç»åãåŠçãã3ã€ã®ã¹ã¯ãªãããå®è¡ããããšã«ããŸããã
NGINXã¢ãžã¥ãŒã«ã®Uploadã¢ãžã¥ãŒã«ãæ§ç¯ããããšããå§ããŸãããããã¡ãã圹ã«ç«ã¡ãŸããã ãã°ããææ¢ãããŠãäœè ããããæŸæ£ããããšã«æ°ä»ããŸããããã®ã¢ãžã¥ãŒã«ã¯ææ°ããŒãžã§ã³ã§ã¯åäœããŸããã ããŠã倧äžå€«-TornadoãµãŒããŒã«çä¿¡ãã¡ã€ã«ããã£ã¹ã¯ã«ä¿åãããŠãã ããã ããã«ãå®éã«æ°ããç»ååŠçã¹ã¯ãªããã«ã³ããŒã¢ã³ãããŒã¹ãããŸãã ã¹ãŒããŒãã€ã¶ãŒãšNGINXãæ§æããã€ã³ã¹ããŒã«ã¹ã¯ãªãããå®äºããŸãã ãããŠããã¯åäœããŸãã
ãã€ãã¹ã®ç¹ïŒç»åãããŠã³ããŒãããåŸããŠãŒã¶ãŒã¯ããŠã³ããŒãã¹ããŒã¿ã¹ã®ããŒãžãéããŸããç»åãè¡šã«è¡šç€ºããããŸã§ã«æéãããããŸããçŽç²ãªRGBããŒã¿ã®ããã·ã¥ãäžæ¢ããå¿ èŠãããããã¡ã€ã«å šäœãããã·ã¥ãããŠéè€ããã§ãã¯ããŸãã ãšã©ãŒãçºçããå ŽåãããŠã³ããŒãçµæã¯1æ¥éä¿åãããŸãã
æçµçã«ãæ¯èŒçäœãè² è·ã§ããã®ã¢ããªã±ãŒã·ã§ã³ã¯å®å®ããŠåäœããå€ãã®ã³ã¢ãåãã匷åãªãµãŒããŒã§ãè¯ãããã©ãŒãã³ã¹ã«ã€ããŠè©±ãããšãã§ãããšä¿¡ããŠããŸãã æ®å¿µãªããããã®ãã¹ãã¿ã¹ã¯ã®ã»ãšãã©ã¯ã©ã€ãã©ãªã®æ€çŽ¢ãšç®¡çã§æºããããããã°ã©ãã³ã°ã¯ã»ãšãã©è¡ãããŠããŸããã éçšäž»ããã®ä»äºã§ç¥ãããã£ãããšã¯ãç§ã«ã¯ããŸãæ確ã§ã¯ãããŸããã EXIFããŒã¿ãååŸããããã«ç¬èªã®ã©ã€ãã©ãªãäœæããå¿ èŠããããããããŸãããïŒ ãããŠããã®ãããªãã¹ãã¿ã¹ã¯ãå°ããåŒã³åºãããšã¯ã§ããŸããã8æé以äžãçµéããŸããã ãµããŒããããŠããç»å圢åŒã®è©³çŽ°ãå°å ¥ããã¿ã¹ã¯ãå€§å¹ ã«ç°¡çŽ åããã¢ããªã±ãŒã·ã§ã³ã®äœ¿çšç®çã®è©³çŽ°ã説æããŸãã
ãœãŒã¹ã¯githubã§è¡šç€ºã§ããŸãã ãããŠãç§ã¯ç æ°ã«ãªãç¶ããŸãã