Created
October 24, 2021 21:05
-
-
Save Mossman1215/79fc0b8163e4bc2eef0a0942326f3133 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#requires pyvips and ruby-image-processing on ubuntu | |
import pyvips | |
import argparse | |
import pathlib | |
parser = argparse.ArgumentParser(description='resize images ') | |
parser.add_argument('images', metavar='file', nargs='+', | |
help='paths to files to shrink') | |
args = parser.parse_args() | |
for filepath in args.images: | |
image = pyvips.Image.new_from_file(filepath, access='sequential') | |
image = image.colourspace('srgb') | |
image = image.resize( 0.5 ) | |
source_path = pathlib.Path(filepath) | |
new_name = source_path.parent.joinpath(source_path.name.replace(source_path.suffix,'')+'_smol'+source_path.suffix).as_posix() | |
image.write_to_file(new_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment