Skip to main content

Image processing plugin built for Django

Project description

PyPi_Version PyPi_Status Format python_versions django_versions License

Django ImageIt is a simple image handling plugin for Django that allows for scaling, upscaling and cropping of raster images. Imageit also has the capability to accept svg files if required.

Key features

  • Preview current image and new image selected for upload.

  • Scale images to fit the bounds of max_width and max_height.

  • Crop images to user defined dimensions before being scaled.

  • Option to upscale smaller images.

  • Utilises cropper.js.

  • Accepts .svg images.

  • Django Admin support.

Documentation

https://django-imageit.readthedocs.io/en/latest/

Usage

  • Install django-imageit using pip
    pip install django-imageit
  • Add ‘imageit to INSTALLED_APPS in your settings.py
    INSTALLED_APPS = [
        ...
        'imageit',
        ...
    ]
  • Import Imageit model fields to use them in your models.
    from imageit.models import ScaleItImageField, CropItImageField
    
    class ImageItModel(models.Model):
        scale_image = ScaleItImageField(max_width=100, max_height=100, quality=100, null=True, blank=True)
        crop_image = ScaleItImageField(max_width=1000, max_height=1000, quality=100, null=True, blank=True)
  • Available Imageit field KWARGS
    • max_width (int): Image will be scaled to the bounds of max_width in pixels (while retaining aspect ratio)

    • max_height (int): Image will be scaled to the bounds of max_height in pixels (while retaining aspect ratio)

    • quality (int): Quality in dpi of resampled images

    • max_save_size (int): Max size (mb) permitted for images after scaling/ resampling

    • upscale (bool): Upscale images to the value of max_width/max_height?

Options

Imageit provides many options to tailor functionality specifically for your use case. While specific dimensions for scaling can be set as arguments on a field-by-field basis, Imageit also allows for project wide defaults to be set if no value is provided at the field level.

Imageit will default to 100dpi quality at maximum dimensions of 1000x1000, If you wish to use your own custom defaults, you can do so in your settings.py as follows.

Settings overrides .. code-block:: python

IMAGEIT_MAX_UPLOAD_SIZE_MB = 5 IMAGEIT_MAX_SAVE_SIZE_MB = 5 IMAGEIT_DEFAULT_IMAGE_PROPS = {“max_width”: 1000, “max_height”: 1000, “quality”: 100, “upscale”: False} IMAGEIT_ACCEPTED_CONTENT_TYPES = ‘image/jpeg’, ‘image/png’, ‘image/svg+xml’ IMAGEIT_SVG_CONTENT_TYPE = ‘image/svg+xml’

  • IMAGEIT_MAX_UPLOAD_SIZE_MB is provided in MB, and is validated on the client side as well as on the server before cropping/scaling.

  • IMAGEIT_MAX_SAVE_SIZE_MB is provided in MB, and is validated on the server after and scaling/cropping/resampling is completed.

  • IMAGEIT_DEFAULT_IMAGE_PROPS Default properties used to scale/resample images

  • IMAGEIT_ACCEPTED_CONTENT_TYPES Content types accepted by imageit. (File mimes are validated by 3rd party FileTypes package)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-imageit-0.0.6.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

django_imageit-0.0.6-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file django-imageit-0.0.6.tar.gz.

File metadata

  • Download URL: django-imageit-0.0.6.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for django-imageit-0.0.6.tar.gz
Algorithm Hash digest
SHA256 ef9c9efa5c57ec38b86553fa269c60f59db03572fa739cb5ca3f4270abb5f712
MD5 2ec2400826f6662b09d97e46fce66b9b
BLAKE2b-256 1932f1b3c722bc6ceb790d37bb57f32c1fcf2211ec4e66c5ebb44f1d568cb079

See more details on using hashes here.

Provenance

File details

Details for the file django_imageit-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: django_imageit-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for django_imageit-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 14f157b87c571bd3955eb0bb82bc9efa2b2353ba43c1c8c18db68ccb455c943f
MD5 aec4a690502e3da3cf6bd3573e5029b6
BLAKE2b-256 c1e76761886e0c1cf6121cfda7b79ddb2536532d96a22dbf43a91f6fe78c9e89

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page