Gabe Stang ( geb dev )

home / who | blog | things | 🎝 art | github

Many Pictures

Try me out @ https://many-pictures.github.io/tags: images, pixabay

Motivation

I've often toyed around writing scripts to generate random images from google images. I thought it would be an interesting screensaver, since you never know what you're going to get!

Google images doesn't have a very good free API, despite the fact that anyone can make requests to google images from our browser for free. As such, the obvious approach I take would be to shoddily "reverse engineer" the google search bar to https://www.google.com/search?q=your+search+query+here&tbm=isch [1]That last part &tbm=isch tells google to only search images., then make an HTTP request & hope for the best. This approach typically ends in a buggy tool that mostly generates poor quality images.

This time around, in order to beat both issues, I decided to look into Pixabay. Pixabay is a nice website for finding free photos submitted by users, most of which are quite high quality given that they're forced to go through a layer of community voting first. It just so happens that Pixabay has a really nice free API that fit my purposes!


What is it?

Many Pictures is a screensaver website that uses Pixabay's public API in order to automatically scroll through images.

The entire purpose of Many Pictures is to act as a screensaver for when you have a computer that's sitting idle. The current version of Many Pictures scrolls through images in chronological order, and never repeats!


example of the 921st image added to Pixabay, including formatting


Problems

Pixabay's free API key has a limit of 100 requests per minute. If the scroll speed ever loads images faster than once per 600ms, Many Pictures will detect it using a geometric average and throttle the scroll speed accordingly.


chart of the geometric average time vs the exact time the image took to load, including scroll speed


You can see in the above chart that the geometric average helps rough out any accidental speedups / slowdowns. When recording this data, I only ever increased the scroll speed, while the algorithm slowed it down. A nice side-effect of this approach is that all slowdowns are somewhat smooth, and typically occur all at once.


Usage

In order to use Many Pictures you need your own API key. 100 images per minute is too shallow of a limit for more than a few people to use at a time, but luckily Pixabay API keys are free! Use the following rules to grab your own key & plug it into Many Pictures.


woooooo~


Feel free to check out GitHub if you'd like to see how I used the Pixabay API, or have any other questions



🌊