Skip to main content

Resize and Crop

Description

Resize and crop an image to fit the specified size.

Installation

pip install resize-and-crop

or

pipenv install resize-and-crop

Methods

  1. resize_and_crop(path, size, crop_origin) - Resize the image located at path, into the size specified, cropping the image starting at the crop_origin.
  2. resized_image_file(image_field, format, dimensions, crop_origin) - Returns a new image file that has the resized image. Can be used to save to a Django ImageField.

Usage

from resize_and_crop import resize_and_crop

image = resize_and_crop("/path/to/image", (200,200), "middle")
from django.db import models
from resize_and_crop.utils import resized_image_file

class ExampleModel(models.Model):
	image = models.ImageField(upload_to="images/")
	thumbnail = models.ImageField(upload_to="thumbnails/")

	def save(self, *args, **kwargs):
		if self.image and not self.thumbnail:
			self.thumbnail = resized_image_file(
				self.image,
				"jpeg",
				(200, 200),
			)
		return super().save(*args, **kwargs)

Metadata

Release files for resize-and-crop 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for resize-and-crop 0.1.1
File Size Uploaded Provenance Actions
resize_and_crop-0.1.1.tar.gz 6.8 kB Without provenance Details for resize_and_crop-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for resize-and-crop 0.1.1
File Interpreter ABI Platform Actions
resize_and_crop-0.1.1-py3-none-any.whl Python 3 none any Details for resize_and_crop-0.1.1-py3-none-any.whl

Total release size: 10.5 kB

Release files / resize_and_crop-0.1.1.tar.gz

Download URL resize_and_crop-0.1.1.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1335fc571d79bf15196cf2149152f6fbdadd97a400ba849d3ffa183926a18cc6
BLAKE2b-256 checksum
How to use checksums
41bd35bddd185197d7e4666c4263424532326a4eaaa9b3d267f2169573b4b535
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

Release files / resize_and_crop-0.1.1-py3-none-any.whl

Download URL resize_and_crop-0.1.1-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1f29aa8a8e3c600a4fa6049d9270d0c9362dc931f0805875d1137f448073094
BLAKE2b-256 checksum
How to use checksums
75863a32a1d82df507b4f9357fc46bd4eb87b17f8b0c50e54ce12bbbd77365b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

Security for resize-and-crop 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page