Create different scaled versions of an image, in webp, jpg, png, svg,... to be used on responsive website
Project description
Introduction
responsiveimage is a python package aimed at building responsive version of images.
Supported formats are:
- image: webp, jpg, png, gif and svg
- video: mp4, mts, avi, wmv, mov
Usage
Installation
Run python -m pip install responsiveimage to install the python package.
Also, please install the binaries ffmpeg and optipng
(using apt-get, pacman, or directly from
sourceforge)
to further optimize the png version of the sprite.
Usage
- resize and save all images in
<srcdir>into<dstdir>. New size is 1920px by default (at largest dimension, keep the aspect-ratio), and save quality is:- gif and svg: direct copy
- png: use Pillow library, with Optimize=True
- jpg: quality=80, progressive, 4:2:2
- webp: quality=80
- mp4: use
ffmpegto scale at 1024
python -m responsiveimage --src-dir <srcdir> --dst-dir <dstdir>
-
--export-to-webp: also export thewebpversion of the image -
--size <s1,s2...>: different scaling are generating, instead of the default 1920px. The max size will be s1, s2... -
--height <s1,s2...>: different scaling are generating, based on the height which will be be s1, s2... Note that--sizeand--heightcannot be used at the same time. -
By default, the name of the created responsive versions of the image are
- unchanged if there is a single scaled version of the image
- or suffixed with
-s1,-s2... otherwise.
Option
--add-name <name1,name2...>is used to modify the suffix, inname1,name2. Note that the numbers of sizes or heights must be the same as the one of add-name if providedAs an example, using
--size 1024,512 --add-name _big,_small, an imageimg.jpgwill be rescaled with 1024px and namedimg_big.jpg, and another one rescaled at 512px and namedimg_small.jpg -
--mp4-as-gif: from a mp4 file, the gif and the webp animated versions are created, usingffmpeg -
--crop <x1,y1,x2,y2>crops the original image using(x1,y1)as the top-left point (x being the horizontal position in px), and(x2,y2)being the bottom-right point. -
--recursiveto scan recursively the source directory. The directory tree is kept in destination -
--format <f1,f2>to used to only process files of provided format. You can for example process only jpg and png to exclude videos. The default value isjpg,png,webp,gif,svg,mp4,mts,avi,wmv,mov -
--force: recreate the scaled versions of the images, even when they exist.
Releases
1.4.0
- animated gif and webp uses --size option
1.3.0
- Multiprocessing on images
1.2.0
- Supported formats: webp, jpg, png, gif and svg, mp4, mts, avi, wmv, mov
- New options:
- --format
- --recursive
1.1.1
- Fix mp4: no upscale, along max size.
- Fix HEIC format
1.1.0
Following capabilities are added:
--height--add-name--crop--force
1.0.0
Initial version
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file responsiveimage-1.4.1.tar.gz.
File metadata
- Download URL: responsiveimage-1.4.1.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a081c0897da578c9198b3f101daac9772b121f5a9be7c8050d97db30fff9591c
|
|
| MD5 |
a8270e8299c4f3874fcdfcf7ddb395e9
|
|
| BLAKE2b-256 |
726a4f11993f47826254091dd02cc865dd00c4d368987ebe365dcad4d1245efa
|
File details
Details for the file responsiveimage-1.4.1-py3-none-any.whl.
File metadata
- Download URL: responsiveimage-1.4.1-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcb9711f10b588fd1da3390e253a4e2c359e6e018e22bb43d448158872c319d8
|
|
| MD5 |
ba62aecb09cba128895ebd2dfc7110e0
|
|
| BLAKE2b-256 |
a5d6716092b65aa015a71188990e97815c3f295049458c506985bd3accfb824d
|