在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:xarg/django-stdimage开源软件地址:https://github.com/xarg/django-stdimage开源编程语言:Python 100.0%开源软件介绍:Note: This repo si no longer maintained. Please use this one: https://github.com/codingjoe/django-stdimage Django Standarized Image FieldDjango Field that implement those features:
Installation
UsageImport it in your project, and use in your models. Example: [...] from stdimage import StdImageField class MyClass(models.Model): image1 = StdImageField(upload_to='path/to/img') # works as ImageField image2 = StdImageField(upload_to='path/to/img', blank=True) # can be deleted throwgh admin image3 = StdImageField(upload_to='path/to/img', variations={'thumbnail': (100, 75)}) # creates a thumbnail resized to maximum size to fit a 100x75 area image4 = StdImageField(upload_to='path/to/img', variations={'thumbnail': (100, 100, True}) # creates a thumbnail resized to 100x100 croping if necessary image_all = StdImageField(upload_to='path/to/img', blank=True, variations={'large': (640, 480), 'thumbnail': (100, 100, True)}) # all previous features in one declaration For using generated thumbnail in templates use "myimagefield.thumbnail". Example: [...] <a href="{{ object.myimage.url }}"><img alt="" src="{{ object.myimage.thumbnail.url }}"/></a> [...] About image namesStdImageField stores images in filesystem modifying its name. Renamed name is set using field name, and object primary key. Also it changes old windows "jpg" extesions to standard "jpeg". Using image_all field previously defined (that creates a thumbnail), if an image called myimage.jpg is uploaded, then resulting images on filesystem would be (supose that this image belongs to a model with pk 14): image_all_14.jpeg image_all_14.large.jpeg image_all_14.thumbnail.jpeg |
2022-08-15
2022-08-17
2022-09-23
2023-10-27
2022-08-18
请发表评论