My solution is:

def save( self ):
   if self.image1:
      original = Image.open( self.image1 )
      if original.mode not in ('L', 'RGB'):
         original = original.convert('RGB')

      cp_image = original.copy()

      cp_image_handle = StringIO()
      cp_image.save( cp_image_handle, 'JPEG', quality=100 )
      cp_image_handle.seek(0)

      cp_image_upload =
SimpleUploadedFile(os.path.split(self.image1.name)[-1],cp_image_handle.read(),
content_type='image/jpeg')

      self.image1.save( "changed_extension.jpg", cp_image_upload, save=False)

   super( MyModel , self ).save()




2011/4/15 ozgur yilmaz <yelb...@gmail.com>:
> Hi,
>
> I want to change the filetype of any uploaded image to JPG. What is
> the most efficient way for this? I think i surely do this before
> save(). Any ideas?
>
> 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