Comments (3)
@lettertwo just asked me about this so I thought I'd let everybody know my thoughts—and let you (@nishimu) know that I'm not ignoring you!
There is definitely a use-case for this; #11 is an example. Having said that, I'm not sure I'm a fan of allowing a processors
callable. The reason is that I can see a new issue being created in two months in which somebody says, "we should make the format
argument a callable." And quality
. Basically, the rationale for allowing processors
to be a callable would be the same for every other field—including ones that we may add in the future. Furthermore, in practice, the functions used for these values would have to repeat much of the same work—in other words, what determines which processors are used is also likely to determine the format. To have to execute the same code twice is gross.
I think the idea of a callable "processors" argument may be too narrow of a solution. What you (and @koebbe) want, in effect, is to define different specs based on properties of the model. I'm still trying to figure out if there's a way to do that that fits with how we're used to working with Django fields. Ultimately, the answer may just be to allow callables for all the arguments, but I want to see if we can't come up with something better first.
Anybody have any good ideas for alternatives here? Or examples of Django libraries with fields that change behavior based on model properties?
from django-imagekit.
How about making it posible to define the ImageSpec inside the init of the model after the super init?
from django-imagekit.
Sorry for dragging my feet on this one.
@jokerejoker Unfortunately, model fields don't really work like that. In the case of ImageSpec, we could probably get it to work, but I think the result would be without precedent and tie our hands in the future if we need to do more bookkeeping in the contribute_to_class
method.
Ultimately, I think that the best option we have (or at least the best one we've been able to come up with!) is to allow callables to be used for the processors argument. And, lucky for us, @cyberdelia has done that work for us in #85! I've pulled his changes into develop with commit 3bac472.
@nishimu Sorry again for dragging my feet so long on this solution (only to finally settle on what you suggested initially). I still have my original objections but the perfect is the enemy of the good, and we've gone long enough without a solution.
from django-imagekit.
Related Issues (20)
- Generate images in postsave HOT 2
- generateimages does not replace original image? HOT 1
- I have a problem displaying images on my server from the cache of the imagekit. Do you have any idea how can i fix it ? Im using apache2 HOT 1
- How to delete orphans? HOT 1
- WEBP GIF's not working
- !
- Accept `cachefile_storage` as callable
- where is the processed image saved? I only see the original
- Is django-imagekit dead? HOT 3
- How to preserve exif data with ProcessedImageField HOT 1
- Using ResizeToFill and ResizeToFit changes colors of JPEG HOT 2
- New release? HOT 4
- Pillow deprecating ANTIALIAS HOT 5
- Pillow sometimes throw an error with ANTIALIASING HOT 5
- Slow page rendering when using S3 HOT 3
- 'PIL.Image' has no attribute 'ANTIALIAS' HOT 1
- Integration with django-parler package HOT 6
- Trouble using S3 for Originals and Local Storage for Thumbnails HOT 1
- Readme about this image tool does not contain images HOT 1
- Feature Request: Make it possible to specify the format for the thumbnail template tag
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-imagekit.