{"id":10305,"date":"2012-08-08T07:52:00","date_gmt":"2012-08-08T07:52:00","guid":{"rendered":"http:\/\/melotopia.net\/b\/?p=10305"},"modified":"2012-08-08T07:52:00","modified_gmt":"2012-08-08T07:52:00","slug":"tiff-csv-converter","status":"publish","type":"post","link":"http:\/\/melotopia.net\/b\/?p=10305","title":{"rendered":"tiff-csv converter"},"content":{"rendered":"<div class=\"desc\">\n<div class=\"tt_article_useless_p_margin\">\n<p style=\"text-align: center; clear: none; float: none;\">\n<p>\n          TIFF-CSV \ubcc0\ud658\uae30. Python 2.7\uc5d0\uc11c \uc791\uc131\ub418\uc5c8\uace0 ImageMagick\uacfc wxPython\uc774 \ud544\uc694\ud558\ub2e4.\n         <\/p>\n<div class=\"txc-textbox\" style=\"border-style: solid; border-width: 1px; border-color: rgb(231, 253, 181); background-color: rgb(231, 253, 181); padding: 10px;\">\n<p>\n           # -*- coding: utf-8 -*-<\/p>\n<p>           # This program converts 16-bit TIFF files from XCAP of EPIX CCD to .csv and .png.<br \/>\n           <br \/>\n           # This program depends on ImageMagick and wxPython.<br \/>\n           <br \/>\n           # Please make sure &#8216;convert&#8217; command is possible at the program path.<br \/>\n           <br \/>\n           # Copyright 2012, Kee Hwan Nam, APRI, GIST.\n          <\/p>\n<p>\n           # This program can be used under Gnu Public Licence version 3.\n          <\/p>\n<p>\n           # Refer to http:\/\/www.gnu.org\/copyleft\/gpl.html\n          <\/p>\n<p>\n\n<\/p>\n<p>\n           import wx<br \/>\n           <br \/>\n           import os<br \/>\n           <br \/>\n           import csv<br \/>\n           <br \/>\n           import sys<br \/>\n           <br \/>\n           reload(sys)<br \/>\n           <br \/>\n           sys.setdefaultencoding(&#8216;cp949&#8217;)<\/p>\n<p>           def convertfilter(p):<br \/>\n           <br \/>\n           a = csv.reader(open(p.replace(&#8220;\\\\\\\\&#8221;,&#8221;\\\\&#8221;), &#8216;r&#8217;), delimiter=&#8217;,&#8217;)<br \/>\n           <br \/>\n           pp = p[:-3] + &#8220;csv&#8221;<br \/>\n           <br \/>\n           ppp=open(pp, &#8216;w&#8217;)<\/p>\n<p>           index = 1<br \/>\n           <br \/>\n           flag = 0<br \/>\n           <br \/>\n           for i in a:<br \/>\n           <br \/>\n           if flag == 0:<br \/>\n           <br \/>\n           d=int(i[0].split(&#8220;:&#8221;)[1])<br \/>\n           <br \/>\n           flag+=1<br \/>\n           <br \/>\n           else:<br \/>\n           <br \/>\n           ppp.write(i[2])<br \/>\n           <br \/>\n           if index%d==0:<br \/>\n           <br \/>\n           ppp.write(&#8220;\\n&#8221;)<br \/>\n           <br \/>\n           else:<br \/>\n           <br \/>\n           ppp.write(&#8220;,&#8221;)<br \/>\n           <br \/>\n           index+=1<\/p>\n<p>           def converting(a, dirn,filen):<br \/>\n           <br \/>\n           for filens in filen:<br \/>\n           <br \/>\n           #~ print(filens)<br \/>\n           <br \/>\n           print(filens[-3:].lower())<br \/>\n           <br \/>\n           if filens[-3:].lower()==&#8221;tif&#8221;:<br \/>\n           <br \/>\n           filename = dirn+&#8221;\\\\&#8221;+filens<br \/>\n           <br \/>\n           print((&#8220;convert \\&#8221;&#8221; + filename + &#8220;\\&#8221; \\&#8221;&#8221; + filename + &#8220;.txt\\&#8221;&#8221;))<br \/>\n           <br \/>\n           os.system(&#8220;convert \\&#8221;&#8221; + filename + &#8220;\\&#8221; \\&#8221;&#8221; + filename + &#8220;.txt\\&#8221;&#8221;)<br \/>\n           <br \/>\n           os.system(&#8220;convert \\&#8221;&#8221; + filename + &#8220;\\&#8221; \\&#8221;&#8221; + filename + &#8220;.png\\&#8221;&#8221;)<br \/>\n           <br \/>\n           convertfilter(filename + &#8220;.txt&#8221;)<br \/>\n           <br \/>\n           os.system(&#8220;del \\&#8221;&#8221; + filename + &#8220;.txt\\&#8221;&#8221;)<\/p>\n<p>           class mainframe(wx.Frame):<br \/>\n           <br \/>\n           def __init__(self, *args, **kwds):<br \/>\n           <br \/>\n           kwds[&#8220;style&#8221;] = wx.DEFAULT_FRAME_STYLE<br \/>\n           <br \/>\n           wx.Frame.__init__(self, *args, **kwds)<\/p>\n<p>           dig = wx.DirDialog(None, message=&#8221;Choose data files&#8221;, style = wx.FD_MULTIPLE)<br \/>\n           <br \/>\n           if dig.ShowModal() == wx.ID_OK:<br \/>\n           <br \/>\n           pp = dig.GetPath()<br \/>\n           <br \/>\n           else:<br \/>\n           <br \/>\n           exit()<br \/>\n           <br \/>\n           os.path.walk(dig.GetPath(), converting, 0)<\/p>\n<p>           class TIFFconv(wx.App):<br \/>\n           <br \/>\n           def OnInit(self):<br \/>\n           <br \/>\n           wx.InitAllImageHandlers()<br \/>\n           <br \/>\n           main = mainframe(None, -1, &#8220;&#8221;)<br \/>\n           <br \/>\n           self.SetTopWindow(main)<br \/>\n           <br \/>\n           main.Show(True)<br \/>\n           <br \/>\n           main.Show(False)<br \/>\n           <br \/>\n           exit()<br \/>\n           <br \/>\n           return 1<\/p>\n<p>           if __name__ == &#8220;__main__&#8221;:<br \/>\n           <br \/>\n           TIFFconv = TIFFconv(0)<br \/>\n           <br \/>\n           TIFFconv.MainLoop()<br \/>\n           \n<\/p>\n<\/div>\n<p>\n\n<\/p>\n<p style=\"text-align: center; clear: none; float: none;\">\n\n<\/p>\n<p>\n\n<\/p>\n<div style=\"width:100%;margin-top:30px;clear:both;height:30px\">\n<div style=\"width:31px;float:left;\">\n<a href=\"\/toolbar\/popup\/abuseReport\/?entryId=3142\" onclick=\"window.open(this.href, 'tistoryThisBlogPopup', 'width=550, height=510, toolbar=no, menubar=no, status=no, scrollbars=no'); return false;\"><br \/>\n<img data-recalc-dims=\"1\" decoding=\"async\" alt=\"\uc2e0\uace0\" src=\"https:\/\/i0.wp.com\/t1.daumcdn.net\/tistory_admin\/static\/ico\/ico_spam_report.png\" style=\"border:0\"\/><br \/>\n<\/a>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>TIFF-CSV \ubcc0\ud658\uae30. Python 2.7\uc5d0\uc11c \uc791\uc131\ub418\uc5c8\uace0 ImageMagick\uacfc wxPython\uc774 \ud544\uc694\ud558\ub2e4. # -*- coding: utf-8 -*- # This program converts 16-bit TIFF files from XCAP of EPIX CCD to .csv and .png. # This program depends on ImageMagick and wxPython. # Please make sure &#8216;convert&#8217; command is possible at the program path. # Copyright 2012, Kee Hwan Nam, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[12],"tags":[],"class_list":["post-10305","post","type-post","status-publish","format-standard","hentry","category-12"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8o6gA-2Gd","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/melotopia.net\/b\/index.php?rest_route=\/wp\/v2\/posts\/10305","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/melotopia.net\/b\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/melotopia.net\/b\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/melotopia.net\/b\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/melotopia.net\/b\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10305"}],"version-history":[{"count":0,"href":"http:\/\/melotopia.net\/b\/index.php?rest_route=\/wp\/v2\/posts\/10305\/revisions"}],"wp:attachment":[{"href":"http:\/\/melotopia.net\/b\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/melotopia.net\/b\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10305"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/melotopia.net\/b\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}