#11158: get_image_dimensions very slow after 1 call
-----------------------------------------------------+----------------------
 Reporter:  kua                                      |       Owner:  nobody    
   Status:  new                                      |   Milestone:            
Component:  Uncategorized                            |     Version:  1.0       
 Keywords:  get_image_dimensions, field, save, slow  |       Stage:  Unreviewed
Has_patch:  1                                        |  
-----------------------------------------------------+----------------------
 get_image_dimensions in django.core.files.images is very slow after 1 call

 This has the effect of slowing down calls to save on model image fields,
 the whole thing shudders to a halt while we spin around in PIL.Image.feed

 The issue is that the read pointer is not being reset after the call to
 get_image_dimensions. Subsequent calls to file.read

 To reproduce:


 from django.core.files.images import get_image_dimensions[[BR]]
 from django.core.files.uploadedfile import File[[BR]]

 f = File(open('/tmp/some_multi_megabyte_file.jpg')[[BR]]
 get_image_dimensions(f)[[BR]]
 get_image_dimensions(f)[[BR]]



 I suggest this function should save the read pointer pos, reset it to 0,
 then do all the PIL fancyness, then reset the pointer when finished. I've
 tried to attach a patch that reflects this

 Imagine this scenario: Someone mucks with the read pointer on a hundred
 meg image, say reads 2 kilobytes. Then this function is called and starts
 reading data in 1K chunks looking for a header (which has already been
 skipped).

 So 100 Megabytes - 2 kilobytes / 1024 bytes per read means this function
 will be called over 100,000 times

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11158>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to