No, everything is fine. Once you uploaded a file, you can call
image.width and image.height (where image is an instance of Image).
If you are using ModelForms, you can set editable=False as a parameter
for width and height.

image           = models.ImageField(upload_to='images',
height_field='height', width_field='width')
height     = models.PositiveSmallIntegerField(editable=False)
width      = models.PositiveSmallIntegerField(editable=False)



On Aug 27, 3:31 am, TheIvIaxx <theivi...@gmail.com> wrote:
> Assume i have the following:
>
> class Image(models.Model):
>     image = models.ImageField(upload_to="path/to",
> width_field="width", height_field="height"
>
> do i create new Integer fields there for width and height?  With this
> i can do things like:
>
> >>> Image.objects.get(pk=1).image.width
>
> However this is just opening the file with PIL which is slow.  The
> documentation suggestions the width/height will be updated upon save,
> thus being quick :)
>
> class Image(models.Model):
>     image = models.ImageField(upload_to="path/to",
> width_field="width", height_field="height"
>     width = models.IntegerField()
>     height = models.IntegerField()
>
> did not seem to do anything.  Am i missing something?
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to