Registry / devops / python-resize-image

python-resize-image

JSON →
library1.1.20pypypi✓ verified 86d ago

A small Python package to easily resize images. Supports multiple resizing strategies (crop, pad, thumbnail, etc.). Current version 1.1.20 runs on Python 3.6+.

pip install python-resize-image
INSTALL
IMPORT
SIG · PYTHON-RESIZE-IMAG
P
python-resize-image
devopspythonv1.1.20
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

resizeimage
from resizeimage import resizeimage
import resizeimage
resizeimage is a module, not a package. Use 'from resizeimage import resizeimage' to access the class.

Resize an image using the 'cover' method (crop to fill dimensions).

from PIL import Image from resizeimage import resizeimage with open('test.jpeg', 'r+b') as f: with Image.open(f) as image: cover = resizeimage.resize_cover(image, [200, 100]) cover.save('test-cover.jpeg', image.format)
Debug
Known issues
gotchaThe resizeimage module is case-sensitive. Import as `from resizeimage import resizeimage` (lowercase).
fix
Ensure correct import and module name casing.
affects: all
gotchaThe library expects file-like objects, not file paths. Always open files with open() before passing.
fix
Use `with open('image.jpg', 'r+b') as f: Image.open(f)` inside the block.
affects: all
gotchaJPEG images must be opened with mode 'r+b' (read-write binary) to avoid 'cannot write mode RGBA as JPEG' error when saving.
fix
Open JPEG files with 'r+b' mode and ensure image is converted to RGB before saving.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'resizeimage'
Incorrect import: `import resizeimage` instead of `from resizeimage import resizeimage`.
fix
Use `from resizeimage import resizeimage`.
OSError: cannot write mode RGBA as JPEG
JPEG does not support alpha channel. The image has an alpha channel, but the output format is JPEG.
fix
Convert image to RGB: `image = image.convert('RGB')` before saving.
AttributeError: module 'resizeimage' has no attribute 'resize_cover'
Trying to call resize_cover directly on the module instead of a class instance.
fix
First call `resizeimage.resize_cover(image, size)` or import the function: `from resizeimage.resizeimage import resize_cover`.
Upgrade
Version history
1.1.20latest on PyPI · released Nov 4, 2021
Audit
Dependencies
PillowrequiredRequired for image processing
Agent activity
2 hits · last 30 days
node
2
Resources
python-resize-image — pip install python-resize-image · libregistry