Skip to main content

使用 Python 轻松处理图像:更改亮度、对比度、锐度、调整大小

项目描述

枕套

使用 Python 批量处理图像:更改亮度、对比度、清晰度、调整大小、压缩、裁剪和转换(例如 png 到 jpg)。使用枕头的简单脚本(包装器)。许可条件:GNU 通用公共许可证 v3 或更高版本 (GPLv3+) 对于 Gui 选项 checkout 分支 'gui'

要求

python >= 3.5,枕头

安装

最简单的选择是使用 sudo 安装 pip。

sudo python3 -m pip install pillowcover --upgrade

--OR-- 以没有 sudo 的用户身份安装。这会将其安装在 ~/.local/bin/ 中,确保此路径在您的 $PATH 中。

python3 -m pip install --user pillowcover --upgrade

如果未找到,请将以下内容添加到您的 .bashrc 或 .zshrc

# Add to PATH to Install and run programs with "pip install --user"
export PATH=$PATH:~/.local/bin

用法

将亮度、对比度、锐度提高 20% 并将所有图像(横向、纵向)的大小调整为 1920 像素的最大尺寸(使用最大尺寸。高度或宽度)并在给定文件夹中将它们压缩到 60%,同时保持相同的纵横比.

pillowcover -d /home/user/Pictures/ -b 1.20 -c 1.20 -s 1.20 -r 1920 -q 60

裁剪(从左上角 640*480)和转换(从 png 到 jpg)文件夹中的所有图像。

plc -d /home/user/Pictures/ -k "0,0,640,480" -x jpg

使用选项

usage: plc [-h] [-v] [-i IMAGE_FILE] [-d IMAGE_DIR] [-o OUTPUT_DIR]
           [-b BRIGHTNESS] [-c CONTRAST] [-s SHARPNESS] [-r RESIZE]
           [-R RESIZE_RATIO] [-k CROP] [-q COMPRESSION] [-x EXTENSION]

PillowCover: Mass Manipulate Images Using Python: Change Brightness, Contrast,
Sharpness, Resize, Compress, Crop and Convert. A simple script (wrapper) using
pillow. Licensed Under: GNU General Public License v3 or later (GPLv3+)

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program\'s version number and exit
  -i IMAGE_FILE, --img IMAGE_FILE
                        Path to the image file to edit
  -d IMAGE_DIR, --dir IMAGE_DIR
                        Path to the directory containing the image files
  -o OUTPUT_DIR, --out-dir OUTPUT_DIR
                        Path to output directory to store edited images. by
                        default they get stored in (parent
                        director)/pillowcover-output
  -b BRIGHTNESS, --brightness BRIGHTNESS
                        Change brightness level, 1.00 is the current value
  -c CONTRAST, --contrast CONTRAST
                        Change contrast level, 1.00 is the current value
  -s SHARPNESS, --sharpness SHARPNESS
                        Change sharpness level, 1.00 is the current value
  -r RESIZE, --resize RESIZE
                        Resize img, keep ratio. provide the maximum
                        length/width value as one number. e.g pillowcase.py
                        img -r 1920
  -R RESIZE_RATIO, --resize-ratio RESIZE_RATIO
                        Resize img by providing new width and length e.g
                        pillowcase.py img -R "640 480"
  -k CROP, --crop CROP  Crop img by providing starting point then width and
                        length from it e.g pillowcase.py img -k "0,0,640,480"
  -q COMPRESSION, --compression-quality COMPRESSION
                        Compression quality 1-100, 100 means no compression at
                        all
  -x EXTENSION, --extension EXTENSION
                        Specifiy the output extension. Can be 'jpg', 'jpeg',
                        'png' Default is same as the input file's. e.g
                        pillowcase.py -d imgdir -x "jpg"

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

枕套-1.2.1.tar.gz (5.2 kB 查看哈希)

已上传 source