Skip to main content

(Python) utility which acts as a wrapper around the Linux CLI: convert

Project description

Quick Overview

Python wrapper around Linux CLI “convert” which works as an entrypoint around the Linux image processing ‘ImageMagick’.

Overview

pyimgconvert is a Python utility which acts as a wrapper around the magick convert Linux CLI program that is useful for convert input images to the desired format and saves them in an output directory specified by the user.

This utility requires you to pass an inputDir, inputFile, outputDir, outputFile, and all the other optional CLI arguments that the convert accepts as a string to the args argument of pyimgconvert.

Assumptions

This document assumes UNIX conventions and a bash shell. The script should work fine under Windows, but we have not actively tested on that platform – our dev envs are Linux Ubuntu and macOS.

Installation

Python module

One method of installing this script and all of its dependencies is by fetching it from PyPI.

pip3 install pyimgconvert

Docker container

We also offer a docker container of pyimgconvert as a ChRIS-conformant platform plugin here https://github.com/FNNDSC/pl-imageconvert – please consult that page for information on running the dockerized container. The containerized version exposes a similar CLI and functionality as this module.

How to Use

mgz2imgslices needs at a minimum the following required command line arguments:

  • -I | --inputDir <inputDir>: The input directory which contains the input image that is to be converted

  • -i | --inputFile <inputFile>: The input image file to convert.

  • -O| --outputDir <outputDir>: The output directory which will store the output image

  • -o | --outputFile <outputFile>: The output file name (with extension) to save the output image

  • Optional: -a | --args "ARGS: <otherArgs>": Pass all the other arguments that convert accepts to this argument using the double quotes.

Examples

First, let’s create a directory, say devel wherever you feel like it. We will place some test data in this directory to process with this plugin.

cd ~/
mkdir devel
cd devel
export DEVEL=$(pwd)
  • Make sure your current working directory is devel. At this juncture it should contain the image file that you want to convert.

  • Create an output directory named results in devel.

mkdir results && chmod 777 results

Example-1

pyimgconvert
    --inputDir ${DEVEL}/                \
    --inputFile image.jpg               \
    --outputDir ${DEVEL}/results/       \
    --outputFile image.png              \

Example-2

pyimgconvert
    --inputDir ${DEVEL}/                            \
    --inputFile image.jpg                           \
    --outputDir ${DEVEL}/results/                   \
    --outputFile image.png                          \
    --args "ARGS: -colorspace RGB    -resize 40% "
  • The output image will be stored in the results directory.

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

pyimgconvert-1.0.10.tar.gz (5.7 kB view details)

Uploaded Source

File details

Details for the file pyimgconvert-1.0.10.tar.gz.

File metadata

  • Download URL: pyimgconvert-1.0.10.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.5

File hashes

Hashes for pyimgconvert-1.0.10.tar.gz
Algorithm Hash digest
SHA256 961c3c948b189cc6df6b04973767d27863fa305caf2242e999de739546a2ae5a
MD5 ea421d78c04659e9634622f501f434e3
BLAKE2b-256 e542c935759d80308afc908c5910c4868769167054f99d916ea27629237bbadc

See more details on using hashes here.

Supported by

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