We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to find out the dominant color of the image and store it in a field. This should happen in the save method.
save
I'm using a little version of this method: https://stackoverflow.com/a/34964548/9878135
class Model(models.Model): image = models.ImageField( storage=OverwriteStorage(), upload_to=image_path "_org/", default=settings.DEFAULT_IMAGE_PATH, blank=True, ) def save(self, *args, **kwargs): self.create_dominant_color() super().save(*args, **kwargs) def create_dominant_color(self): self.dominant_color = get_dominant_color(self.image)
This is my get_dominant_color:
get_dominant_color
def get_dominant_color(image_file): im = Image.new(image.mode, image.size) # just added one line
When I try to call image.mode I get this error: 'ImageCacheFile' object has no attribute 'mode'.
image.mode
'ImageCacheFile' object has no attribute 'mode'
Would be nice if you could add the mode to the ImageCacheFile class.
ImageCacheFile
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I want to find out the dominant color of the image and store it in a field.
This should happen in the
save
method.I'm using a little version of this method: https://stackoverflow.com/a/34964548/9878135
This is my
get_dominant_color
:When I try to call
image.mode
I get this error:'ImageCacheFile' object has no attribute 'mode'
.Would be nice if you could add the mode to the
ImageCacheFile
class.The text was updated successfully, but these errors were encountered: