Comments (2)
Pillow (an existing dependency) supports detecting image types by opening the image and looking at the format
property: https://pillow.readthedocs.io/en/latest/reference/Image.html#PIL.Image.Image.format
Both places in the code where this functionality is used (that I could find), the purpose is to generate a random filename with an extension that matches the encoding of the image:
bookwyrm/bookwyrm/views/books/books.py
Lines 156 to 162 in 9e7b040
bookwyrm/bookwyrm/models/fields.py
Lines 505 to 510 in 9e7b040
Using Pillow this way would parse the entire image instead of just the header, so that makes it less efficient.
from bookwyrm.
PEP 594 was updated to include recommendations to replace imghdr
.
puremagic
looks like it should be a suitable replacement.
get_image
already reads the entire file, so overhead compared to imghdr
should be minimal (puremagic
may try to examine a few more kilobytes than imghdr
's 32).
from bookwyrm.
Related Issues (20)
- Adding email domain to the block list doesn't affect invite requests HOT 3
- LubimyCzytac - polish GoodReads alternative - as a source for books
- "Your books" links are broken when using a subdomain HOT 3
- External Link Modal confirmation window HOT 2
- Account export times out when trying to generate export json HOT 7
- I would like the max upload size to be configurable HOT 1
- Test for inefficient queries HOT 1
- Potential error or missing explanation in nginx production config? HOT 1
- Merged book code is creating long-running queries HOT 1
- Account import fails with error: 'attributedTo' HOT 3
- Wrong CSS paths with S3 object storage (while non-CSS assets paths are correct) HOT 7
- Switch to an OSI-approved license HOT 2
- "Most Loved" Doesn't Dedupe by User
- Send e-mail on group invitation
- Trim leading and trailing spaces in search HOT 1
- Clarification about nginx configuration introduced at 0.7.2 HOT 7
- ModuleNotFoundError: No module named 'oauth2_provider' HOT 4
- Dates wrong when importing from storygraph
- Feature Request: Show Ratings/Reviews completed in left-side book carousel
- Start date blank when finishing a book HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bookwyrm.