Comments (11)
Hey @Bartvds !
That's a super-fantastic idea! I've been less-than-thrilled with how long file names can get and a hashing function would be the ideal way to do it for sure.
I'm adding this to the roadmap right now...thanks for the suggestion!!
Otherwise, how's the app been performing for you?
from django-versatileimagefield.
+1
I recommend using file's md5 hash to make their's filename.
from django-versatileimagefield.
@respondcreate Sorry for my late reply. DVIF app works very well for us, thanks for publishing it.
@mrgaolei A combination of these would be nice: a hash of the content of the original image as a filename, and a hash of the DVIF options as postfix. This would also cut-down duplication of re-uploaded images (our content people occasionally re-use same image files in different fields).
Ideally encode the hash as base32 to trim down the length compared to base16 (hex). We use the lowercase crockford base32 alphabet for nice friendly hashes.
Not sure how far this should be implemented. Maybe if there is too much choices some optional callbacks to process the names would work best (with a sane default of course).
from django-versatileimagefield.
Hey @Bartvds –
I'm going to tackle this feature this weekend, would you mind linking me to a gist (or commit or whatever) with an example function that accepts a string and spits out a 'lowercase crockford base32' string trimmed to a base16 hex length? I already know where in the code the custom hashing functions should be injected so having an example off which to base the first function would go a long way to having this happen sooner rather than later.
Thanks in advance!
from django-versatileimagefield.
Any news about this feature?
I think that also quality should be included in the image_key
+1
from django-versatileimagefield.
Check my PR
from django-versatileimagefield.
Thanks for your PR @fabiocaccamo , I'm working on integrating it right now. Stay tuned!
from django-versatileimagefield.
@respondcreate I think the hashing callback could be a simple string->string function. DVIF loads it from dotted path (django import_utils) and calls it with the regular long name and it returns a replacement string.
I would hash the unicode string to bytes with sha1 or maybe even md5 and put those through a nice looking encoder. Possibly trim it before or after (not sure if good idea), maybe strip() the fill character ('=' usually).
Base16 (ye olde hexdigest()), base32 (possibly with crockfords characters) and base58 all give decent looking utf characters for the hash bytes. I would lowercase base16 and base32 for cosmetics effect.
from django-versatileimagefield.
Hey @Bartvds, @mrgaolei and @fabiocaccamo –
This feature has been added in the 1.4 release by way of the new VERSATILEIMAGEFIELD_SETTINGS['image_key_post_processor']
setting. Just upgrade via pip to start using it:
$ pip install django-versatileimagefield==1.4
NOTE: The 1.4 release dropped support for Django 1.5.x and 1.6.x
from django-versatileimagefield.
@respondcreate Thanks. We've been running this in production for a few days and it works great so far.
from django-versatileimagefield.
@Bartvds Glad it's working out well! Don't hesitate to file a ticket if you run into anything strange.
from django-versatileimagefield.
Related Issues (20)
- Unclear docs on using VersatileImageFieldWarmer with rendition sets HOT 1
- python-magic 0.4.20 incompatible
- Fails to work with django-cacheops HOT 2
- How to store filename returned by storage for sized images? HOT 1
- Test with Python3.9
- Test with Django 3.1 and 3.2
- Add Django 3.2 Compatibility HOT 1
- Test with djangorestframework 3.11 and 3.12
- error to upload images using django-rest and angular HOT 1
- versatileimagefield How to use Django Graphql
- Deleting all created images for the image without extension fails
- VersatileImageFieldWarmer regenerate images for delete rendition key set
- Question: is it possible to use this app with static files?
- AttributeError: module 'magic' has no attribute 'from_buffer' HOT 1
- Django 4 HOT 3
- Question: Crop as circle
- Extra queries when warming with VersatileImageFieldWarmer
- django-versatileimagefield doesn't work on Pillow >= 10.0.0 released 1 July HOT 5
- Created images not deleted when using image_key_post_processor
- Configurable exception handling
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 django-versatileimagefield.