Skip to content

bmuller/fastimage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastImage travis

This is an implementation of the excellent Ruby library FastImage - but for Python.

FastImage finds the size or type of an image given its uri by fetching as little as needed.

Installation

pip install fastimage

Usage

Usage is pretty dang simple.

import asyncio
from fastimage.detect import get_size

loop = asyncio.get_event_loop()
url = "http://stephensykes.com/images/ss.com_x.gif"
width, height = loop.run_until_complete(get_size(url))
print("Size:", width, "x", height)

which will poop out:

Size: 266 x 56

You can also just get the image type:

import asyncio
from fastimage.detect import get_type

loop = asyncio.get_event_loop()
url = "http://stephensykes.com/images/ss.com_x.gif"
result = loop.run_until_complete(get_type(url))
print("Type:", result)

which will poop out:

Type: gif

Right now, sizes can be deduced from webp / gif / jpg / png. Additionally, it can detect the type (but not size) of bmp / tiff.

About

Python library that finds the size / type of an image given its URI by fetching as little as needed

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published