
Cut off the head in nginx
Not so long ago, I talked about how Topface stores and distributes custom images on Topface Developer Day ( presentation on speakerdeck ). We cut pictures on the fly in nginx using image_filter.
People are mostly oblong in the vertical direction and photographs of themselves for the dating service make appropriate ones, designers want small squares, and nginx cuts out to people not quite what people are interested in (I mean the face). Using the example of longcat, we get something like the following:

You have to live with this in the usual way: take it and add it yourself. As a result, I got a patch for the image_filter module, which can be said which side of the image does not need to cut off the edges when crop occurs. All good on github .
It's simple, you need to enter the directive in the location or server you need.
Original:

Alignment to the top:

Alignment to the center (normal behavior):

Alignment to the bottom:

Original:

Left justify:

Center justify (normal behavior):

Right justify:

For those who missed: link to github .
People are mostly oblong in the vertical direction and photographs of themselves for the dating service make appropriate ones, designers want small squares, and nginx cuts out to people not quite what people are interested in (I mean the face). Using the example of longcat, we get something like the following:

You have to live with this in the usual way: take it and add it yourself. As a result, I got a patch for the image_filter module, which can be said which side of the image does not need to cut off the edges when crop occurs. All good on github .
Customization
It's simple, you need to enter the directive in the location or server you need.
image_filter_offset {left,center,right} {top,center,bottom};
Good examples
Vertical pictures
Original:

Alignment to the top:
image_filter_offset center top;

Alignment to the center (normal behavior):
image_filter_offset center center;

Alignment to the bottom:
image_filter_offset center bottom;

Horizontal pictures
Original:

Left justify:
image_filter_offset left center;

Center justify (normal behavior):
image_filter_offset center center;

Right justify:
image_filter_offset right center;

For those who missed: link to github .