ãœãŒã¹ããŒã¿
Yelpã¯12幎éã«ã¹ã¿ã åçãä¿åããŠããŸãã ãã¹ã¬ã¹åœ¢åŒïŒPNGãGIFïŒãPNGãšããŠä¿åããä»ã®ãã¹ãŠã®åœ¢åŒãJPEGã§ä¿åããŸãã PythonãšPillowã¯ãã¡ã€ã«ã®ä¿åã«äœ¿çšãããåçã®ã¢ããããŒãã¯æ¬¡ã®ã¹ããããã®ãããªãã®ããå§ãŸããŸãã
# do a typical thumbnail, preserving aspect ratio new_photo = photo.copy() new_photo.thumbnail( (width, height), resample=PIL.Image.ANTIALIAS, ) thumbfile = cStringIO.StringIO() save_args = {'format': format} if format == 'JPEG': save_args['quality'] = 85 new_photo.save(thumbfile, **save_args)
ãã®åŸãå質ãæãªãããšãªããã¡ã€ã«ãµã€ãºãæé©åãããªãã·ã§ã³ãæ¢ãå§ããŸãã
æé©å
ãŸãããã¡ã€ã«ãèªåã§åŠçããããCDNãããã€ããŒã«éæ³ã®ããã«åçãå€æŽããããã決å®ããå¿ èŠããããŸãã é«å質ã®ã³ã³ãã³ããåªå ããããããµã€ãºãšå質ã®éžæè¢ãšæœåšçãªãã¬ãŒããªããè©äŸ¡ããããšã¯çã«ããªã£ãŠããŸãã ãã¡ã€ã«ãµã€ãºãæé©åããããšã§ãçŸç¶ã調æ»ãå§ããŸãããã©ã®ãããªå€æŽãå ããããšãã§ããããããã®ãµã€ãº/å質ãã©ã®ããã«å€åãããã§ãã 調æ»ã®æåŸã«ã3ã€ã®äž»èŠãªåéã§äœæ¥ããããšã«ããŸããã èšäºã®æ®ãã®éšåã§ã¯ãç§ãã¡ãè¡ã£ãããšãšãåæé©åããåŸãããã¡ãªããã«ã€ããŠèª¬æããŸãã
- æã®å€æŽ
- ãã©ã°ãæé©åãã
- ããã°ã¬ãã·ãJPEG
- åçã¢ããªã±ãŒã·ã§ã³ã®ããžãã¯ã®å€æŽ
- 倧èŠæš¡ãªPNGèªè
- ãã€ãããã¯JPEGå質
- JPEGãšã³ã³ãŒããŒã®å€æŽ
- MozjpegïŒãã¬ãªã¹éååãã«ã¹ã¿ã éååãããªãã¯ã¹ïŒ
æã®å€æŽ
ãã©ã°ãæé©åãã
ããã¯ãç§ãã¡ãè¡ã£ãæãåçŽãªå€æŽã®1ã€ã§ããCPUæéã«ããè¿œå ã®ãã¡ã€ã«ãµã€ãºç¯çŽã®è²¬ä»»ãPillowã«ç§»ãããšã§ãïŒ
optimize=True
ïŒã å®çŸ©ã«ãããããã¯åçã®å質ã«åœ±é¿ããŸããã
JPEGã®å Žåããã®ãã©ã°ã¯ãåç»åãã¹ãã£ã³ãããšãã«äœåãªãã¹ãäœæããŠãæé©ãªãããã³ã³ãŒããèŠã€ãããããšã³ã³ãŒããŒã«æ瀺ããããšãæå³ããŸãã ãã¡ã€ã«ãžã®æžã蟌ã¿ã®ä»£ããã«ãåæåã®ãã¹ã¯åå€ã®çºçã®çµ±èšãèšç®ããŸãããã®æ å ±ã¯å®å šãªãšã³ã³ãŒãã«å¿ èŠã§ãã PNGæšæºã¯zlibã䜿çšããããããã®å Žåã®æé©åãã©ã°ã¯ãšã³ã³ãŒããŒã«
gzip -6
代ããã«
gzip -6
gzip -9
ã䜿çšããããã«æ瀺ããŸãã
ãã®ãããªå€æŽã¯ç°¡åã«è¡ãããšãã§ããŸãããããã¡ã€ã«ãµã€ãºãæ°ããŒã»ã³ãããåæžã§ããªãçæ³çãªãœãªã¥ãŒã·ã§ã³ã§ã¯ãªãããšãããããŸããã
ããã°ã¬ãã·ãJPEG
JPEGãä¿åãããšããããã€ãã®ç°ãªãã¿ã€ããéžæã§ããŸãã
- äžããäžã«ããŒãããããŒã¹ã©ã€ã³JPEG
- ãŒããããã®ããé®®æãªãã®ãŸã§ããŒãããããã°ã¬ãã·ãJPEGã ããã°ã¬ãã·ãç»åãªãã·ã§ã³ã¯ãPillowã§ç°¡åã«æå¹ã«ã§ããŸãïŒ
progressive=True
ïŒã ãã®çµæãå質ã䞻芳çã«åäžããŸãïŒã€ãŸããäžå®å šãªã·ã£ãŒããã¹ããããç»åã®éšåçãªæ¬ èœã«æ°ä»ãããããªããŸãïŒ
ããã«ãããã°ã¬ãã·ãç»åãããã¯ããæ¹æ³ã§ã¯ãéåžžããã¡ã€ã«ãµã€ãºãå°ãããªããŸãã Wikipediaã®èšäºã§è©³ãã説æãããŠããããã«ã8Ã8ãã¯ã»ã«ãããã¯ã®ãžã°ã¶ã°æµžéããšã³ããããŒãšã³ã³ãŒãã£ã³ã°çšã®JPEG圢åŒã§äœ¿çšãããŸãã ãããã®ãã¯ã»ã«ãããã¯ã®å€ãããã¯ããããé çªã«äžŠã¹ãããŠããªãå Žåãéåžžã¯ãŒã以å€ã®å€ãããããã®åŸãŒãã®ã·ãŒã±ã³ã¹ãããããã®ãã¿ãŒã³ã¯ç»åå ã®8Ã8ãããã¯ããšã«ç¹°ãè¿ããã亀äºã«äžŠã¹ãããŸãã ããã°ã¬ãã·ãã³ãŒãã£ã³ã°ã§ã¯ããã¯ã»ã«ãããã¯ã®åŠçé åºãå€æŽãããŸãã ãã¡ã€ã«ã®æåã¯åãããã¯ã®å€§ããªå€ã§ããïŒããã°ã¬ãã·ãç»åã®æåã®ã¹ãã£ã³ã«ç¹åŸŽçãªãããã¯ãã€ãºãäžããŸãïŒãçµããè¿ãã«ã¯ããŒããå«ãå°ããªå€ã®é·ãç¯å²ãä¿åããããããã®ç¯å²ã¯è©³çŽ°ãæäŸããŸãã ãã®ãããªãã¡ã€ã«å ã®ããŒã¿ã®åé åžã¯ãã€ã¡ãŒãžèªäœãå€æŽããŸããããé£ç¶ããŠãŒãã®æ°ãå¢ãããŸãïŒå§çž®ã容æã§ãïŒã
ããŒã¹ã©ã€ã³JPEGãšããã°ã¬ãã·ãJPEGã®æ¯èŒ
ããŒã¹ã©ã€ã³JPEGã¬ã³ããªã³ã°ã®ä»çµã¿ã®äŸ
ããã°ã¬ãã·ãJPEGã¬ã³ããªã³ã°ã®ä»çµã¿ã®äŸ
ããŒã¹ã©ã€ã³JPEGã¬ã³ããªã³ã°ã®ä»çµã¿ã®äŸ
ããã°ã¬ãã·ãJPEGã¬ã³ããªã³ã°ã®ä»çµã¿ã®äŸ
åçã¢ããªã±ãŒã·ã§ã³ã®ããžãã¯ã®å€æŽ
倧èŠæš¡ãªPNGèªè
Yelpã¯ãã«ã¹ã¿ã ã³ã³ãã³ãã®2ã€ã®åœ¢åŒïŒJPEGãšPNGïŒã§åäœããŸãã JPEGã¯åçã«ã¯é©ããŠããŸãããéåžžãã³ã³ãã©ã¹ãã®é«ããã¶ã€ããŒã³ã³ãã³ãïŒããŽãªã©ïŒã«ã¯å¯Ÿå¿ããŠããŸããã å¯Ÿç §çã«ãPNGã¯ç»åãå®å šã«ãã¹ã¬ã¹ã«å§çž®ããã°ã©ãã£ãã¯ã«ã¯æé©ã§ãããå°ããªæªã¿ããŸã ç®ç«ããªãåçã«ã¯æ±ãã«ããã§ãã ãŠãŒã¶ãŒãPNG圢åŒã§åçãã¢ããããŒãããå Žåããã®ãããªãã¡ã€ã«ãèªèããŠJPEGã§ä¿åããã°ãå€ãã®ã¹ããŒã¹ãç¯çŽã§ããŸãã Yelpã®PNGåçã®äž»ãªæ å ±æºã®1ã€ã¯ãåçãå€æŽããå¹æãé©çšãããã¬ãŒã ãè¿œå ããã¢ãã€ã«ããã€ã¹ããã³ã¢ããªã±ãŒã·ã§ã³ã®ã¹ã¯ãªãŒã³ã·ã§ããã§ãã
å·ŠïŒããŽãšãã¬ãŒã ã䜿çšããäžè¬çãªPNGã®çµã¿åããã å³ïŒã¹ã¯ãªãŒã³ã·ã§ããã®å žåçãªPNGã
ãã®ãããªãªãã·ã§ã³ã®PNGã®æ°ãæžããããã£ãã®ã§ããã圢åŒãå€æŽããããããŽãã°ã©ãã£ãã¯ã¹ãªã©ã®å質ãäœäžããããããŠç¡çãããªãããšãéèŠã§ãããç»åãåçãã©ãããå€æããã«ã¯ã©ãããã°ããã§ããïŒ ãã¯ã»ã«ã§ïŒ
2500æã®ç»åã®å®éšãµã³ãã«ã確èªããåŸããã¡ã€ã«ãµã€ãºãšäžæã®ãã¯ã»ã«æ°ã®çµã¿åããã«ãããåçãæ£ç¢ºã«æ±ºå®ã§ããããšãããããŸããã æ倧解å床ã§å°ããªã³ããŒãçæãããã¡ã€ã«ãµã€ãºã300 KiBãè¶ ãããã©ããã確èªããŸãã ãã®å Žåã2 16ãè¶ ããäžæã®è²ã®ç»åãã¯ã»ã«ã確èªããŸãïŒYelpã¯ããŠã³ããŒãããRGBAç»åãRGBã«å€æããŸããããããè¡ããªãã£ãå Žåãããã確èªããŸãïŒã
å®éšãµã³ãã«ã§ã¯ãââã倧ããªåçãã®å®çŸ©ã«é¢ãããã®ãããªæåèšå®ã«ãããã°ã©ãã£ãã¯ã¹ã«èª€æ€åºããªããæé©åã«é©ããŠããå¯èœæ§ããããã¹ãŠã®ãã¡ã€ã«ã®88ïŒ ãæããã«ãªããŸãã
ãã€ãããã¯JPEGå質
JPEGãã¡ã€ã«ã®ãµã€ãºãçž®å°ããæåã§æãæåãªæ¹æ³ã¯ã
quality
ãšããèšå®ã䜿çšãã
quality
ã§ãã JPEG圢åŒã§ä¿åã§ããå€ãã®ã¢ããªã±ãŒã·ã§ã³ã§ã¯ã
quality
ãæ°å€ãšããŠå®çŸ©ããŠããŸãã
å質ã¯äžçš®ã®æœè±¡åã§ãã å®éãJPEGç»åã®åã«ã©ãŒãã£ã³ãã«ã«ã¯åå¥ã®å質ã¬ãã«ããããŸãã 0ã100ã®å質ã¬ãã«ã¯ãã«ã©ãŒãã£ãã«ã®ç°ãªãéååããŒãã«ã«å¯Ÿå¿ãã倱ãããããŒã¿ã®éã決å®ããŸãïŒéåžžã¯é«åšæ³¢æ°ã§ïŒã ä¿¡å·ã®éååã¯ãæ å ±ã倱ãããå Žåã®JPEGã³ãŒãã£ã³ã°ããã»ã¹ã®æé ã®1ã€ã§ãã
ãã¡ã€ã«ãµã€ãºãçž®å°ããæãç°¡åãªæ¹æ³ã¯ããã€ãºãå¢ããããšã§ç»è³ªãäœäžãããããšã§ãã ãã ãããã¹ãŠã®ç»åãåãå質ã¬ãã«ã§åãéã®æ å ±ã倱ãããã§ã¯ãããŸããã
å質ãšãµã€ãºã®å®ç§ãªãã©ã³ã¹ãå®çŸããããã«ãå質èšå®ãåçã«å€æŽããåã ã®ç»åããšã«æé©åããããšãã§ããŸãã ãããè¡ãã«ã¯2ã€ã®æ¹æ³ããããŸãã
- ããã ã¢ããïŒãããã®ã¢ã«ãŽãªãºã ã¯ãã«ã¹ã¿ãã€ãºãããéååããŒãã«ãçæãã8Ã8ãã¯ã»ã«ã®ãããã¯ã¬ãã«ã§ç»åãåŠçããŸãã 圌ãã¯åæã«ãçè«äžã®å質ãã©ãã ã倱ããããããããŠãããã®å€±ãããããŒã¿ã人éã®ç®ã®æªã¿ã®å€èŠ³ãã©ã®ããã«åäžãŸãã¯æžå°ãããããèšç®ããŸãã
- ãããããŠã³ïŒãããã®ã¢ã«ãŽãªãºã ã¯ãç»åå šäœãå ã®ããŒãžã§ã³ãšæ¯èŒãã倱ãããæ å ±ã®éãå€æããŸãã å質èšå®ãç°ãªãåè£ãäžè²«ããŠçæããããã䜿çšããè©äŸ¡ã¢ã«ãŽãªãºã ã«å¿ããŠãæäœã¬ãã«ã®è©äŸ¡ã«å¯Ÿå¿ãããã®ãéžæã§ããŸãã
ããã ã¢ããã¢ã«ãŽãªãºã ã®åäœãè©äŸ¡ããçµæã䜿çšãããæé«å質ã®èšå®ã§é©åãªçµæãåŸãããªããšããçµè«ã«éããŸããïŒãã ããç Žæ£ã®éžæã«é¢ããŠãšã³ã³ãŒãããã倪ããªãå¯èœæ§ãããäžå質ã®ç¯å²ã§æœåšæ§ãããããã§ãïŒãã€ãïŒã ãã®æŠç¥ã«é¢ããå€ãã®ç§åŠ è«æã¯ãã³ã³ãã¥ãŒãã£ã³ã°ãªãœãŒã¹ãäžè¶³ããŠãã90幎代åé ã«å ¬éãããããããããã¯éã®é¢ä¿ã®è©äŸ¡ãªã©ããªãã·ã§ã³Bã䜿çšãããªãœãŒã¹éçŽçãªæ¹æ³ã䜿çšããããšã¯å°é£ã§ããã
ããã§ã2çªç®ã®ã¢ãããŒãã«ç§»ããŸããïŒåå²ã¢ã«ãŽãªãºã ãååã«äœ¿çšããŠç°ãªãå質ã¬ãã«ã§åè£ç»åãçæãããã®å€ãã«ã¹ã¿ã ã®ç¯å²å ã«ããéãã pyssimã䜿çšããŠæ§é é¡äŒŒæ§ææ°ïŒ SSIM ïŒãèšç®ããŠåç»åã®å質äœäžãè©äŸ¡ããŸãããããéçãªãããå€ã ããã«ãããç¥èŠããããããå€ãè¶ ããç»åã«ã€ããŠã®ã¿ãå¹³åãã¡ã€ã«ãµã€ãºïŒããã³å¹³åå質ïŒãéžæçã«äžããããšãã§ããŸããã
次ã®å³ã§ã¯ã3ã€ã®ç°ãªãå質èšå®ã§åçæããã2,500åã®ç»åã®SSIMå€ã衚瀺ããŠããŸãã
-
quality = 85
çŸåšã®æ¹æ³ã䜿çšããŠäœæãããå ã®ç»åã¯éã§è¡šç€ºãããŸãã - å質èšå®ã
quality = 80
ã«æžãããŠããã¡ã€ã«ãµã€ãºãå°ããããå¥ã®ã¢ãããŒããèµ€ã§ç€ºããŠããŸãã - æåŸã«ã
SSIM 80-85
åçãªå質ã§ããã¢ãããŒãããªã¬ã³ãžè²ã§ç€ºãããŠããŸãã ããã§ãå質ã¯ãSSIMã®æ¯çã®äžèŽãŸãã¯éå°ã«å¿ããŠã80ãã85ïŒäž¡ç«¯ãå«ãïŒã®ç¯å²ããéžæãããŸããããã¯ãç»åç¯å²ã®äžå€®ã§ãã®é·ç§»ãè¡ãäºåã«èšç®ãããéçå€ã§ãã ããã«ãããèŠæ ãã®æªãç»åã®å質ãäœäžãããããšãªããå¹³åãã¡ã€ã«ãµã€ãºãåæžã§ããŸãã
å質èšå®ãå€æŽããããã®3ã€ã®ç°ãªãæŠç¥ãæã€2500ç»åã®SSIMã€ã³ããã¯ã¹
SSIMïŒ
人éã®èŠèŠã·ã¹ãã ãæš¡å£ããããšããç»åã®å質ãå€æŽããããã®ã¢ã«ãŽãªãºã ãããã€ããããŸãã ç§ãã¡ã¯ãããã®å€ããé«ãè©äŸ¡ããSSIMã¯å€ããã®ã®ããã®ç¹æ§ã«ããããã®ãããªå埩æé©åã«æé©ã§ãããšèããŠããŸãã
- JPEGéååãšã©ãŒã®åœ±é¿ãåãããã
- é«éã§ã·ã³ãã«ãªã¢ã«ãŽãªãºã
- ç»åãPNGã«å€æããŠCLIã¢ããªã±ãŒã·ã§ã³ã«è»¢éããããšãªãããã€ãã£ãPILãªããžã§ã¯ãã§èšç®ã§ããŸãïŒïŒ2ãåç §ïŒ
åçå質ã®ãµã³ãã«ã³ãŒãïŒ
import cStringIO import PIL.Image from ssim import compute_ssim def get_ssim_at_quality(photo, quality): """Return the ssim for this JPEG image saved at the specified quality""" ssim_photo = cStringIO.StringIO() # optimize is omitted here as it doesn't affect # quality but requires additional memory and cpu photo.save(ssim_photo, format="JPEG", quality=quality, progressive=True) ssim_photo.seek(0) ssim_score = compute_ssim(photo, PIL.Image.open(ssim_photo)) return ssim_score def _ssim_iteration_count(lo, hi): """Return the depth of the binary search tree for this range""" if lo >= hi: return 0 else: return int(log(hi - lo, 2)) + 1 def jpeg_dynamic_quality(original_photo): """Return an integer representing the quality that this JPEG image should be saved at to attain the quality threshold specified for this photo class. Args: original_photo - a prepared PIL JPEG image (only JPEG is supported) """ ssim_goal = 0.95 hi = 85 lo = 80 # working on a smaller size image doesn't give worse results but is faster # changing this value requires updating the calculated thresholds photo = original_photo.resize((400, 400)) if not _should_use_dynamic_quality(): default_ssim = get_ssim_at_quality(photo, hi) return hi, default_ssim # 95 is the highest useful value for JPEG. Higher values cause different behavior # Used to establish the image's intrinsic ssim without encoder artifacts normalized_ssim = get_ssim_at_quality(photo, 95) selected_quality = selected_ssim = None # loop bisection. ssim function increases monotonically so this will converge for i in xrange(_ssim_iteration_count(lo, hi)): curr_quality = (lo + hi) // 2 curr_ssim = get_ssim_at_quality(photo, curr_quality) ssim_ratio = curr_ssim / normalized_ssim if ssim_ratio >= ssim_goal: # continue to check whether a lower quality level also exceeds the goal selected_quality = curr_quality selected_ssim = curr_ssim hi = curr_quality else: lo = curr_quality if selected_quality: return selected_quality, selected_ssim else: default_ssim = get_ssim_at_quality(photo, hi) return hi, default_ssim
ãã®ææ³ã«ã€ããŠã¯ãä»ã«ãããã°èšäºãããã€ããããŸããã³ã«ããã«ã³ãªã¹ã®èšäºãã芧ãã ããã ãŸããå ¬éãããšãã«ãEtsyãå ¬éããŸããïŒ ãã€ãã¡ã€ããé«éã€ã³ã¿ãŒãããïŒ
JPEGãšã³ã³ãŒããŒã®å€æŽ
ã¢ãºãžãã°
Mozjpegã¯libjpeg-turboã®ãªãŒãã³ãœãŒã¹ãã©ãŒã¯ã§ããã¡ã€ã«ãµã€ãºã®ããã«ã©ã³ã¿ã€ã ãç ç²ã«ããŸããã ãã®ã¢ãããŒãã¯ããªãã©ã€ã³ãã¡ã€ã«å埩ãã€ãã©ã€ã³ãšã®äºææ§ããããŸãã libjpeg-turboã®3ã5åã®ãªãœãŒã¹æ¶è²»ã«ããããã®ã¢ã«ãŽãªãºã ã¯ç»åã®ãµã€ãºãå°ããããŸãã
mozjpegã®éãã®1ã€ã¯ã代æ¿ã®éååããŒãã«ã䜿çšããããšã§ãã åè¿°ã®ããã«ãå質ã¯åã«ã©ãŒãã£ãã«ã®éååããŒãã«ã®æœè±¡åã§ãã ãã¹ãŠã®å åã¯ãããã©ã«ãã®JPEGéååããŒãã«ãéåžžã«ç°¡åã§ããããšã§ãã JPEGä»æ§ãèšãããã«ïŒ
ãããã®è¡šã¯äŸãšããŠã®ã¿æäŸãããŠãããç¹å®ã®ã¢ããªã±ãŒã·ã§ã³ã«å¿ ãããé©ããŠããããã§ã¯ãããŸããã
ãããã£ãŠãåœç¶ããããã®ããŒãã«ããšã³ã³ãŒãã®ã»ãšãã©ã®å®è£ ã§ããã©ã«ãã§äœ¿çšãããŠããããšã«é©ããªãã§ãã ãã...
Mozjpegã¯ä»£æ¿ããŒãã«ãæ¯èŒãããšãã倧å€ãªäœæ¥ãè¡ããç»åçææã«æé«ã®ããã©ãŒãã³ã¹ãçºæ®ãã代æ¿ããŒãã«ã䜿çšããŠããŸãã
Mozjpeg +æ
ã»ãšãã©ã®Linuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã«ã¯ãããã©ã«ãã§libjpegãã€ã³ã¹ããŒã«ãããŠããŸãã ãã®ãããPillowã®äžã®mozjpegã¯ããã©ã«ãã§ã¯æ©èœããŸããããæ§æã§æ§æããã®ã¯ããã»ã©é£ãããããŸããã mozjpegããã«ããããšãã¯ã
--with-jpeg8
ã䜿çšããŠãPillowãšãªã³ã¯ã§ããããšã確èªããŠãã ããã Dockerã䜿çšããå Žåã次ã®ãããªDockerfileãäœæã§ããŸãã
FROM ubuntu:xenial RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install \ # build tools nasm \ build-essential \ autoconf \ automake \ libtool \ pkg-config \ # python tools python \ python-dev \ python-pip \ python-setuptools \ # cleanup && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Download and compile mozjpeg ADD https://github.com/mozilla/mozjpeg/archive/v3.2-pre.tar.gz /mozjpeg-src/v3.2-pre.tar.gz RUN tar -xzf /mozjpeg-src/v3.2-pre.tar.gz -C /mozjpeg-src/ WORKDIR /mozjpeg-src/mozjpeg-3.2-pre RUN autoreconf -fiv \ && ./configure --with-jpeg8 \ && make install prefix=/usr libdir=/usr/lib64 RUN echo "/usr/lib64\n" > /etc/ld.so.conf.d/mozjpeg.conf RUN ldconfig # Build Pillow RUN pip install virtualenv \ && virtualenv /virtualenv_run \ && /virtualenv_run/bin/pip install --upgrade pip \ && /virtualenv_run/bin/pip install --no-binary=:all: Pillow==4.0.0
以äžã§ãïŒ éåžžã®ç»ååŠçããã»ã¹ã§mozjpegã䜿çšããŠPillowãåéãã䜿çšã§ããããã«ããŸãã
å¹æ
ãããã®æ¹åç¹ã¯ã©ãã»ã©éèŠã§ãããïŒ 2,500æã®Yelpã®ããžãã¹åçã®ã©ã³ãã ãªãµã³ãã«ããå§ããããããåŠçãã€ãã©ã€ã³ã«éãããµã€ãºå€æŽã枬å®ããŸããã
- æã®èšå®ãå€æŽãããš4.5ïŒ ç¯çŽ
- 倧ããªPNGãç¹å®ãããš6.2ïŒ ç¯çŽ
- åçå質ã«ãã4.5ïŒ ç¯çŽ
- mozjpegãšã³ã³ãŒããŒã«åãæ¿ãããš13.8ïŒ ç¯çŽãããŸã
å šäœãšããŠãããã«ããå¹³åç»åãµã€ãºãçŽ30ïŒ åæžãããŸãããããã¯ãæãäžè¬çãªåç解å床ã«äœ¿çšãããŠãŒã¶ãŒã«ãšã£ãŠãµã€ããé«éåããããŒã¿è»¢éã§1æ¥ããããã©ãã€ããç¯çŽããŸããã CDNã¬ãã«ã§ä¿®æ£ããããšããïŒ
CDNã®çµæçãªå¹³åãã¡ã€ã«ãµã€ãºã®å€åïŒããã³ç»åã§ã¯ãªãä»ã®ãã¡ã€ã«ïŒ
ããªãã£ãããš
ãã®ã»ã¯ã·ã§ã³ã§ã¯ã䜿çšã§ããä»ã®ããã€ãã®å žåçãªæé©åã«ã€ããŠèª¬æããŸãããããŒã«ã®ããã©ã«ãèšå®ã®ããããŸãã¯ãã®ãããªåŠ¥åãæå³çã«æåŠããããããããã¯Yelpã«é©ããŠããŸããã§ããã
ããŠã³ãµã³ããªã³ã°
ãµããµã³ããªã³ã°ã¯ãWebç»åãã¡ã€ã«ã®å質ãšãµã€ãºã®äž¡æ¹ã決å®ããéèŠãªèŠçŽ ã§ãã ããŠã³ãµã³ããªã³ã°ã®è©³çŽ°ãªèª¬æã¯ã€ã³ã¿ãŒãããã§èŠã€ããããšãã§ããŸããããã®èšäºã§ã¯ãã§ã«
4:1:1
ããŠã³ãµã³ããªã³ã°ãå®è¡ããŠãããšèšãã ãã§ååã§ãïŒä»ã®èšå®ãæå®ããªãéãããããã¯Pillowã®ããã©ã«ãèšå®ã§ãïŒããããªãæé©åãç²åŸããŸãã
ããã·ãŒPNGãšã³ã³ãŒãã£ã³ã°
PNGã§äœãããŠããã®ãããããã®ç»åãåã圢åŒã§ä¿åãããªãã·ã§ã³ãç¥ã£ãŠããŸããã pngminiã®ãããªéå¯éãšã³ã³ãŒããŒã䜿çšããããšã¯çã«ããªã£ãŠããŸãããJPEGå§çž®ãªãã·ã§ã³ãéžæããŸããã ããã§ãããšã³ã³ãŒãã®äœæè ã¯ããã¡ã€ã«ã®å§çž®ã«ã€ããŠ72ã85ïŒ èšã£ãŠãããããããã¯åŠ¥åœãªçµæããããã代æ¿æ段ã§ãã
ããçŸä»£çãªãã©ãŒããã
WebPãJPEG2kãªã©ã®ããæ°ãã圢åŒã®ãµããŒãã¯ãç§ãã¡ã«ãã£ãŠç¢ºå®ã«èæ ®ãããŸããã ããããä»®ã«ãã®ä»®æ³ãããžã§ã¯ããå®è£ ãããšããŠããJPEG / PNGç»åãå¿ èŠãšãããŠãŒã¶ãŒã®ãã³ã°ããŒã«ãååšããããããããã«ããããããæé©åããåªåã¯ç¡é§ã§ã¯ãããŸããã§ããã
Svg
SVGã¯ããã¶ã€ããŒãã¹ã¿ã€ã«ã¬ã€ãçšã«äœæããéçç»åãªã©ããµã€ãã®å€ãã®å Žæã§äœ¿çšããŸãã ãã®åœ¢åŒãšsvgoã®ãããªæé©åããŒã«ã¯ããŒãžãµã€ãºãå€§å¹ ã«åæžããŸããããããã¯ã¿ã¹ã¯ã«é©ããŠããŸããã
ãã³ããŒããžãã¯
ãµãŒãã¹ãšããŠç»åã®é ä¿¡ããµã€ãºå€æŽãããªãã³ã°ããã©ã³ã¹ã³ãŒããæäŸããŠããäŒæ¥ãå€ãããŸãã ãªãŒãã³ãœãŒã¹thumborãå«ãã å°æ¥çã«ã¯ããããã¬ã¹ãã³ã·ãç»åãåçã¿ã€ãã®ã³ã³ãã³ãã®ãµããŒããå®è£ ããæå 端ã®é²æ©ãç¶æããããã®æãç°¡åãªæ¹æ³ãããããŸããã ãããä»ãç§ãã¡ã¯èªåã§ããããã£ãŠããŸãã
ããã«èªã
ããã§èšåãããŠãã2åã®æ¬ã¯ããã®èšäºã®æèå€ã§ã¯å®å šã«èªçµŠèªè¶³ã§ããããã®ããŒãã«ã€ããŠããã«èªãããã«åŒ·ããå§ãããŸãã