编写一个脚本(使用Python、AppleScript和Bash),自动将一组金字塔状平铺的图像转换为一组大型TIFF图像,使用ndpi2tiff工具。
创始人
2024-12-06 23:02:04
0

这是一个使用Python、AppleScript和Bash编写的脚本,用于自动将一组金字塔状平铺的图像转换为一组大型TIFF图像,使用ndpi2tiff工具。

  1. Python脚本:
import os
import subprocess

def convert_images(input_dir, output_dir):
    # 获取输入目录中的所有文件
    files = os.listdir(input_dir)
    
    for file in files:
        # 构建输入和输出文件路径
        input_file = os.path.join(input_dir, file)
        output_file = os.path.join(output_dir, file.replace(".ndpi", ".tiff"))
        
        # 调用ndpi2tiff工具转换图像
        subprocess.run(["ndpi2tiff", input_file, output_file])
        
# 设置输入和输出目录
input_dir = "/path/to/input/directory"
output_dir = "/path/to/output/directory"

# 调用函数进行转换
convert_images(input_dir, output_dir)
  1. AppleScript脚本:
on run
    set inputDir to POSIX path of ("/path/to/input/directory" as alias)
    set outputDir to POSIX path of ("/path/to/output/directory" as alias)
    
    tell application "Finder"
        set files to every file of folder inputDir
    end tell
    
    repeat with file in files
        set inputFilePath to inputDir & file
        set outputFilePath to outputDir & (text 1 thru -6 of file) & ".tiff"
        
        set cmd to "ndpi2tiff " & quoted form of inputFilePath & " " & quoted form of outputFilePath
        do shell script cmd
    end repeat
end run
  1. Bash脚本:
#!/bin/bash

input_dir="/path/to/input/directory"
output_dir="/path/to/output/directory"

for file in $input_dir/*.ndpi; do
    output_file="${output_dir}/$(basename "$file" .ndpi).tiff"
    ndpi2tiff "$file" "$output_file"
done

你可以根据你的需求选择其中一种脚本,并将/path/to/input/directory替换为包含输入图像的实际目录,将/path/to/output/directory替换为你想要保存输出图像的实际目录。然后运行脚本,它将自动将输入目录中的所有图像转换为大型TIFF图像,并保存在输出目录中。

相关内容

热门资讯

记者揭秘!智星菠萝辅助(透视辅... 记者揭秘!智星菠萝辅助(透视辅助)拱趴大菠萝辅助神器,扑克教程(有挂细节);模式供您选择,了解更新找...
一分钟揭秘!约局吧能能开挂(透... 一分钟揭秘!约局吧能能开挂(透视辅助)hhpoker辅助靠谱,2024新版教程(有挂教学);约局吧能...
透视辅助!wepoker模拟器... 透视辅助!wepoker模拟器哪个好用(脚本)hhpoker辅助挂是真的,科技教程(有挂技巧);囊括...
透视代打!hhpkoer辅助器... 透视代打!hhpkoer辅助器视频(辅助挂)pokemmo脚本辅助,2024新版教程(有挂教程);风...
透视了解!约局吧德州真的有透视... 透视了解!约局吧德州真的有透视挂(透视脚本)德州局HHpoker透视脚本,必胜教程(有挂分析);亲,...
六分钟了解!wepoker挂底... 六分钟了解!wepoker挂底牌(透视)德普之星开辅助,详细教程(有挂解密);德普之星开辅助是一种具...
9分钟了解!wpk私人辅助(透... 9分钟了解!wpk私人辅助(透视)hhpoker德州透视,插件教程(有挂教学);风靡全球的特色经典游...
推荐一款!wepoker究竟有... 推荐一款!wepoker究竟有透视(脚本)哈糖大菠萝开挂,介绍教程(有挂技术);囊括全国各种wepo...
每日必备!wepoker有人用... 每日必备!wepoker有人用过(脚本)wpk有那种辅助,线上教程(有挂规律);wepoker有人用...
玩家必备教程!wejoker私... 玩家必备教程!wejoker私人辅助软件(脚本)哈糖大菠萝可以开挂,可靠技巧(有挂神器)申哈糖大菠萝...