2

PyLiff、Libtiff、または機能するものを使用して、複数のファイルを複数ページの TIFF に統合するのに苦労しています。

任意の 8 桁の ID とそれに続くページ番号を持つ何千ものファイルを統合しています。

日付 \images\1999\10\14 という名前のディレクトリ

ファイル群 1 01234567_0001.tif、01234567_0002.tif、01234567_0003.tif

ファイル群 2 07654321_0001.tif、07654321_0002.tif

変換後、次の 2 つのファイルが必要です。

  1. 01234567.tif (3 ページのマルチページ TIFF ファイル)
  2. 07654321.tif (2 ページのマルチページ TIFF ファイル)

等々。最初の 8 桁で分離し、その一意の 8 桁の番号でファイルをマージし、新しい (統合された) ファイルの名前を適切な8 桁の数字.tiffに変更するスクリプトと統合に関するガイダンスを提供してください。

これは何の努力もしていないように思えます。私は、このフォーラムの水域を濁らせる多くの異なるスクリプトとアプローチを持っています。

4

1 に答える 1

0

Rubyが提供できたソリューションとして(Imagemagickは実際に変換を行いました)。これが他の人に役立つことを願っています:

#!/usr/bin/env ruby

require 'find'
require 'set'

start_path = ARGV.shift || "~\Desktop\in"
output_path = ARGV.shift || "~\Desktop\out"

unless File.exist? start_path
  raise "cannot catalog contents; '#{start_path}' does not exist"
end

unless File.exist? output_path
  raise "cannot catalog contents; '#{output_path}' does not exist"
end

#make sure the output directory has a trailing slash
unless output_path =~ /\\$/
  output_path += "\\"
end

documents = Set.new

#look at each file
Find.find(start_path) do |file_path| 
  #look for the document pattern
  if file_path =~ /^(.*?(\d{8}))_\d{4}.tif/
    #track it so we can get the unique document list
    documents.add({:path => $1, :name => $2})
  end
end

documents.each do |doc|
  command = "convert #{doc[:path]}*.tif* #{output_path}#{doc[:name]}.tif"
  puts command
  `#{command}`
end
于 2014-05-04T20:50:51.427 に答える