You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def _get_image_entropy(self, image):
"""calculate the entropy of an image"""
hist = image.histogram()
hist_size = sum(hist)
print hist_size
hist = [float(h) / hist_size for h in hist]
return -sum([p * math.log(p, 2) for p in hist if p != 0])
print hist_size gives a zero in the console - hence the error. We need some sort of try/except on this calculation, but I'm not sure what the except should be!
The text was updated successfully, but these errors were encountered:
Should have said I'm using sorl-thumbnail==11.12.1b
I've also noticed that if I set the image larger I don't get this error. Narrowing it down, this gives the error:
{% thumbnail comment.user.profile.avatar_image "37x37" crop="smart" as im %}
...but one pixel bigger does not:
{% thumbnail comment.user.profile.avatar_image "38x38" crop="smart" as im %}
I presumably that's because when the image is very small the entropy distinction tends towards zero. Which suggests the entropy calc is being run on an already-reduced image? Surely the entropy cropper should be run on the full-size image to determine the "smartest" area - and then resized down to the desired size?
I'm getting a
float division by zero
error here:I'm calling it using:
This happens on some images and not others. The image that's causing me issues is this one:
https://www.dropbox.com/s/m5e79cvk53ujs7b/Chelsea_physic_garden.jpg?dl=0
From a brief bit of digging the code is:
print hist_size
gives a zero in the console - hence the error. We need some sort oftry
/except
on this calculation, but I'm not sure what theexcept
should be!The text was updated successfully, but these errors were encountered: