Beispiel #1
0
def pre_save_callback(sender, **kwargs):
    record = kwargs['instance']
    if record.image:
        max_width = 500
        if record.image.width > max_width or record.image.height > max_width:
            f = thumbnail(record.image.file, max_width, max_width)
            record.image.save(record.image.name, File(f))
Beispiel #2
0
def on_pre_save_post(sender, **kwargs):
    post = kwargs['instance']
    if post.photo:
        max_width = 300
        if post.photo.width > max_width or post.photo.height > max_width:
            processed_f = thumbnail(post.photo.file, max_width, max_width)
            post.photo.save(post.photo.name, File(processed_f), save=False)
 def on_pre_save(sender, **kwargs):
     post = kwargs["instance"]
     if post.image:
         max_width = 300
         if post.image.width > max_width or post.image.height > max_width:
             processed_file = thumbnail(post.image.file, max_width, max_width)
             # processed_file = square_image(post.image.file, max_width)
             post.image.save(post.image.name, File(processed_file))
Beispiel #4
0
def pre_on_post_save(sender, **kwargs):
    post = kwargs['instance']
    if post.image:
        max_width = 300
        if post.image.width > max_width or post.image.height > max_width:
            processed_file = thumbnail(post.image.file, max_width, max_width)
            # processed_file = square_image(post.image.file, max_width)
            post.image.save(post.image.name, File(processed_file))