from django.db import models
from imagekit.models import ImageSpecField
from imagekit.processors import ResizeToFit, SmartResize, Transpose


class Image(models.Model):
    file = models.ImageField('Datei')
    creator = models.ForeignKey(
            'gestalten.Gestalt', related_name='images', on_delete=models.PROTECT)

    preview_api = ImageSpecField(
            source='file', processors=[Transpose(), SmartResize(250, 250)], format='PNG')
    preview_content = ImageSpecField(
            source='file', processors=[Transpose(), SmartResize(200, 200)], format='PNG')
    preview_gallery = ImageSpecField(
            source='file', processors=[Transpose(), ResizeToFit(250)], format='PNG')
    preview_group = ImageSpecField(
            source='file', processors=[Transpose(), SmartResize(366, 120)], format='PNG')
    intro = ImageSpecField(
            source='file', processors=[Transpose(), ResizeToFit(554)], format='JPEG')
    sidebar = ImageSpecField(
            source='file', processors=[Transpose(), ResizeToFit(313)], format='JPEG')
    facebook_meta = ImageSpecField(
            source='file', processors=[Transpose(), ResizeToFit(800)])
    twitter_meta = ImageSpecField(
            source='file', processors=[Transpose(), SmartResize(600, 300)])

    def __str__(self):
        return '{} ({})'.format(self.file, self.creator)[2:]

@@ -420,38 +420,24 @@
 e(250, 250)%5D
-, format='PNG'
 )%0A    previe
@@ -538,30 +538,16 @@
 0, 200)%5D
-, format='PNG'
 )%0A    pr
@@ -647,30 +647,16 @@
 it(250)%5D
-, format='PNG'
 )%0A    pr
@@ -763,22 +763,8 @@
 20)%5D
-, format='PNG'
 )%0A  
@@ -858,31 +858,16 @@
 it(554)%5D
-, format='JPEG'
 )%0A    si
@@ -963,23 +963,8 @@
 13)%5D
-, format='JPEG'
 )%0A  

disable forced format conversions for images