Skip to main content

Create different scaled versions of an image, in webp, jpg, png, svg,... to be used on resposive website

Project description

Pytest

Pypi version Pypi Download

Introduction

responsiveimage is a python package aimed at building responsive version of images.

Supported image format are webp, jpg, png, gif and svg.



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 ffmpeg to scale at 1024
python -m responsiveimage --src-dir <srcdir> --dst-dir <dstdir>
  • --export-to-webp: also export the webp version 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 --size and --height cannot 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, in name1 , name2. Note that the numbers of sizes or heights must be the same as the one of add-name if provided

    As an example, using --size 1024,512 --add-name _big,_small, an image img.jpg will be rescaled with 1024px and named img_big_.jpg, and another one rescaled at 512px and named img_small_.jpg

  • --mp4-as-gif: from a mp4 file, the gif and the webp animated versions are created, using ffmpeg

  • --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.

  • --force: recreate the scaled versions of the images, even when they exist.



Releases

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


Download files

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

Source Distribution

responsiveimage-1.1.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

responsiveimage-1.1.1-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file responsiveimage-1.1.1.tar.gz.

File metadata

  • Download URL: responsiveimage-1.1.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for responsiveimage-1.1.1.tar.gz
Algorithm Hash digest
SHA256 4e3dc7bb3ae2dd0906af8580644b386203a79d0227efbe7f95904d2b2a3e528e
MD5 54e32c0148eac914a6491a81e63a35e7
BLAKE2b-256 722b6dd175924f65bac050f8a88bfed097260a4087a6858e85bc3c8ee7d0a342

See more details on using hashes here.

File details

Details for the file responsiveimage-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for responsiveimage-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0c2899e6240e99d3bec4c6ea948a9df3dc48a5307d02e833ab90dc5d9aa58ca8
MD5 99633bd2da30d44ae64ba19a6c3ea8be
BLAKE2b-256 55267e2ff10549dc551df04c0afdf996e050920a2d24dc0a6ac367d618497686

See more details on using hashes here.

Supported by

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