Open recon88 opened 8 years ago
I'm sure we could pull in an image processing library to downsample a result, but that seems excessive.
The Random endpoint does include a field for the downsampled gif, as well as a "small" version. The trouble is the Random endpoint doesn't include the sizes of those gifs. The Search endpoint does provide the size
of the main, small, and downsampled gifs. For instance: http://api.giphy.com/v1/gifs/search?q=funny+cat&api_key=dc6zaTOxFJmzC&limit=1&offset=0
We already let you set the endpoint you hit, either with the ENV var HUBOT_GIPHY_DEFAULT_ENDPOINT
or if you search like hubot gif me /search some search query
. So, you could:
search
the default endpointsize
is above MAX_GIF_SIZE, use the small or downsampled gif insteadWe already pull a random image from a search result (default of 25), so you'd get a similar effect to the Random endpoint out of search.
Interested in submitting a PR? If not, this seems like something I could take care of.
Sorry for the late answer. Didn't have the time for a PR. Would appreciate if you implement that missing feature.
We are using Flowdock with Hubot and your script. Sometimes the gifs are that huge, it will just lag everyone's client to death. Would it be possible to implement an option to limit size or even better provide downsampled results if they exceed the given size limit?
The giphy API seems to be supporting this. Just take a look at the example response: https://github.com/Giphy/GiphyAPI#random-endpoint