django-imagekit

Django model inheritance overriding a variable used in field attribute

拟墨画扇 提交于 2021-02-08 20:59:37
问题 I am trying to override some default values in a inherited Django model. I have a bunch of different image sizes for models I need and the fields needed are 90% the same. I have tried creating a base model to use and was going to add any additional fields needed to the child models. The problem I am having is that the images are only using the "default" values I have set and are not being overwritten in the child model. Is what I am trying to accomplish possible? Thanks! class ImageLink

Django Imagekit processing the original image

喜你入骨 提交于 2019-12-13 02:28:14
问题 With version 1.1 I don't understand how I can preprocess the original image (by JUST using imagekit) https://github.com/jdriscoll/django-imagekit/blob/develop/README.rst Having a model like this: class Photo(models.Model): original = models.ImageField(etcetera) thumbnail = ImageSpec(etcetera) How do I for instance resize the original image? This was possible in previous imagekits, however the documentation insinuates I need another modelfield? 回答1: You can use ProcessedImageField : from

Django ImageKit and PIL

冷暖自知 提交于 2019-12-11 18:02:36
问题 I am using django image and creating a custom processor. I want to find out the size in KB (or bytes) but unable to do so. The size attribute give the dimensions and not the size of the file. I am a newbie so have only been able to find attr of PIL to get more information about the image but none of the them actually give the file size in bytes. I have creating this processor for a ModelForm. Can you please help with this? I am adding the code written so far. It is more of a test code; import

Django-imagekit: how to reduce image quality with a preprocessor_spec?

南楼画角 提交于 2019-12-11 04:39:57
问题 I've created this simple model class, with a Preprocessor to reduce my photos'quality (the photos'extension is .JPG): from django.db import models from imagekit.models import ImageModel from imagekit.specs import ImageSpec from imagekit import processors class Preprocessor(ImageSpec): quality = 50 processors = [processors.Format] class Picture(ImageModel): image = models.ImageField(upload_to='pictures') class IKOptions: preprocessor_spec = Preprocessor The problem : pictures' quality are not

Resizing image on upload with django-imagekit

妖精的绣舞 提交于 2019-12-10 10:40:51
问题 I am using imagekit to handle custom size of uploaded images. While it works fine for creating custom size images with this, I'd like to use imagekit to resize the original image on upload. Is this possible? 回答1: follow the link above. Create processors as you like for original image (resize, enhance, etc). Look imagekit wiki for examples class ResizeOriginal(processors.Resize): width = 640 height = 480 Create your ImageSpec for this original image with those previously processors. Leave pre

Django ImageField default

给你一囗甜甜゛ 提交于 2019-12-10 02:47:54
问题 models.py: class UserProfile(models.Model): photo = models.ImageField(upload_to = get_upload_file_name, storage = OverwriteStorage(), default = os.path.join(settings.STATIC_ROOT,'images','generic_profile_photo.jpg'), height_field = 'photo_height', width_field = 'photo_width') photo_height = models.PositiveIntegerField(blank = True, default = 0) photo_width = models.PositiveIntegerField(blank = True, default = 0) views.py: def EditProfile(request): register_generator() source_file =

Resizing image on upload with django-imagekit

痴心易碎 提交于 2019-12-06 07:23:55
I am using imagekit to handle custom size of uploaded images. While it works fine for creating custom size images with this, I'd like to use imagekit to resize the original image on upload. Is this possible? follow the link above. Create processors as you like for original image (resize, enhance, etc). Look imagekit wiki for examples class ResizeOriginal(processors.Resize): width = 640 height = 480 Create your ImageSpec for this original image with those previously processors. Leave pre_cache as default (false) class Original(ImageSpec): processors = [ResizeOriginal] Add that ImageSpec to your