nginxで頭を切り落とす

少し前まで、Topface Developer Day( speakerdeckでのプレゼンテーション)でTopfaceがカスタム画像を保存および配布する方法について話しました 。 image_filterを使用してnginxでその場で写真をカットします。

人々は主に縦方向に長方形であり、出会い系サービスのための自分の写真は適切なものを撮り、デザイナーは小さな正方形を望み、nginxは人々が興味を持っているものではなく人々に切り取ります(私は顔を意味します)。 longcatの例を使用すると、次のようなものが得られます。

ロングキャット

あなたは通常の方法でこれと一緒に暮らす必要があります:それを取り、自分でそれを終了します。 その結果、image_filterモジュール用のパッチを入手しました。これは、クロップが発生したときに、画像のどちらの側でエッジを切り取る必要がないかを示すことができます。 githubですべて良好です。

カスタマイズ

簡単です。必要な場所またはサーバーにディレクティブを入力する必要があります。

image_filter_offset {left,center,right} {top,center,bottom};

良い例


縦の写真

オリジナル:

Original vertical image

上部の配置: image_filter_offset center top;

Aligned to top vertical image

中央揃え(通常の動作): image_filter_offset center center;

Aligned to center vertical image

下揃え: image_filter_offset center bottom;

Aligned to bottom vertical image

横の写真

オリジナル:

Original horizontal image

image_filter_offset left center;image_filter_offset left center;

Aligned to left horizontal image

中央揃え(通常の動作): image_filter_offset center center;

Aligned to center horizontal image

image_filter_offset right center;image_filter_offset right center;

Aligned to right horizontal image

見逃した方へ: githubへリンク

Source: https://habr.com/ru/post/J157457/


All Articles