https://github.com/byteface/pythumb
base64 thumbnail generator
https://github.com/byteface/pythumb
Last synced: about 2 months ago
JSON representation
base64 thumbnail generator
- Host: GitHub
- URL: https://github.com/byteface/pythumb
- Owner: byteface
- Created: 2015-04-26T23:47:27.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-27T23:18:48.000Z (almost 11 years ago)
- Last Synced: 2025-12-03T12:15:19.445Z (4 months ago)
- Language: HTML
- Size: 492 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#PyThumb
Pass in images urls, returns base64 strings. use for things like thumbnails
Currently just pass 2 params. http path to image and a width constraint. i.e.
```
http://localhost:5000/thumbnail?image=http://127.0.0.1:5000/static/img/landscape.png?w=100
```
will return something like...
```
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAABLCAIAAACwbjOoAAAd4UlEQVR4nE16Waxm2XXWt9ba+0z/f+d...
```
For a working example run the app and also check out the code in...
server.py
index.html
that's as much as I need it for at the mo, Saves having to create/manage thumbnail images on the server as I can just create them on request.
##RUN
to run the example create a virutal environment and install the requirements, then run
```
python server.py
```
##lists
if you like Flask checkout the list renderer http://localhost:5000/list
and the list.html template for implementation
img folder contains a mixture of PNGS and JPG files to play with
##NOTE
I had to use threaded=True parameter in the flask app or it would just lock up when making the image request. I think it only happens when loading images from localhost? I think that port was busy serving my app, either that or something to do with proxies? anyways I had issues with the 'requests' library and urllib and urllib2. Spent ages trying to figure out why but that resovled it. see at the bottom of the app...
```
app.run(threaded=True)
```
##YOU WILL NEED TO CONFIG STUFF DEPENDING ON PLATFORM
http://stackoverflow.com/questions/8915296/python-image-library-fails-with-message-decoder-jpeg-not-available-pil