çµå©å¼ã®åçãå±ããã®ã§è¦ªæã«å±ãããã
ãã©ããã3MB*700æ=2GBãããã®ãã¼ã¿éã¨ãªã£ã¦ãã¾ã£ã¦ãããããããªããã¦ã³ãã¼ããã¦ãã¨ããã®ã¯ãã¾ãç¸æã®ç°å¢ãèæ ®ãã¦ããªãã ããã
å¡ã¯å¡ã§ãã¦ã³ãã¼ããã¦ããããã¨ãã§ããã¨ãã¦ãwebãã©ã¦ã¶ã§æ軽ã«è¦ããæ¹æ³ããã£ã¦ãããã¯ãã
webãã©ã¦ã¶ã§è¡¨ç¤ºãããã¨ããã¨å ¨é¨ã¯ç¡çãªã®ã§ãã¼ã¸ã³ã°ãããããªãã
ãã¼ã¸ã³ã°ããã¨ãã¦ãä¸æã§3MBã®ç»åãä½ååã¨ä¸¦ã¶ã®ãã¤ãã¤ããªæããããã
webãã©ã¦ã¶ããè¦ãåã«ã¯ç»è³ªãããç¨åº¦è½ã¨ãã¦æ軽ã«è¦ããããã«ããã¨è¯ãããã ã
é«ç»è³ªçã¯å¥éãã¦ã³ãã¼ããã¦ãã¨ããæãã
ãã®ããã«ã¯700æã®ç»åãimage magickã§ç¸®å°ããã°ãããã©ããã®ä½æ¥ã1åã ãã¨ã¯éããªãã®ã§ããã°ã©ããªãã¹ã¯ãªããåãããã
以ä¸ã¿ããã¨ã
以ä¸å®æãã8並åã§700æã®ç»åã20%ã«ãªãµã¤ãºããã¹ã¯ãªããã
root_path = "../../app/assets/images" from_dir = "all_image" to_dir = "thumb" pids = [] Dir.chdir root_path do Dir.glob("#{from_dir}/*") do |from_path| puts from_path pids << fork do Process.exec(['convert', '-geometry', '20%', from_path, from_path.sub(/all_image/, to_dir)].join(' ')) end if 8 <= pids.length pid,status = Process.wait2 unless pids.delete(pid) fail status.inspect end end end end Process.waitall
ããªãé©å½ã ãã©ãããã§æ大ããã»ã¹ã8åã«æãã¤ã¤ä¸¦åã§å¦çã§ããã ä¸åãã¤ã®æãã測ã£ã¦ãªããã©æè¦çã«ã¯ã ãã¶éãã
ãã®æããæ £ããã¨ã¹ããããçã«ä½¿ãããã