matthewwithanm / pilkit

Utilities and processors built for, and on top of PIL
BSD 3-Clause "New" or "Revised" License
196 stars 54 forks source link

passing spec to ProcessedImageField #23

Closed jerzyk closed 8 years ago

jerzyk commented 8 years ago

I have separate definitions for the image spec:

class BrowseImageSpec(ImageSpec):
    processors = [
        processors.SmartResize(*settings.IMAGE_BROWSE_SIZE, upscale=True)
    ]
    format = 'JPEG'
    options = None
    autoconvert = True

and I want to use it as parameter for the ProcessedImageField:

    image = models.ImageField(_('Image'), upload_to=upload_path)
    thumb_index = ProcessedImageField(spec=BrowseImageSpec(source='image'))

which looks like a reasonable thing to do... but this fails:

TypeError: You can provide either an image spec or arguments for the ImageSpec constructor, but not both.