Here's a comprehensive README.md for your GitHub repository:
A Python script for batch processing video files with HDR metadata injection and LUT embedding for professional video workflows.
# Clone repository
git clone https://github.com/yourusername/hdr-injector.git
cd hdr-injector
# Install requirements (no external dependencies needed)
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
# Automatic mode: Process all videos in current directory and subdirectories
python addhdr.py
# Process single file with LUT embedding
python addhdr.py input.mkv
# Process directory and subdirectories
python addhdr.py /path/to/videos/
# Wildcard pattern matching
python addhdr.py *.mkv
# Without LUT embedding
python addhdr.py --no-lut input.mkv
# Custom output directory
python addhdr.py -o /custom/output/path input.mkv
# Custom mkvmerge path
python addhdr.py --mkvmerge-path "/usr/local/bin/mkvmerge" input.mkv
⚠️ Note: Always back up original files before processing
NBCU Technical LUT for PQ→SDR conversion (included in Resolve installations)
Q: mkvmerge not found
A: Install MKVToolNix and verify it's in your system PATH
Q: LUT file not found
A: Use --lut /custom/path/to/lut.cube or disable with --no-lut
Q: Permission denied errors
A: Run with elevated privileges or check file/directory permissions
Q: Output directory not created
A: Verify valid path and write permissions on target drive
This Python script uses the Google Gen AI Python SDK to extract and clean up text from image files. It dynamically determines the MIME type of each input file, allowing you to process any image file type (e.g., JPEG, PNG, WebP). The script also retrieves a list of available models from the API, prompts you to select one interactively, and processes the images in natural numerical order.
Dynamic Image Support:
Automatically detects the MIME type for any image file based on its extension.
Interactive Model Selection:
Lists available models from the API and prompts you to choose one by entering its corresponding number.
Natural File Sorting:
Uses natural sorting to process files in human-friendly numerical order (e.g., 2.webp comes before 10.webp).
Transcription & Cleanup:
Extracts text from images using OCR-like functionality, cleans up formatting (removes extra line breaks and spaces), and outputs well-structured text.
Output File Saving:
Saves the cleaned transcription to a text file (with a _transcription.txt suffix) for each processed image.
Run the script with one or more file patterns as arguments. For example:
python transcribeimage.py *.webp *.jpg *.png
When you run the script, it will:
List Available Models:
Display all models returned by the API (without extra metadata) with their index numbers.
Prompt for Model Selection:
Ask you to enter a number corresponding to the model you want to use.
Process Files:
Expand the provided file patterns using wildcards, sort the files naturally, and then process each image:
_transcription.txt suffix.Dynamic MIME Type Detection:
The script uses Python’s mimetypes module to guess the MIME type of each file. Only files with a MIME type that starts with "image/" are processed.
Interactive Model Selection:
All available models from the API are listed. You choose the model to use by entering its index number.
Natural Sorting of Files:
File names are sorted in natural (human-friendly) order, ensuring that files like 2.webp are processed before 10.webp.
Transcription & Cleanup:
The selected model extracts the text from each image and cleans up the output, removing unnecessary line breaks and spaces.
A simple Python GUI application for sorting images using Tkinter and Pillow. This tool allows you to preview images in a filmstrip, select images for processing, zoom and pan within the preview, and automatically organize selected files into folders based on their file extensions.
pip install Pillow
Note: Tkinter is included with most standard Python distributions.
Clone the Repository:
git clone https://github.com/yourusername/imagesorter.git
cd imagesorter
Install Dependencies:
pip install Pillow
Prepare Your Images:
Place the image files you want to sort in the same folder as the imagesort.py script.
Run the Script:
python imagesort.py
Navigate & Process:
Image Loading Errors:
If an image fails to load (e.g., "cannot identify image file"), it will be skipped from the interface. An error message will be printed to the console.
Navigation Bounds:
The script prevents navigation beyond the available images. If you reach the last image, the next image navigation will be disabled.
File Processing Issues:
Ensure that the image files are not open in another application during processing. If errors occur, check the console for specific messages.
Enjoy sorting your images with ease!
CropTransp is a Python script that automatically trims transparent borders from image files (such as PNGs) using ImageMagick. It supports wildcard file patterns, customizable transparency thresholds with a default of 30%, and an option to specify a custom output directory. If installed, it also displays a progress bar via tqdm.
-f/--fuzz flag to set a tolerance level (default is 30%).*.png) to process multiple images at once.tqdm is installed.magick command available.pip install tqdm
Clone the repository or download the script directly:
git clone https://github.com/yourusername/CropTransp.git
cd CropTransp
Make the script executable:
chmod +x croptransp.py
Trim transparent borders from one or more images:
./croptransp.py image1.png image2.png
-f, --fuzz:
Set the transparency threshold as a percentage (default is 30%).
Example (using a 10% threshold):
./croptransp.py -f 10 image1.png
-o, --output:
Specify the output directory. Default is TranspCrop.
./croptransp.py -o OutputFolder *.png
Help:
./croptransp.py -h
TranspCrop) in the current working directory.magick command to apply the -trim operation along with -fuzz (default 30%) and +repage to crop transparent borders.tqdm is available, a progress bar is displayed during processing.Process all PNG images in the current directory with a fuzz threshold of 20% and output them to a folder named CroppedImages:
./croptransp.py -f 20 -o CroppedImages *.png
magick command is correctly installed and in your system's PATH.Happy cropping!
OSPL (ospl.py) is a Python script that processes text files to ensure that each sentence appears on a separate line. It also maintains paragraph separation and correctly handles decorative or extra text before sentences by placing them on separate lines.
punkt_tab) if required.output/ subfolder in the working directory.Ensure you have Python installed, then install NLTK if you haven't already:
pip install nltk
Run the script from the command line, specifying one or more text files:
python ospl.py *.txt
chapter_003.txt)CHAPTER I.
Down the Rabbit-Hole
Alice was beginning to get very tired of sitting by her sister on the bank, and
of having nothing to do: once or twice she had peeped into the book her sister
was reading, but it had no pictures or conversations in it, “and what is
the use of a book,” thought Alice “without pictures or
conversations?”
output/chapter_003.txt)CHAPTER I.
Down the Rabbit-Hole
Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do.
Once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it.
“And what is the use of a book,” thought Alice, “without pictures or conversations?”
output/ folder.If the required NLTK tokenizer is missing, the script will automatically download it and retry processing.
The rembgwrapper.bat script is designed to wrap calls to the rembg tool from a virtual environment. It automatically activates the Python virtual environment, loops over image files (based on a file mask or list), calls rembg with the specified model option, and then deactivates the virtual environment.
It is intended to be hard‐coded with paths for your working directory and virtual environment, so you only need to modify the customizable variables at the top of the script.
Hardcoded Paths:
Customize the virtual environment location and working directory in the script’s header.
File Mask Processing:
Accepts a file mask (e.g. *.jpg or a single file) as the first command-line argument and applies the processing command to each file.
Model Option:
The model option is provided via command-line parameters (after the file mask) and passed to rembg.
Virtual Environment Management:
Automatically activates and then deactivates the virtual environment.
At the top of the script, you will find variables that you can modify:
VENV_PATH:
The absolute path to your virtual environment (e.g. F:\AI\rembg\venv).
WORK_DIR:
The working directory where your source files and rembg script are located (e.g. F:\AI\rembg).
Place the Script:
Save the batch file as rembgwrapper.bat in your project folder (for example, F:\AI\rembg).
Call the Script:
Open a command prompt in the working folder and run:
rembgwrapper.bat *.jpg --model birefnet-massive
This command will process every .jpg file in the directory using the birefnet-massive model.
Processing Workflow:
activate script.rembg i with the specified model, input, and output file names.deactivate to exit the virtual environment.@echo off
REM ============================
REM rembgwrapper.bat - Batch file wrapper for rembg command
REM Processes image files using rembg inside a virtual environment.
REM Usage example:
REM rembgwrapper.bat *.jpg --model birefnet-massive
REM ============================
REM --- Configuration ---
set "VENV_PATH=F:\AI\rembg\venv"
set "WORK_DIR=F:\AI\rembg"
REM --- Change to working directory ---
cd /d "%WORK_DIR%"
REM --- Activate the virtual environment ---
call "%VENV_PATH%\Scripts\activate"
REM --- Parse arguments ---
REM The first argument is the file mask (or single file).
set "FILEMASK=%1"
shift
REM Build options variable from the remaining arguments.
set "OPTS="
:buildOptions
if "%~1"=="" goto optionsDone
set "OPTS=%OPTS% %1"
shift
goto buildOptions
:optionsDone
echo FILEMASK: %FILEMASK%
echo OPTS: %OPTS%
echo.
REM --- Enable delayed expansion ---
setlocal enabledelayedexpansion
REM --- Loop over each matching file ---
for %%F in (%FILEMASK%) do (
set "INPUT=%%F"
set "OUTPUT=%%~nF_T.png"
echo Processing file: !INPUT!
echo Running: rembg i !OPTS! "!INPUT!" "!OUTPUT!"
rembg i !OPTS! "!INPUT!" "!OUTPUT!"
)
endlocal
REM --- Deactivate the virtual environment ---
call deactivate
Unexpected Arguments:
If you see errors about extra arguments, ensure that your options are placed after the file mask on the command line.
Virtual Environment Issues:
Verify that the VENV_PATH is correct and that the virtual environment is set up with rembg installed.
Executable Not Found:
Confirm that rembg.exe is available and in the expected location within your virtual environment’s Scripts folder.
The rembatcher.py script provides a graphical user interface (GUI) to select image files and one or more rembg models. It is intended to be run from a working folder containing your source images, and it outputs processed files into a subdirectory (customizable) within the working folder. When you press the Process button, the GUI closes immediately and processing begins with progress updates printed to the console.
GUI for File & Model Selection:
A vertically arranged interface displays a list of files (populated from command-line arguments) and a list of rembg models as checkboxes.
Customizable Models List:
The list of models is hardcoded (sorted alphabetically) at the top. You can add or remove models as needed.
Dynamic Window Sizing:
The GUI window dynamically sizes itself to fit all widgets, including all model checkboxes (no scrollbar).
Output Directory:
Processed images are output to a subdirectory (e.g., named transp by default) in the working folder.
Dynamic Console Updates:
All processing commands and progress are printed to the console as each file is processed.
At the very top of the script, you can modify:
REMBG_CMD:
The full path to the rembg executable.
Example:
REMBG_CMD = r"F:\AI\rembg\venv\Scripts\rembg.exe"
MODELS:
A list of rembg models. This list is sorted automatically.
You can add or remove models as required.
OUTPUT_DIR_NAME:
The name of the subdirectory where processed files are saved.
Example:
OUTPUT_DIR_NAME = "transp"
Place the Script:
Save the script as rembatcher.py in a central folder (for example, F:\AI\rembg).
Run the Script:
From a working folder (where your image files reside), run the script with:
python F:\AI\rembg\rembatcher.py *.jpg
The script uses the current working folder (from where it is run) as the location for input files and will create (or use) a subdirectory (e.g., transp) for the output files.
Using the GUI:
import tkinter as tk
from tkinter import ttk, filedialog, messagebox
import sys
import os
import subprocess
# -------------------------------
# Configuration - Customize these:
# -------------------------------
# Hardcoded location for the rembg executable.
REMBG_CMD = r"F:\AI\rembg\venv\Scripts\rembg.exe"
# List of rembg models (sorted alphabetically)
MODELS = [
'birefnet-general',
'birefnet-general-lite',
'birefnet-portrait',
'birefnet-dis',
'birefnet-hrsod',
'birefnet-cod',
'birefnet-massive',
'isnet-anime',
'isnet-general-use',
'sam',
'silueta',
'u2net_cloth_seg',
'u2net_custom',
'u2net_human_seg',
'u2net',
'u2netp',
'bria-rmbg'
]
MODELS.sort()
# Name of the output subdirectory (within the working folder)
OUTPUT_DIR_NAME = "transp"
# -------------------------------
# End Configuration
# -------------------------------
def run_gui():
# The working folder is the directory from which the script is called.
working_dir = os.getcwd()
selections = {"files": [], "models": []}
root = tk.Tk()
root.title("Rembatcher")
# Main frame with vertical layout
main_frame = ttk.Frame(root, padding=10)
main_frame.pack(fill="both", expand=True)
# ----- File Frame (top) -----
file_frame = ttk.LabelFrame(main_frame, text="Files in " + working_dir)
file_frame.pack(fill="both", expand=True, padx=5, pady=5)
file_listbox = tk.Listbox(file_frame, selectmode=tk.MULTIPLE, width=60, height=10)
file_listbox.pack(side="top", fill="both", expand=True, padx=5, pady=5)
file_scrollbar = ttk.Scrollbar(file_frame, orient="vertical", command=file_listbox.yview)
file_scrollbar.pack(side="right", fill="y")
file_listbox.config(yscrollcommand=file_scrollbar.set)
# Populate file listbox from command-line arguments
for f in sys.argv[1:]:
file_listbox.insert(tk.END, f)
# File management buttons
file_button_frame = ttk.Frame(file_frame)
file_button_frame.pack(fill="x", padx=5, pady=5)
def add_files():
files = filedialog.askopenfilenames(title="Select Files", initialdir=working_dir)
for f in files:
file_listbox.insert(tk.END, os.path.basename(f))
def remove_selected_files():
for index in reversed(file_listbox.curselection()):
file_listbox.delete(index)
def select_all_files():
file_listbox.select_set(0, tk.END)
def deselect_all_files():
file_listbox.select_clear(0, tk.END)
def clear_files():
file_listbox.delete(0, tk.END)
ttk.Button(file_button_frame, text="Add", command=add_files).pack(side="left", padx=2)
ttk.Button(file_button_frame, text="Remove", command=remove_selected_files).pack(side="left", padx=2)
ttk.Button(file_button_frame, text="Select All", command=select_all_files).pack(side="left", padx=2)
ttk.Button(file_button_frame, text="Deselect All", command=deselect_all_files).pack(side="left", padx=2)
ttk.Button(file_button_frame, text="Clear All", command=clear_files).pack(side="left", padx=2)
# ----- Model Frame (middle) -----
model_frame = ttk.LabelFrame(main_frame, text="Models")
model_frame.pack(fill="both", expand=True, padx=5, pady=5)
# Instead of a canvas, use a frame directly for the checkbuttons.
model_check_frame = ttk.Frame(model_frame)
model_check_frame.pack(fill="both", expand=True, padx=5, pady=5)
model_vars = {}
for m in MODELS:
var = tk.BooleanVar(value=False)
chk = ttk.Checkbutton(model_check_frame, text=m, variable=var)
chk.pack(anchor="w")
model_vars[m] = var
# Model selection buttons (below the checkbuttons)
model_button_frame = ttk.Frame(model_frame)
model_button_frame.pack(fill="x", padx=5, pady=5)
def select_all_models():
for var in model_vars.values():
var.set(True)
def deselect_all_models():
for var in model_vars.values():
var.set(False)
ttk.Button(model_button_frame, text="Select All Models", command=select_all_models).pack(side="left", padx=5)
ttk.Button(model_button_frame, text="Deselect All Models", command=deselect_all_models).pack(side="left", padx=5)
# ----- Process Button (bottom) -----
def on_process():
selections["files"] = file_listbox.get(0, tk.END)
selections["models"] = [model for model, var in model_vars.items() if var.get()]
# Immediately close the GUI.
root.destroy()
process_button = ttk.Button(root, text="Process", command=on_process)
process_button.pack(pady=10)
# Dynamically size the window based on its contents.
root.update_idletasks()
req_width = root.winfo_reqwidth()
req_height = root.winfo_reqheight()
root.geometry(f"{req_width}x{req_height}")
root.mainloop()
return selections, working_dir
def main():
selections, working_dir = run_gui()
if not selections["files"]:
print("No files selected for processing.")
return
if not selections["models"]:
print("No models selected. Exiting.")
return
# Create output subdirectory in the working folder.
output_dir = os.path.join(working_dir, OUTPUT_DIR_NAME)
os.makedirs(output_dir, exist_ok=True)
# Process each file with each selected model.
for f in selections["files"]:
input_file = os.path.join(working_dir, f)
base, _ = os.path.splitext(os.path.basename(f))
for model in selections["models"]:
output_file = os.path.join(output_dir, f"{base}_{model}_T.png")
cmd = [REMBG_CMD, "i", "--model", model, input_file, output_file]
print(f"\nProcessing {f} with model {model}...", flush=True)
print("Running command:", " ".join(cmd), flush=True)
try:
subprocess.run(cmd, check=True)
print(f"Finished processing {f} with model {model}.", flush=True)
except subprocess.CalledProcessError as e:
print(f"Error processing {f} with model {model}:\n{e}", flush=True)
except FileNotFoundError as e:
print(f"Executable not found: {e}", flush=True)
return
print("\nAll processing complete. Processed files are in:", output_dir)
if __name__ == '__main__':
main()
GUI Not Fitting:
The script uses winfo_reqwidth() and winfo_reqheight() to dynamically size the window. If you add many files or models, consider adjusting the design (e.g., adding scrollbars) for very large lists.
Processing Errors:
Console messages provide feedback for each file/model combination. Check the console for error messages if a particular file fails to process.
Virtual Environment:
Ensure the path in REMBG_CMD points to the correct executable (and that rembg is installed in that environment).
This Python script provides a graphical user interface (GUI) for video processing, leveraging the power of NVEncC (NVIDIA Encoder) for fast and efficient video encoding. The tool simplifies common video processing tasks such as:
nvvfx-superres and ngx-vsr for upscaling quality.This tool is designed to be user-friendly, allowing for drag-and-drop file input, intuitive option selection, and batch processing capabilities.
nvvfx-superres or ngx-vsr (Quality 4) for upscaling.This script relies on the following software and Python libraries:
NVEncC64.exe is added to your system's PATH environment variable.ffmpeg.exe and ffprobe.exe are in your PATH.mkvmerge.exe is in your PATH.nvvfx-superres and ngx-vsr upscale algorithms) Download and install the SDK and models. You may need to set the model directory using the --vpp-nvvfx-model-dir NVEncC option if it's not automatically detected (this script currently doesn't expose this option in the GUI, but it's good to be aware of if you encounter issues).pip install):pip install tkinterdnd2pip install ftfyYou can install the Python libraries using pip:
pip install tkinterdnd2 ftfy
--vpp-gauss and npp based resize algorithms in NVEncC - not directly used in the current script's GUI options but mentioned in the NVEncC documentation):nppc64_10.dll, nppif64_10.dll, nppig64_10.dll. These are required if you intend to use the --vpp-gauss filter or NPP-based resize algorithms directly with NVEncC command line (not exposed in the current GUI). You can download these DLLs from NVEnc Releases (look for npp64_10_dll_7zip.7z). Place these DLLs in the same directory as NVEncC64.exe.pip install tkinterdnd2 ftfy.PATH environment variable.your_script_name.py) from this repository.nvvfx-superres or ngx-vsr upscale algorithms, install the NVIDIA Maxine Video Effects SDK and Models.Run the Script: Execute the Python script (your_script_name.py). This will open the Video Processing Tool GUI.
Add Video Files:
File List Management:
Ctrl+Click or Shift+Click for multiple selections.Configure Encoding Options:
Resolution and Upscale Algorithm (LabelFrame "Resolution and Upscale Algorithm"):
nvvfx-superres for AI-powered super-resolution upscaling (requires NVIDIA Maxine SDK). Generally offers good quality and detail preservation.Convert to 8 bit: Check this box to convert the output video to 8-bit color depth. If unchecked, the output will be 10-bit (if supported by the input and encoder).
Convert to HDR: Check this box to tag the output video as HDR (High Dynamic Range). Note: For 8-bit output, this option will trigger HDR to SDR conversion using a LUT. For 10-bit output, it will apply HDR metadata tagging using mkvmerge (if installed).
Vertical Crop: Check this box to apply vertical cropping. This is automatically applied for 4K and 8K resolutions if the input video width is large enough (>= 3840 for 4K, >= 7680 for 8K) to remove black bars.
QVBR Value: Enter the desired QVBR (Quality Variable Bitrate) value (0-51, 0 for automatic). Lower values generally mean higher quality and larger file sizes.
Enable FRUC: Check this box to enable Frame Rate Up Conversion (FRUC).
FRUC FPS Target: (Enabled when "Enable FRUC" is checked) Enter the target FPS for FRUC. Common values are 60 or higher for smoother motion.
Subtitle Alignment: Choose the alignment for burned-in subtitles: Top, Middle, or Bottom.
Subtitle Font Size: Enter the desired font size for burned-in subtitles.
Generate Log File: Check this box to create a log.log file in the same directory as the script, containing detailed encoding information.
Burn Subtitle Tracks (LabelFrame "Burn Subtitle Tracks"):
Start Processing: Once you have configured all options, click the "Start Processing" button in the bottom frame. The script will begin processing the files in the list according to your settings.
Output Files: Output files will be created in subdirectories named "original", "4k", or "8k" within the same directory as the input video files, based on the selected resolution. File names will include suffixes indicating resolution, bit depth (e.g., _8bit), and subtitle track information if subtitles are burned in.
This GUI tool utilizes NVEncC for encoding and exposes a subset of its options through the interface. For advanced users who want to explore the full range of NVEncC's capabilities and command-line options, please refer to the [NVEncC Option List Documentation](link-to-NVEncC-documentation-if-available, or mention searching for "NVEncC Options" online).
ngx-vsr, NVIDIA Maxine SDK integration) are primarily designed for and tested on Windows.nvvfx-superres, ngx-vsr) rely on NVIDIA GPUs. The script will not function as intended without a compatible NVIDIA graphics card.PATH.This Python script converts PNG images to JPG format in the current working directory using ImageMagick. It's designed to be run from the command line and offers various options to control the JPG conversion process, such as quality, sampling factor, and more. Newly generated JPG files are automatically moved into a jpg subfolder.
-q or --quality): Adjust JPG quality for file size vs. image quality trade-off.--sampling-factor): Control chroma subsampling for color detail vs. file size.--density): Set DPI resolution for the output JPG images.--interlace): Create progressive (interlaced) or baseline JPGs.--strip): Remove metadata to reduce file size.--profile): Embed a specific ICC color profile.--resize): Resize images before conversion using ImageMagick geometry strings.jpg Folder: Automatically creates a jpg subfolder and moves the newly created JPG files into it, keeping your original directory organized.-h or --help flag to display usage instructions and available options.Before running this script, you need to have the following software installed and properly configured:
magick command-line tool must be accessible in your system's PATH environment variable. You can download ImageMagick from https://imagemagick.org/. Make sure to install a version that includes the magick command (the newer unified command-line interface).process_images.py or magickjpg.py) to your desired location.chmod +x process_images.py (on Linux/macOS). On Windows, this is generally not necessary.Open Command Prompt/Terminal: Open your command prompt (on Windows) or terminal (on macOS/Linux).
Navigate to the Directory with PNGs: Use the cd command to navigate to the directory where your PNG images are located. This directory will be the current working directory for the script.
Run the Script: Execute the script using the python interpreter, providing the input file pattern as the first argument, followed by any desired options.
python path/to/magickjpg.py <input_pattern> [options]
path/to/magickjpg.py: Replace this with the actual path to where you saved the script if you are not running it from the same directory. If the script is in your current directory, you can just use magickjpg.py (or python magickjpg.py on Windows).<input_pattern>: This is required and specifies the file pattern to match for conversion. Common patterns are:
*.png: To convert all PNG files.*.tif: To convert all TIFF files.image*.png: To convert PNG files starting with "image".single_image.bmp: To convert a specific file named "single_image.bmp".[options]: These are optional flags to control the JPG conversion process. See the "Command-Line Arguments" section below for available options.| Argument/Option | Short Flag | Type | Description |
|---|---|---|---|
<input_pattern> | (positional) | String | Required. Specifies the file pattern to match for image conversion (e.g., *.png, image*.tif). |
-q / --quality | -q | Integer | JPEG quality level (0-100, higher is better quality, larger file size). Default is ImageMagick's default quality. |
--sampling-factor | String | JPEG chroma sampling factor (e.g., '4:2:0', '4:4:4'). Controls color detail vs. file size. | |
--density | Integer | DPI density for the output JPEG images. | |
--interlace | String | JPEG interlace mode. Choices: 'None', 'Plane', 'Line', 'Partition'. Use 'Plane' for progressive JPEGs (recommended for web). | |
--strip | Flag | Strip metadata (EXIF, IPTC, etc.) from JPEG images to reduce file size. | |
--profile | String | Path to an ICC profile file to embed in the JPEG images. Example: "path/to/sRGB.icc". | |
--resize | String | ImageMagick geometry string for resizing images before conversion. Examples: '50%', '800x600', '800x>'. Refer to ImageMagick documentation for geometry syntax. | |
-h / --help | -h | Flag | Display help message and exit. |
The script will create a subfolder named jpg in the current working directory (if it doesn't already exist). All newly generated JPG files will be moved into this jpg folder.
Convert all PNG files in the current directory to JPG with default settings:
python magickjpg.py *.png
Convert all PNG files to JPG with a quality level of 85:
python magickjpg.py *.png -q 85
Convert all PNG files, set quality to 90, use 4:2:0 sampling factor, and create progressive JPGs:
python magickjpg.py *.png -q 90 --sampling-factor 4:2:0 --interlace Plane
Convert all PNG files, resize them to 50% of their original size, and strip metadata:
python magickjpg.py *.png --resize 50% --strip
Get help information to see all available options:
python magickjpg.py -h
or
python magickjpg.py --help
Contributions to this project are welcome! If you find bugs, have feature requests, or want to contribute code improvements, please feel free to:
For questions or support, pray to the AI god. Good luck.
Disclaimer: This tool is provided as-is, without warranty. Please use it responsibly and at your own risk. Always verify your output files.
This project is open-source and available under the GNU General Public License version 3 (GPLv3) license.
1,186 commits
Python
90.4%
Batchfile
5.5%
Lua
2.9%
Here's a comprehensive README.md for your GitHub repository:
A Python script for batch processing video files with HDR metadata injection and LUT embedding for professional video workflows.
# Clone repository
git clone https://github.com/yourusername/hdr-injector.git
cd hdr-injector
# Install requirements (no external dependencies needed)
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
# Automatic mode: Process all videos in current directory and subdirectories
python addhdr.py
# Process single file with LUT embedding
python addhdr.py input.mkv
# Process directory and subdirectories
python addhdr.py /path/to/videos/
# Wildcard pattern matching
python addhdr.py *.mkv
# Without LUT embedding
python addhdr.py --no-lut input.mkv
# Custom output directory
python addhdr.py -o /custom/output/path input.mkv
# Custom mkvmerge path
python addhdr.py --mkvmerge-path "/usr/local/bin/mkvmerge" input.mkv
⚠️ Note: Always back up original files before processing
NBCU Technical LUT for PQ→SDR conversion (included in Resolve installations)
Q: mkvmerge not found
A: Install MKVToolNix and verify it's in your system PATH
Q: LUT file not found
A: Use --lut /custom/path/to/lut.cube or disable with --no-lut
Q: Permission denied errors
A: Run with elevated privileges or check file/directory permissions
Q: Output directory not created
A: Verify valid path and write permissions on target drive
This Python script uses the Google Gen AI Python SDK to extract and clean up text from image files. It dynamically determines the MIME type of each input file, allowing you to process any image file type (e.g., JPEG, PNG, WebP). The script also retrieves a list of available models from the API, prompts you to select one interactively, and processes the images in natural numerical order.
Dynamic Image Support:
Automatically detects the MIME type for any image file based on its extension.
Interactive Model Selection:
Lists available models from the API and prompts you to choose one by entering its corresponding number.
Natural File Sorting:
Uses natural sorting to process files in human-friendly numerical order (e.g., 2.webp comes before 10.webp).
Transcription & Cleanup:
Extracts text from images using OCR-like functionality, cleans up formatting (removes extra line breaks and spaces), and outputs well-structured text.
Output File Saving:
Saves the cleaned transcription to a text file (with a _transcription.txt suffix) for each processed image.
Run the script with one or more file patterns as arguments. For example:
python transcribeimage.py *.webp *.jpg *.png
When you run the script, it will:
List Available Models:
Display all models returned by the API (without extra metadata) with their index numbers.
Prompt for Model Selection:
Ask you to enter a number corresponding to the model you want to use.
Process Files:
Expand the provided file patterns using wildcards, sort the files naturally, and then process each image:
_transcription.txt suffix.Dynamic MIME Type Detection:
The script uses Python’s mimetypes module to guess the MIME type of each file. Only files with a MIME type that starts with "image/" are processed.
Interactive Model Selection:
All available models from the API are listed. You choose the model to use by entering its index number.
Natural Sorting of Files:
File names are sorted in natural (human-friendly) order, ensuring that files like 2.webp are processed before 10.webp.
Transcription & Cleanup:
The selected model extracts the text from each image and cleans up the output, removing unnecessary line breaks and spaces.
A simple Python GUI application for sorting images using Tkinter and Pillow. This tool allows you to preview images in a filmstrip, select images for processing, zoom and pan within the preview, and automatically organize selected files into folders based on their file extensions.
pip install Pillow
Note: Tkinter is included with most standard Python distributions.
Clone the Repository:
git clone https://github.com/yourusername/imagesorter.git
cd imagesorter
Install Dependencies:
pip install Pillow
Prepare Your Images:
Place the image files you want to sort in the same folder as the imagesort.py script.
Run the Script:
python imagesort.py
Navigate & Process:
Image Loading Errors:
If an image fails to load (e.g., "cannot identify image file"), it will be skipped from the interface. An error message will be printed to the console.
Navigation Bounds:
The script prevents navigation beyond the available images. If you reach the last image, the next image navigation will be disabled.
File Processing Issues:
Ensure that the image files are not open in another application during processing. If errors occur, check the console for specific messages.
Enjoy sorting your images with ease!
CropTransp is a Python script that automatically trims transparent borders from image files (such as PNGs) using ImageMagick. It supports wildcard file patterns, customizable transparency thresholds with a default of 30%, and an option to specify a custom output directory. If installed, it also displays a progress bar via tqdm.
-f/--fuzz flag to set a tolerance level (default is 30%).*.png) to process multiple images at once.tqdm is installed.magick command available.pip install tqdm
Clone the repository or download the script directly:
git clone https://github.com/yourusername/CropTransp.git
cd CropTransp
Make the script executable:
chmod +x croptransp.py
Trim transparent borders from one or more images:
./croptransp.py image1.png image2.png
-f, --fuzz:
Set the transparency threshold as a percentage (default is 30%).
Example (using a 10% threshold):
./croptransp.py -f 10 image1.png
-o, --output:
Specify the output directory. Default is TranspCrop.
./croptransp.py -o OutputFolder *.png
Help:
./croptransp.py -h
TranspCrop) in the current working directory.magick command to apply the -trim operation along with -fuzz (default 30%) and +repage to crop transparent borders.tqdm is available, a progress bar is displayed during processing.Process all PNG images in the current directory with a fuzz threshold of 20% and output them to a folder named CroppedImages:
./croptransp.py -f 20 -o CroppedImages *.png
magick command is correctly installed and in your system's PATH.Happy cropping!
OSPL (ospl.py) is a Python script that processes text files to ensure that each sentence appears on a separate line. It also maintains paragraph separation and correctly handles decorative or extra text before sentences by placing them on separate lines.
punkt_tab) if required.output/ subfolder in the working directory.Ensure you have Python installed, then install NLTK if you haven't already:
pip install nltk
Run the script from the command line, specifying one or more text files:
python ospl.py *.txt
chapter_003.txt)CHAPTER I.
Down the Rabbit-Hole
Alice was beginning to get very tired of sitting by her sister on the bank, and
of having nothing to do: once or twice she had peeped into the book her sister
was reading, but it had no pictures or conversations in it, “and what is
the use of a book,” thought Alice “without pictures or
conversations?”
output/chapter_003.txt)CHAPTER I.
Down the Rabbit-Hole
Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do.
Once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it.
“And what is the use of a book,” thought Alice, “without pictures or conversations?”
output/ folder.If the required NLTK tokenizer is missing, the script will automatically download it and retry processing.
The rembgwrapper.bat script is designed to wrap calls to the rembg tool from a virtual environment. It automatically activates the Python virtual environment, loops over image files (based on a file mask or list), calls rembg with the specified model option, and then deactivates the virtual environment.
It is intended to be hard‐coded with paths for your working directory and virtual environment, so you only need to modify the customizable variables at the top of the script.
Hardcoded Paths:
Customize the virtual environment location and working directory in the script’s header.
File Mask Processing:
Accepts a file mask (e.g. *.jpg or a single file) as the first command-line argument and applies the processing command to each file.
Model Option:
The model option is provided via command-line parameters (after the file mask) and passed to rembg.
Virtual Environment Management:
Automatically activates and then deactivates the virtual environment.
At the top of the script, you will find variables that you can modify:
VENV_PATH:
The absolute path to your virtual environment (e.g. F:\AI\rembg\venv).
WORK_DIR:
The working directory where your source files and rembg script are located (e.g. F:\AI\rembg).
Place the Script:
Save the batch file as rembgwrapper.bat in your project folder (for example, F:\AI\rembg).
Call the Script:
Open a command prompt in the working folder and run:
rembgwrapper.bat *.jpg --model birefnet-massive
This command will process every .jpg file in the directory using the birefnet-massive model.
Processing Workflow:
activate script.rembg i with the specified model, input, and output file names.deactivate to exit the virtual environment.@echo off
REM ============================
REM rembgwrapper.bat - Batch file wrapper for rembg command
REM Processes image files using rembg inside a virtual environment.
REM Usage example:
REM rembgwrapper.bat *.jpg --model birefnet-massive
REM ============================
REM --- Configuration ---
set "VENV_PATH=F:\AI\rembg\venv"
set "WORK_DIR=F:\AI\rembg"
REM --- Change to working directory ---
cd /d "%WORK_DIR%"
REM --- Activate the virtual environment ---
call "%VENV_PATH%\Scripts\activate"
REM --- Parse arguments ---
REM The first argument is the file mask (or single file).
set "FILEMASK=%1"
shift
REM Build options variable from the remaining arguments.
set "OPTS="
:buildOptions
if "%~1"=="" goto optionsDone
set "OPTS=%OPTS% %1"
shift
goto buildOptions
:optionsDone
echo FILEMASK: %FILEMASK%
echo OPTS: %OPTS%
echo.
REM --- Enable delayed expansion ---
setlocal enabledelayedexpansion
REM --- Loop over each matching file ---
for %%F in (%FILEMASK%) do (
set "INPUT=%%F"
set "OUTPUT=%%~nF_T.png"
echo Processing file: !INPUT!
echo Running: rembg i !OPTS! "!INPUT!" "!OUTPUT!"
rembg i !OPTS! "!INPUT!" "!OUTPUT!"
)
endlocal
REM --- Deactivate the virtual environment ---
call deactivate
Unexpected Arguments:
If you see errors about extra arguments, ensure that your options are placed after the file mask on the command line.
Virtual Environment Issues:
Verify that the VENV_PATH is correct and that the virtual environment is set up with rembg installed.
Executable Not Found:
Confirm that rembg.exe is available and in the expected location within your virtual environment’s Scripts folder.
The rembatcher.py script provides a graphical user interface (GUI) to select image files and one or more rembg models. It is intended to be run from a working folder containing your source images, and it outputs processed files into a subdirectory (customizable) within the working folder. When you press the Process button, the GUI closes immediately and processing begins with progress updates printed to the console.
GUI for File & Model Selection:
A vertically arranged interface displays a list of files (populated from command-line arguments) and a list of rembg models as checkboxes.
Customizable Models List:
The list of models is hardcoded (sorted alphabetically) at the top. You can add or remove models as needed.
Dynamic Window Sizing:
The GUI window dynamically sizes itself to fit all widgets, including all model checkboxes (no scrollbar).
Output Directory:
Processed images are output to a subdirectory (e.g., named transp by default) in the working folder.
Dynamic Console Updates:
All processing commands and progress are printed to the console as each file is processed.
At the very top of the script, you can modify:
REMBG_CMD:
The full path to the rembg executable.
Example:
REMBG_CMD = r"F:\AI\rembg\venv\Scripts\rembg.exe"
MODELS:
A list of rembg models. This list is sorted automatically.
You can add or remove models as required.
OUTPUT_DIR_NAME:
The name of the subdirectory where processed files are saved.
Example:
OUTPUT_DIR_NAME = "transp"
Place the Script:
Save the script as rembatcher.py in a central folder (for example, F:\AI\rembg).
Run the Script:
From a working folder (where your image files reside), run the script with:
python F:\AI\rembg\rembatcher.py *.jpg
The script uses the current working folder (from where it is run) as the location for input files and will create (or use) a subdirectory (e.g., transp) for the output files.
Using the GUI:
import tkinter as tk
from tkinter import ttk, filedialog, messagebox
import sys
import os
import subprocess
# -------------------------------
# Configuration - Customize these:
# -------------------------------
# Hardcoded location for the rembg executable.
REMBG_CMD = r"F:\AI\rembg\venv\Scripts\rembg.exe"
# List of rembg models (sorted alphabetically)
MODELS = [
'birefnet-general',
'birefnet-general-lite',
'birefnet-portrait',
'birefnet-dis',
'birefnet-hrsod',
'birefnet-cod',
'birefnet-massive',
'isnet-anime',
'isnet-general-use',
'sam',
'silueta',
'u2net_cloth_seg',
'u2net_custom',
'u2net_human_seg',
'u2net',
'u2netp',
'bria-rmbg'
]
MODELS.sort()
# Name of the output subdirectory (within the working folder)
OUTPUT_DIR_NAME = "transp"
# -------------------------------
# End Configuration
# -------------------------------
def run_gui():
# The working folder is the directory from which the script is called.
working_dir = os.getcwd()
selections = {"files": [], "models": []}
root = tk.Tk()
root.title("Rembatcher")
# Main frame with vertical layout
main_frame = ttk.Frame(root, padding=10)
main_frame.pack(fill="both", expand=True)
# ----- File Frame (top) -----
file_frame = ttk.LabelFrame(main_frame, text="Files in " + working_dir)
file_frame.pack(fill="both", expand=True, padx=5, pady=5)
file_listbox = tk.Listbox(file_frame, selectmode=tk.MULTIPLE, width=60, height=10)
file_listbox.pack(side="top", fill="both", expand=True, padx=5, pady=5)
file_scrollbar = ttk.Scrollbar(file_frame, orient="vertical", command=file_listbox.yview)
file_scrollbar.pack(side="right", fill="y")
file_listbox.config(yscrollcommand=file_scrollbar.set)
# Populate file listbox from command-line arguments
for f in sys.argv[1:]:
file_listbox.insert(tk.END, f)
# File management buttons
file_button_frame = ttk.Frame(file_frame)
file_button_frame.pack(fill="x", padx=5, pady=5)
def add_files():
files = filedialog.askopenfilenames(title="Select Files", initialdir=working_dir)
for f in files:
file_listbox.insert(tk.END, os.path.basename(f))
def remove_selected_files():
for index in reversed(file_listbox.curselection()):
file_listbox.delete(index)
def select_all_files():
file_listbox.select_set(0, tk.END)
def deselect_all_files():
file_listbox.select_clear(0, tk.END)
def clear_files():
file_listbox.delete(0, tk.END)
ttk.Button(file_button_frame, text="Add", command=add_files).pack(side="left", padx=2)
ttk.Button(file_button_frame, text="Remove", command=remove_selected_files).pack(side="left", padx=2)
ttk.Button(file_button_frame, text="Select All", command=select_all_files).pack(side="left", padx=2)
ttk.Button(file_button_frame, text="Deselect All", command=deselect_all_files).pack(side="left", padx=2)
ttk.Button(file_button_frame, text="Clear All", command=clear_files).pack(side="left", padx=2)
# ----- Model Frame (middle) -----
model_frame = ttk.LabelFrame(main_frame, text="Models")
model_frame.pack(fill="both", expand=True, padx=5, pady=5)
# Instead of a canvas, use a frame directly for the checkbuttons.
model_check_frame = ttk.Frame(model_frame)
model_check_frame.pack(fill="both", expand=True, padx=5, pady=5)
model_vars = {}
for m in MODELS:
var = tk.BooleanVar(value=False)
chk = ttk.Checkbutton(model_check_frame, text=m, variable=var)
chk.pack(anchor="w")
model_vars[m] = var
# Model selection buttons (below the checkbuttons)
model_button_frame = ttk.Frame(model_frame)
model_button_frame.pack(fill="x", padx=5, pady=5)
def select_all_models():
for var in model_vars.values():
var.set(True)
def deselect_all_models():
for var in model_vars.values():
var.set(False)
ttk.Button(model_button_frame, text="Select All Models", command=select_all_models).pack(side="left", padx=5)
ttk.Button(model_button_frame, text="Deselect All Models", command=deselect_all_models).pack(side="left", padx=5)
# ----- Process Button (bottom) -----
def on_process():
selections["files"] = file_listbox.get(0, tk.END)
selections["models"] = [model for model, var in model_vars.items() if var.get()]
# Immediately close the GUI.
root.destroy()
process_button = ttk.Button(root, text="Process", command=on_process)
process_button.pack(pady=10)
# Dynamically size the window based on its contents.
root.update_idletasks()
req_width = root.winfo_reqwidth()
req_height = root.winfo_reqheight()
root.geometry(f"{req_width}x{req_height}")
root.mainloop()
return selections, working_dir
def main():
selections, working_dir = run_gui()
if not selections["files"]:
print("No files selected for processing.")
return
if not selections["models"]:
print("No models selected. Exiting.")
return
# Create output subdirectory in the working folder.
output_dir = os.path.join(working_dir, OUTPUT_DIR_NAME)
os.makedirs(output_dir, exist_ok=True)
# Process each file with each selected model.
for f in selections["files"]:
input_file = os.path.join(working_dir, f)
base, _ = os.path.splitext(os.path.basename(f))
for model in selections["models"]:
output_file = os.path.join(output_dir, f"{base}_{model}_T.png")
cmd = [REMBG_CMD, "i", "--model", model, input_file, output_file]
print(f"\nProcessing {f} with model {model}...", flush=True)
print("Running command:", " ".join(cmd), flush=True)
try:
subprocess.run(cmd, check=True)
print(f"Finished processing {f} with model {model}.", flush=True)
except subprocess.CalledProcessError as e:
print(f"Error processing {f} with model {model}:\n{e}", flush=True)
except FileNotFoundError as e:
print(f"Executable not found: {e}", flush=True)
return
print("\nAll processing complete. Processed files are in:", output_dir)
if __name__ == '__main__':
main()
GUI Not Fitting:
The script uses winfo_reqwidth() and winfo_reqheight() to dynamically size the window. If you add many files or models, consider adjusting the design (e.g., adding scrollbars) for very large lists.
Processing Errors:
Console messages provide feedback for each file/model combination. Check the console for error messages if a particular file fails to process.
Virtual Environment:
Ensure the path in REMBG_CMD points to the correct executable (and that rembg is installed in that environment).
This Python script provides a graphical user interface (GUI) for video processing, leveraging the power of NVEncC (NVIDIA Encoder) for fast and efficient video encoding. The tool simplifies common video processing tasks such as:
nvvfx-superres and ngx-vsr for upscaling quality.This tool is designed to be user-friendly, allowing for drag-and-drop file input, intuitive option selection, and batch processing capabilities.
nvvfx-superres or ngx-vsr (Quality 4) for upscaling.This script relies on the following software and Python libraries:
NVEncC64.exe is added to your system's PATH environment variable.ffmpeg.exe and ffprobe.exe are in your PATH.mkvmerge.exe is in your PATH.nvvfx-superres and ngx-vsr upscale algorithms) Download and install the SDK and models. You may need to set the model directory using the --vpp-nvvfx-model-dir NVEncC option if it's not automatically detected (this script currently doesn't expose this option in the GUI, but it's good to be aware of if you encounter issues).pip install):pip install tkinterdnd2pip install ftfyYou can install the Python libraries using pip:
pip install tkinterdnd2 ftfy
--vpp-gauss and npp based resize algorithms in NVEncC - not directly used in the current script's GUI options but mentioned in the NVEncC documentation):nppc64_10.dll, nppif64_10.dll, nppig64_10.dll. These are required if you intend to use the --vpp-gauss filter or NPP-based resize algorithms directly with NVEncC command line (not exposed in the current GUI). You can download these DLLs from NVEnc Releases (look for npp64_10_dll_7zip.7z). Place these DLLs in the same directory as NVEncC64.exe.pip install tkinterdnd2 ftfy.PATH environment variable.your_script_name.py) from this repository.nvvfx-superres or ngx-vsr upscale algorithms, install the NVIDIA Maxine Video Effects SDK and Models.Run the Script: Execute the Python script (your_script_name.py). This will open the Video Processing Tool GUI.
Add Video Files:
File List Management:
Ctrl+Click or Shift+Click for multiple selections.Configure Encoding Options:
Resolution and Upscale Algorithm (LabelFrame "Resolution and Upscale Algorithm"):
nvvfx-superres for AI-powered super-resolution upscaling (requires NVIDIA Maxine SDK). Generally offers good quality and detail preservation.Convert to 8 bit: Check this box to convert the output video to 8-bit color depth. If unchecked, the output will be 10-bit (if supported by the input and encoder).
Convert to HDR: Check this box to tag the output video as HDR (High Dynamic Range). Note: For 8-bit output, this option will trigger HDR to SDR conversion using a LUT. For 10-bit output, it will apply HDR metadata tagging using mkvmerge (if installed).
Vertical Crop: Check this box to apply vertical cropping. This is automatically applied for 4K and 8K resolutions if the input video width is large enough (>= 3840 for 4K, >= 7680 for 8K) to remove black bars.
QVBR Value: Enter the desired QVBR (Quality Variable Bitrate) value (0-51, 0 for automatic). Lower values generally mean higher quality and larger file sizes.
Enable FRUC: Check this box to enable Frame Rate Up Conversion (FRUC).
FRUC FPS Target: (Enabled when "Enable FRUC" is checked) Enter the target FPS for FRUC. Common values are 60 or higher for smoother motion.
Subtitle Alignment: Choose the alignment for burned-in subtitles: Top, Middle, or Bottom.
Subtitle Font Size: Enter the desired font size for burned-in subtitles.
Generate Log File: Check this box to create a log.log file in the same directory as the script, containing detailed encoding information.
Burn Subtitle Tracks (LabelFrame "Burn Subtitle Tracks"):
Start Processing: Once you have configured all options, click the "Start Processing" button in the bottom frame. The script will begin processing the files in the list according to your settings.
Output Files: Output files will be created in subdirectories named "original", "4k", or "8k" within the same directory as the input video files, based on the selected resolution. File names will include suffixes indicating resolution, bit depth (e.g., _8bit), and subtitle track information if subtitles are burned in.
This GUI tool utilizes NVEncC for encoding and exposes a subset of its options through the interface. For advanced users who want to explore the full range of NVEncC's capabilities and command-line options, please refer to the [NVEncC Option List Documentation](link-to-NVEncC-documentation-if-available, or mention searching for "NVEncC Options" online).
ngx-vsr, NVIDIA Maxine SDK integration) are primarily designed for and tested on Windows.nvvfx-superres, ngx-vsr) rely on NVIDIA GPUs. The script will not function as intended without a compatible NVIDIA graphics card.PATH.This Python script converts PNG images to JPG format in the current working directory using ImageMagick. It's designed to be run from the command line and offers various options to control the JPG conversion process, such as quality, sampling factor, and more. Newly generated JPG files are automatically moved into a jpg subfolder.
-q or --quality): Adjust JPG quality for file size vs. image quality trade-off.--sampling-factor): Control chroma subsampling for color detail vs. file size.--density): Set DPI resolution for the output JPG images.--interlace): Create progressive (interlaced) or baseline JPGs.--strip): Remove metadata to reduce file size.--profile): Embed a specific ICC color profile.--resize): Resize images before conversion using ImageMagick geometry strings.jpg Folder: Automatically creates a jpg subfolder and moves the newly created JPG files into it, keeping your original directory organized.-h or --help flag to display usage instructions and available options.Before running this script, you need to have the following software installed and properly configured:
magick command-line tool must be accessible in your system's PATH environment variable. You can download ImageMagick from https://imagemagick.org/. Make sure to install a version that includes the magick command (the newer unified command-line interface).process_images.py or magickjpg.py) to your desired location.chmod +x process_images.py (on Linux/macOS). On Windows, this is generally not necessary.Open Command Prompt/Terminal: Open your command prompt (on Windows) or terminal (on macOS/Linux).
Navigate to the Directory with PNGs: Use the cd command to navigate to the directory where your PNG images are located. This directory will be the current working directory for the script.
Run the Script: Execute the script using the python interpreter, providing the input file pattern as the first argument, followed by any desired options.
python path/to/magickjpg.py <input_pattern> [options]
path/to/magickjpg.py: Replace this with the actual path to where you saved the script if you are not running it from the same directory. If the script is in your current directory, you can just use magickjpg.py (or python magickjpg.py on Windows).<input_pattern>: This is required and specifies the file pattern to match for conversion. Common patterns are:
*.png: To convert all PNG files.*.tif: To convert all TIFF files.image*.png: To convert PNG files starting with "image".single_image.bmp: To convert a specific file named "single_image.bmp".[options]: These are optional flags to control the JPG conversion process. See the "Command-Line Arguments" section below for available options.| Argument/Option | Short Flag | Type | Description |
|---|---|---|---|
<input_pattern> | (positional) | String | Required. Specifies the file pattern to match for image conversion (e.g., *.png, image*.tif). |
-q / --quality | -q | Integer | JPEG quality level (0-100, higher is better quality, larger file size). Default is ImageMagick's default quality. |
--sampling-factor | String | JPEG chroma sampling factor (e.g., '4:2:0', '4:4:4'). Controls color detail vs. file size. | |
--density | Integer | DPI density for the output JPEG images. | |
--interlace | String | JPEG interlace mode. Choices: 'None', 'Plane', 'Line', 'Partition'. Use 'Plane' for progressive JPEGs (recommended for web). | |
--strip | Flag | Strip metadata (EXIF, IPTC, etc.) from JPEG images to reduce file size. | |
--profile | String | Path to an ICC profile file to embed in the JPEG images. Example: "path/to/sRGB.icc". | |
--resize | String | ImageMagick geometry string for resizing images before conversion. Examples: '50%', '800x600', '800x>'. Refer to ImageMagick documentation for geometry syntax. | |
-h / --help | -h | Flag | Display help message and exit. |
The script will create a subfolder named jpg in the current working directory (if it doesn't already exist). All newly generated JPG files will be moved into this jpg folder.
Convert all PNG files in the current directory to JPG with default settings:
python magickjpg.py *.png
Convert all PNG files to JPG with a quality level of 85:
python magickjpg.py *.png -q 85
Convert all PNG files, set quality to 90, use 4:2:0 sampling factor, and create progressive JPGs:
python magickjpg.py *.png -q 90 --sampling-factor 4:2:0 --interlace Plane
Convert all PNG files, resize them to 50% of their original size, and strip metadata:
python magickjpg.py *.png --resize 50% --strip
Get help information to see all available options:
python magickjpg.py -h
or
python magickjpg.py --help
Contributions to this project are welcome! If you find bugs, have feature requests, or want to contribute code improvements, please feel free to:
For questions or support, pray to the AI god. Good luck.
Disclaimer: This tool is provided as-is, without warranty. Please use it responsibly and at your own risk. Always verify your output files.
This project is open-source and available under the GNU General Public License version 3 (GPLv3) license.
1,186 commits
Python
90.4%
Batchfile
5.5%
Lua
2.9%