Pythontr

husonet | Tarih: 30.03.2015

Nginx resimleri yeniden boyutlandırma

Nginx web sunucusu ile resimlerin yeniden boyutlandırma orjian adıyla resize ve crop işleminin yapılması

Sunucularımıza performans katmak amacıyla resim boyutlandırmada bir çok yol deniyorum ve bulduğum birkaç yoldan biride bu işi web sunucunun üzerine yıkma işlemi sonuç gayet başarılı. Bu işlemi php üzerinde yıkmışken ortalama load 1 lerin üzerine çıkmıştı şimdi ise ortalama olarak 0.50 lere düştü. Bu değerlerde ortalam %50 performans artışı demektir.


        # resim resize
location ~^/img/(\d*)x(\d*)/(.*) {
autoindex on;
expires 30d;
set $width $1;
set $height '-';
set $height $2;
set $path $3;
# image_filter crop $width $height;
image_filter resize $width $height;
image_filter_jpeg_quality 75;
image_filter_buffer 2M; #change this to meet your needs
alias /home/www/xxx.com/img/$path; #root where your image folder resides + $path
break;
}

Aynı şekilde crop lamada yapabiliriz
        # resim crop
location ~^/img/(\d*)x(\d*)/(.*) {
autoindex on;
expires 30d;
set $width $1;
set $height '-';
set $height $2;
set $path $3;
image_filter crop $width $height;
# image_filter resize $width $height;
image_filter_jpeg_quality 75;
image_filter_buffer 2M; #change this to meet your needs
alias /home/www/xxx.com/img/$path; #root where your image folder resides + $path
break;
}