#11158: get_image_dimensions very slow after 1 call -------------------------------------+-------------------------------------- Reporter: kua | Owner: nobody Status: new | Milestone: 1.1 Component: Core framework | Version: SVN Resolution: | Keywords: get_image_dimensions, field, save, slow Stage: Accepted | Has_patch: 1 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 1 | -------------------------------------+-------------------------------------- Changes (by rvanlaar):
* milestone: => 1.1 Comment: I wrote a testcase for it, but I don't know how to generate a image with PIL. Putting a 40 MB file in the svn wouldn't be a good a idea. {{{ from time import time from django.core.files.images import get_image_dimensions from django.core.files.uploadedfile import File f = File(open('/tmp/some_multi_megabyte_file.jpg') t1 = time() get_image_dimensions(f) t2 = time() run1_time = t2 - t1 t3 = time() get_image_dimensions(f) t4 = time() run2_time = t4 - t3 # The second run time should be in the same order of the first run. # So we check if the second runtime is not more then one order of # magnitude off. assert(run2_time < 10 * run1_time) }}} A quick solution is using: {{{ get_image_dimensions(f.name) }}} A better way to fix this is having an exposed classfunction to call get_image_dimensions, since django.core.files.image.!ImageFile already has a self._dimensions_cache. -- Ticket URL: <http://code.djangoproject.com/ticket/11158#comment:8> 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 django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---