SMALL LIGHT(ã¹ã¢ã¼ã«ã©ã¤ã)ã§ç°¡åãµã ãã¤ã«ä½æ - ã¤ã³ã¹ãã¼ã«ç·¨ -
Webãµã¤ãã«ããããµã ãã¤ã«ç»åã¨SMALL LIGHTã«ã¤ãã¦
Webãµã¤ãã§ãµã ãã¤ã«ç»åãå¿
è¦ã«ãªãã¨ããã®ã¯å¤ã.
ã¢ãããã¼ãæã«Resizeä½ããï½ã¨ã,ãªãã ã¨ãããã ã¨ã,éç¨ã¾ã§èãã¦ã¿ãã¨,æå¤ã¨ã¡ã³ãã¯ãµã¤åé¡ã§ãã£ãããã.
ããã¦,ä»æ§å¤æ´ã§Resizeç»åãµã¤ãºå¤æ´ã,ã¨ã.çµæ§æ»ãã.
SMALL LIGHT(ã¹ã¢ã¼ã«ã©ã¤ã)ã¯,ãããªãµã ãã¤ã«ç»åã®ä½æã管çãè¯ãæãã«ãã£ã¦ãããlivedoor ã©ããEDGEã製ã®Apacheã¢ã¸ã¥ã¼ã«.
åçã¯åç´ã§,Apacheä¸ã§mod_small_lightã¨ããã¢ã¸ã¥ã¼ã«ãå±éãã¦ããã¦,ããã¤ãImageMagickãimlib2ã¨ãã£ãç»åå¤æã½ããã¦ã§ã¢ã®ã©ããã¼ã¨ãã¦åãã¦ãããã¨ããããã§ã.
ãããã¦ã¿ãã¨ããããã©,ãæ軽ã ã,ããªã便å©.
livedoorãªã©ã®å¤§è¦æ¨¡ãµã¤ãã§ãå©ç¨ããã¦ããããã§,å®ç¸¾ãããã¨ããã®ãã¾ãé åçã£ãã.
以ä¸ãåç½®ãã§ãã¦..
ã¤ã³ã¹ãã¼ã«ãå®éç¨ã«çºå±ãããããã®ãã£ãã·ã¥æ¦ç¥ã¨ã,æ°æã¡ãç¶ãéãæ¸ã.
1.SMALL LIGHT(ã¹ã¢ã¼ã«ã©ã¤ã)ã§ç°¡åãµã ãã¤ã«ä½æ - ã¤ã³ã¹ãã¼ã«ç·¨ - ï¼ãã¾ããï¼
2.SMALL LIGHT(ã¹ã¢ã¼ã«ã©ã¤ã)ã§ç°¡åãµã ãã¤ã«ä½æ - æ§è½æ¤è¨¼ç·¨ - ï¼ãã®ãã¡æ¸ãï¼
3.SMALL LIGHT(ã¹ã¢ã¼ã«ã©ã¤ã)ã§ç°¡åãµã ãã¤ã«ä½æ - ãã£ãã·ã¥æ¦ç¥ç·¨ - ï¼ãã®ãã¡æ¸ãï¼
ã¤ã³ã¹ãã¼ã«
æ¤è¨¼ç°å¢
ãããã®VPS
CentOS release 6.3 (Final) 64bit
æ¤è¨¼æã®ã½ããã¦ã§ã¢ãã¼ã¸ã§ã³
Apache
Server version: Apache/2.2.15 (Unix)
ImageMagick
6.7.6 Q16
imlib2
1.4.4
SMALL LIGHTã®ã¤ã³ã¹ãã¼ã«
æ¬ä¸¸.
[user1@ns1 ~] $ cd /usr/local/src # ãã¦ã³ãã¼ã [user1@ns1 /usr/local/src] $ wget http://smalllight.googlecode.com/files/mod_small_light-1.1.1.tar.gz [user1@ns1 /usr/local/src] $ tar zxf mod_small_light-1.1.1.tar.gz [user1@ns1 /usr/local/src] $ cd mod_small_light-1.1.1 # ImageMagickã¨imlib2ãå©ç¨ããããã«configure [user1@ns1 /usr/local/src] $ ./configure --with-apxs=[apxsã®ãã¹] --with-imlib2-config=[imlib2-configã®ãã¹] --with-Wand-config=[Wand-configã®ãã¹] [user1@ns1 /usr/local/src] $ make [user1@ns1 /usr/local/src] $ sudo make install
â» makeãä¸æãã§ããªãå ´åã¯,以ä¸ã®ãã¼ã¸ãåèã«ããã¨ããããããã¾ãã.
Apacheの動的画像リサイズモジュール「smalllight」のmakeが通らなかったのを直してみた。 - コロタエンヂニアリング
Apacheã®è¨å®
make installããã¨åæã«httpd.confã«æ¸ãè¾¼ã¾ããã½ãã§ãã,以ä¸ã®ã¢ã¸ã¥ã¼ã«ãLoadModuleã§èªã¿è¾¼ã¾ãã¦ããå¿ è¦ãããã¾ã.
LoadModule small_light_module /path/to/hoge/mod_small_light.so
ããã¦,mod_rewirteã§URLè¨è¨ããã¦,ä¸æãSMALL LIGHTã®filterãéãã¦ãããããã«ãã¾ã.
ä¾ï¼small_lightã§å§ã¾ãURLã®ãã®ã¯,å¤æ対象ã¨ããï¼VirtualHostè¨å®ã®ä¸ã¨ãã«æ¸ãï¼
RewriteRule ^/small_light[^/]*/(.+)$ /path/to/img/$1 <LocationMatch ^/small_light[^/]*/> SetOutputFilter SMALL_LIGHT </LocationMatch>
â»公式サイトの解説ãããªã詳ããã®ã§,åºæ¥ãã°ãããä¸åèªãã æ¹ãããã¨æãã¾ã.
ããã¾ã§åºæ¥ã¦ããã°,ãã¨ã¯å®éã«åããã¦ã¿ã¾ããã.
åä½æ¤è¨¼
/path/to/img ã«ç»åç½®ãã¦ããåæã§ã.
http://[URL]/img/hoge.jpeg
âãªãªã¸ãã«ã®ç»åã表示ããã
http://[URL]/small_light(dw=400,dh=400,ds=s, e=imagemagick)/hoge.jpeg
âImageMagickã§å¤æããç»åã表示ããã
http://[URL]/small_light(dw=400,dh=400,ds=s, e=imlib2)/hoge.jpeg
âimlib2ã§å¤æããç»åã表示ããã
ãã¼ã,ãæ軽ã£.
ãã¼ã±ã¼ãæè»½è² è·æ¤è¨¼
è² è·æ¤è¨¼ã¯ã¾ãå¥ã¨ã³ããªãã¾ãã,ãã¼ã±ã¼ãæ軽ãªæãã§[F5]é£ææã®å¤æã³ã¹ããvmstatã§ã¢ãã¿ãªã³ã°.1200Ã800ã®jpegç»åã§ãã£ã¦ããã¾ã.
注ç®ã¯,[memory]ã®[free]ã¨[cpu]ã®[us]æ°å¤.
ImageMagickï¼cpuãã¡ãä¸ããï¼
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 384 579748 108548 188360 0 0 0 0 206 32 7 1 93 0 0 9 0 384 463788 108548 188360 0 0 0 0 2290 577 72 16 3 0 10 11 0 384 410296 108548 188360 0 0 0 0 2367 686 91 9 0 0 1 15 0 384 364792 108548 188364 0 0 0 0 2214 690 88 12 0 0 0 23 0 384 309648 108548 188364 0 0 0 0 2071 689 85 14 0 0 0 27 0 384 201984 108548 188368 0 0 0 0 2043 695 82 18 0 0 0 0 0 384 530184 108556 188368 0 0 0 16 2017 654 89 7 5 0 0
imlib2ï¼ããã£â¦â¦ç§ã®è² è·ãä½ããâ¦â¦ï¼ï¼
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 384 481396 108636 188396 0 0 0 0 48 22 0 0 100 0 0 1 0 384 481272 108636 188812 0 0 0 0 795 89 16 2 80 0 2 1 0 384 481272 108636 188704 0 0 0 0 1113 106 23 3 72 0 2 1 0 384 481272 108636 188764 0 0 0 0 1357 122 30 4 64 0 1 1 0 384 481148 108636 188712 0 0 0 0 1268 118 26 4 65 0 5 0 0 384 481148 108636 188416 0 0 0 0 1329 121 28 4 66 0 2
imlib2ãã³ã»ã¼ã¨è¨ããããªãã¾ãã,ããã¤ãgifã«å¯¾å¿ãã¦ããªãç½ ãããã¾ã.
ä»åã¯ãã®ã¸ãã§ï¼