开发者

tiffcp.exe merging a results file with a results file in a loop

I am building a web app that takes several tiff image files and merges them together into one single tiff image file using GNUWin32 tiffcp.exe from command line.开发者_开发百科

The way I was doing it was to loop through the file list and build a string of file names to merge into one single variable.

strfileList = "c:folder\folder\folder\aased98-def-wsdeff-434fsdsd-dvv.tif c:folder\folder\folder\aased98-def-wsdeff-434fsdsd-axs.tif c:folder\folder\folder\aased98-def-wsdeff-434fsdsd-dxzs.tif"

Then I would just write to the command line:

tiffcp.exe strFileList results.tif

The file names are guids and so the paths are fairly long and I do not have any control to shorten them. So if I have a bunch of these documents (over 20 files or so), the length of the string variable exceeds the limits for windows command line and the merge fails.

Since this process is just merging files, my next thought was instead of writing the file names to a string, just do the merge one file at a time. So the first time the loop runs the following type of code:

tiffcp.exe file1.tif results.tif

The result is a perfect 476k tif file. But the next iteration of the loop needs to merge the second file plus the contents of the first "results" tif file. So I do this:

tiffcp.exe results.tif file2.tiff results.tif

The results each time are a blank 1K tiff file?

All the examples I can find of tiffcp.exe say file1.tif file2.tif results.tif, none use the results file to write back to itself?

Any suggestions on how to do this?


Try the -a switch to tiffcp.exe

I'm doing something similar in Python and inside my file processing loop I'm issuing the command: tiffcpp.exe -a temp.tif output.tif

works fine.


For an ASP.NET project you may want to try LibTiff.Net (free, open source, BSD license). That port of libtiff library contains tiffcp utility with source code. You may try to use it in your code.

Disclaimer: I am one of the maintainers of the library.


I believe your problem is caused by the use of results.tif as both input as output. If you increment the file name (i.e. results1.tif to results2.tif etc.) I believe it should work.

This is a rather inefficient approach (tiff1 is copied 9 times if you have 10 files). Since you refer to libtiff, you may take a look at the source of libtiff cp and check if it is worthwhile to embed it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜