{"id":983,"date":"2020-09-07T00:53:04","date_gmt":"2020-09-06T16:53:04","guid":{"rendered":"https:\/\/www.yohz.com\/blogs\/?p=983"},"modified":"2020-09-07T00:59:12","modified_gmt":"2020-09-06T16:59:12","slug":"merge-or-combine-tiff-files","status":"publish","type":"post","link":"https:\/\/www.yohz.com\/blogs\/2020\/09\/07\/merge-or-combine-tiff-files\/","title":{"rendered":"Merge or combine TIFF files"},"content":{"rendered":"<p>We had a user who recently asked if <a href=\"https:\/\/www.yohz.com\/sbe_details.htm\">SQL Blob Export<\/a> is able to merge or combine the extracted single-page TIFF files from her database into multi-page TIFF files.\u00a0 This feature isn&#8217;t built-in, but we have provided an external command line application (<a href=\"https:\/\/www.yohz.com\/downloads\/misc\/mergetiff.zip\">MergeTiff<\/a>) that you can freely use to perform the same task.<\/p>\n<p>You can use <a href=\"https:\/\/www.yohz.com\/downloads\/misc\/mergetif.zip\">MergeTiff<\/a> on any tif files, including those extracted using <a href=\"https:\/\/www.yohz.com\/siv8_details.htm\">SQL Image Viewer<\/a>, <a href=\"https:\/\/www.yohz.com\/sbe_details.htm\">SQL Blob Export<\/a>, and <a href=\"https:\/\/www.yohz.com\/aole_details.htm\">Access OLE Export<\/a>.\u00a0 It is important that the extracted files use names that group the pages into the right order.<\/p>\n<p>For e.g. the default naming convention for exported files in <a href=\"https:\/\/www.yohz.com\/siv8_details.htm\">SQL Image Viewer<\/a> is row and column index, so assuming each row in your result set only had 1 blob column, your exported files would be named this way:<\/p>\n<p style=\"padding-left: 40px;\">0001_0001.tif<br \/>\n0002_0001.tif<br \/>\n0003_0001.tif<br \/>\n&#8230;<\/p>\n<p>This isn&#8217;t going to help <a href=\"https:\/\/www.yohz.com\/downloads\/misc\/mergetiff.zip\">MergeTiff<\/a>\u00a0determine how to group the files.\u00a0 What you need is a &#8216;grouping&#8217; value e.g. say a CustomerID column that identifies the customer each image belongs to.\u00a0 We then use this naming convention in <a href=\"https:\/\/www.yohz.com\/siv8_details.htm\">SQL Image Viewer<\/a>\/ <a href=\"https:\/\/www.yohz.com\/sbe_details.htm\">SQL Blob Export<\/a>\/ <a href=\"https:\/\/www.yohz.com\/aole_details.htm\">Access OLE Export<\/a>:<\/p>\n<p style=\"padding-left: 40px;\">&lt;CustomerID&gt;_&lt;%row:0000%&gt;<\/p>\n<p>and our exported files may be named this way:<\/p>\n<p style=\"padding-left: 40px;\">A00123_0001.tif<br \/>\nA00123_0002.tif<br \/>\nA00123_0003.tif<br \/>\nC72186_0006.tif<br \/>\nD12472_0007.tif<br \/>\nE88822_0004.tif<br \/>\nE88822_0005.tif<\/p>\n<p>In this way, we know that for customer A00123, we need to merge 3 files, for customer E88822, we need to merge 2 files, and so on.<\/p>\n<p>To use <a href=\"https:\/\/www.yohz.com\/downloads\/misc\/mergetiff.zip\">MergeTiff<\/a>, you need to provide at least 1 parameter:<\/p>\n<ul>\n<li>the search pattern for the files to process using the -i\u00a0 parameter e.g.<\/li>\n<\/ul>\n<p style=\"padding-left: 40px;\">MergeTiff.exe <strong>-i &#8220;g:\\exported images\\*.tif&#8221;\u00a0<\/strong><\/p>\n<h3><\/h3>\n<h3>Other parameters supported by MergeTiff:<\/h3>\n<h4>-o<\/h4>\n<p>this is the output folder to store the merged files.\u00a0 If not provided, the merged files will be stored in the same folder as the source files.\u00a0 If you want to store the merged files in a different folder, you would need to provide the -o parameter e.g.<\/p>\n<p>MergeTiff.exe -i &#8220;g:\\exported images\\*.tif&#8221; <strong><strong>-o &#8220;g:\\exported images\\merged\\&#8221;<\/strong><\/strong><\/p>\n<h4>-d<\/h4>\n<p>this is the delimiter that the source file name uses to separate elements, default value is _<\/p>\n<p>In our example, our file name elements use the underscore character e.g. _.\u00a0 You might use another symbol e.g.<\/p>\n<p>A00123-0001.tif<br \/>\nA00123-0002.tif<br \/>\nA00123-0003.tif<br \/>\nE88822-0004.tif<\/p>\n<p>In this case, you need to provide the -d parameter and the delimiter character e.g.<\/p>\n<p>MergeTiff.exe -i &#8220;g:\\exported images\\*.tif&#8221; -o &#8220;g:\\exported images\\merged\\&#8221; <strong>-d &#8220;-&#8220;<\/strong><\/p>\n<h4>-g<\/h4>\n<p>this is the grouping element index, default value is 1.\u00a0 In our example, the grouping element is the first element i.e. all the characters before the first delimiter i.e.<\/p>\n<p>A00123<br \/>\nE88822<br \/>\nC72186<br \/>\nD12472<br \/>\nE88822<\/p>\n<p>If instead our file named had been named this way:<\/p>\n<p>scanneddocsA00123_invoice1005_A00123_0001.tif<br \/>\nscanneddocsA00123_invoice1005_A00123_0002.tif<br \/>\nscanneddocsA00123_invoice1006_A00123_0003.tif<br \/>\nscanneddocsC72186_invoice1008_C72186_0006.tif<br \/>\nscanneddocsD12472_invoice2010_D12472_0007.tif<\/p>\n<p>and we still wanted to merge all documents belonging to the same customer, then our grouping element is the 3rd element, and we would need to use the -g parameter e.g.<\/p>\n<p>MergeTiff.exe -i &#8220;g:\\exported images\\*.tif&#8221; -o &#8220;g:\\exported images\\merged\\&#8221; <strong>-g 3<\/strong><\/p>\n<h4>-n<\/h4>\n<p>this is the naming element index, default value is 1.\u00a0 Following on from the above example, supposing we merge our files by invoice number instead of customer code, we would need to use both the -g and -n parameters e.g.<\/p>\n<p>MergeTiff.exe -i &#8220;g:\\exported images\\*.tif&#8221; -o &#8220;g:\\exported images\\merged\\&#8221; <strong>-g 2 -n 2<br \/>\n<\/strong><\/p>\n<h4>-ow<\/h4>\n<p>use this parameter to overwrite any existing files of the same name<\/p>\n<p>If you want <a href=\"https:\/\/www.yohz.com\/downloads\/misc\/mergetiff.zip\">MergeTiff<\/a>\u00a0to overwrite any existing files, use the -ow parameter e.g.<\/p>\n<p>MergeTiff.exe -i &#8220;g:\\exported images\\*.tif&#8221; <strong>-ow<\/strong><\/p>\n<h4>-r<\/h4>\n<p>use this parameter to also process files in the input path subfolders<\/p>\n<p>To process files recursively beneath the input path, use the -r parameter e.g.<\/p>\n<p>MergeTiff.exe -i &#8220;g:\\exported images\\*.tif&#8221; <strong>-r<\/strong><\/p>\n<p>You can download MergeTiff from <a href=\"https:\/\/www.yohz.com\/downloads\/misc\/mergetiff.zip\">here<\/a>.<\/p>\n<div class=\"fcbkbttn_buttons_block\" id=\"fcbkbttn_left\"><div class=\"fcbkbttn_like \"><fb:like href=\"https:\/\/www.yohz.com\/blogs\/2020\/09\/07\/merge-or-combine-tiff-files\/\" action=\"like\" colorscheme=\"light\" layout=\"button\"  size=\"small\"><\/fb:like><\/div><div class=\"fb-share-button  \" data-href=\"https:\/\/www.yohz.com\/blogs\/2020\/09\/07\/merge-or-combine-tiff-files\/\" data-type=\"button\" data-size=\"small\"><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>We had a user who recently asked if SQL Blob Export is able to merge or combine the extracted single-page TIFF files from her database into multi-page TIFF files.\u00a0 This feature isn&#8217;t built-in, but we have provided an external command line application (MergeTiff) that you can freely use to perform the same task. You can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[17,44,11],"tags":[18,48,12],"_links":{"self":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/983"}],"collection":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/comments?post=983"}],"version-history":[{"count":8,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/983\/revisions"}],"predecessor-version":[{"id":991,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/983\/revisions\/991"}],"wp:attachment":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/media?parent=983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/categories?post=983"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/tags?post=983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}