matthewwithanm / django-imagekit

Automated image processing for Django. Currently v4.0
http://django-imagekit.rtfd.org/
BSD 3-Clause "New" or "Revised" License
2.26k stars 276 forks source link

what can cause ImageSpecField to have different image than the source? #446

Open jomopeh opened 6 years ago

jomopeh commented 6 years ago

I'm using ImageSpecField on a model like so:

    image = models.ImageField(upload_to='images')
    image_thumbnail = ImageSpecField(source='image', processors=[ResizeToFill(100, 100)], format='JPEG', options={'quality': 60})
    image_medium = ImageSpecField(source='image', processors=[ResizeToFill(400, 400)], format='JPEG', options={'quality': 60})

I noticed that one of the image instance I have saved, contains a different image for the image_thumbnail and image_medium, than the image field.

But all other times (99%) uploads remain consistent and the image_thumbnail and image_medium reflect the source image field.

Could this be a problem with the image name that is being passed when the image is uploaded, causing name conflict? Or a bug with ImageSpecField? I'm currently on django-imagekit==4.0.1

Thanks

vstoykov commented 6 years ago

This is very strange.

Did you make anything strange with the source (not normal model form) or something? Did you changed IMAGEKIT_SPEC_CACHEFILE_NAMER and/or IMAGEKIT_CACHEFILE_NAMER?

jomopeh commented 6 years ago

Hi vstoykov,

I have not modified those settings. I could not find what the problem was. What I can say is that I use django storages (S3) alongside. Whether it's an incompatibility, or s3 storage settings causing the issue, I cannot say.

I suspect it was caused some duplicate name conflict or perhaps ImageSpecField lost reference to the file. After lots of debugging, it looks like it was using the first image that was ever saved, weird.

Either way, unfortunately I have moved away from image-kit for this use case as I had limited time to continue debugging.

After upgrading the relevant packages and reconfiguring django storages, all is well now alongside S3.

Thank you