Hacker News new | ask | show | jobs
by jason_adleberg 4931 days ago
can anyone take a guess as to how this works? i have not a clue.
3 comments

On top of the obvious (resize to largest dimension, crop smallest) I'm guessing they set an anchor point on the image rather than use the center.

For example, the pig's face isn't centered. So rather than returning the center of the image, they crop the sides proportionally to the anchor point on the pig's face.

Edit: Nup. They just crop it down the middle. If you're the developer feel free to steal the above.

They have some set of categorized photos and simply crop them to the size you request after selecting a random one.
They have a page[1] listing all of their images (the "Images" tab at the top-right).

[1] http://lorempixel.com/images.php

I would guess they pull from the wiki commons and then use typical JPG or PNG algorithm libraries to stretch or compress the image. There's probably some AI to retrieve images that don't need to be stretched much so that it looks natural.
From their images list:

> The provided images are for layout purposes and each image we use for this project is released under the creative commons license (CC BY-SA). For more information visit http://creativecommons.org/licenses/ So, if you want to use the images for more than just layouts, you have to double check the license and ask the author. For this we will link to each photographer's flickr page. Furthermore, we assume no liability.

Almost any picture can be used, the algorithm just needs to stretch and crop to maintain the correct image size ratio.