<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>IT Nebula</title>
    <link>https://tech-nebula.tistory.com/</link>
    <description></description>
    <language>ko</language>
    <pubDate>Thu, 14 May 2026 18:19:46 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>별나라추장</managingEditor>
    <item>
      <title>MacOS에서 linux의 Xwindow쓰기</title>
      <link>https://tech-nebula.tistory.com/entry/MacOS%EC%97%90%EC%84%9C-linux%EC%9D%98-Xwindow%EC%93%B0%EA%B8%B0</link>
      <description>&lt;p&gt;참고 URL :&amp;nbsp;&lt;a href=&quot;http://www.cyberciti.biz/faq/how-to-fix-x11-forwarding-request-failed-on-channel-0/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;http://www.cyberciti.biz/faq/how-to-fix-x11-forwarding-request-failed-on-channel-0/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1. 현재상태.&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;a. Local (장비명 A)&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;- OS : Mac OS X Yosemite (10.10.4)&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;- IP : 172.31.xxx.xxx&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;b. Remote (장비명 B)&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;- OS : CentOS 5.10&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;- IP : 172.31.xxx.xxx&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;2. 원하는 결과&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;- B에서 X-window 프로그램을 구동하면&amp;nbsp;A의 모니터에 프로그램이 실행이된다.&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;3. Step&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;a. Linux 에서 &lt;br /&gt;(http://www.cyberciti.biz/faq/how-to-fix-x11-forwarding-request-failed-on-channel-0/ 참조)&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;- /etc/ssh/sshd_config 수정&lt;/p&gt;
&lt;blockquote class=&quot;tx-quote-tistory&quot;&gt; 
&lt;pre&gt;$ sudo vi /etc/ssh/sshd_config 
--- modify two line ----
X11Forwarding yes
X11UseLocalhost no
----------------------
$ sudo /etc/init.d/sshd reload
&lt;/pre&gt;
&lt;/blockquote&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;- sudo yum install xauth&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;b. Mac OS에서&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;a. X Quartz &amp;nbsp;설치&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 6em;&quot;&gt;&lt;strike&gt;- 방법 1 :&amp;nbsp;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;Application -&amp;gt; Utility -&amp;gt; X11 실행 -&amp;gt; 2.7.7 설치 페이지로 이동 : 2.7.7에는 버그가 있다고 함.&lt;/span&gt;&lt;/strike&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 6em;&quot;&gt;- 방법 2 :&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp;http://xquartz.macosforge.org/trac/wiki/X112.7.8&lt;br /&gt;&amp;nbsp; -&amp;gt; 2.7.8_rc1 설치&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;b. Logout + Login&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;c. Appliation -&amp;gt; Utility -&amp;gt; X11 실행&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;d. X11 Menu -&amp;gt; terminal&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;e. run this command on terminal&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;&lt;table class=&quot;txc-table&quot; width=&quot;464&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:돋움;font-size:12px&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:464;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;ssh -Y deploy@172.31.224.9&amp;nbsp;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;f. X window application 실행.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>OSX</category>
      <category>sshd_config</category>
      <category>X11Forwarding</category>
      <category>xauth</category>
      <category>XQuartz</category>
      <category>Xwindow</category>
      <author>별나라추장</author>
      <guid isPermaLink="true">https://tech-nebula.tistory.com/3</guid>
      <comments>https://tech-nebula.tistory.com/entry/MacOS%EC%97%90%EC%84%9C-linux%EC%9D%98-Xwindow%EC%93%B0%EA%B8%B0#entry3comment</comments>
      <pubDate>Mon, 31 Aug 2015 19:04:37 +0900</pubDate>
    </item>
    <item>
      <title>Java ImageIO 사용 관련 속도 개선</title>
      <link>https://tech-nebula.tistory.com/entry/Java-ImageIO-%EC%82%AC%EC%9A%A9-%EA%B4%80%EB%A0%A8-%EC%86%8D%EB%8F%84-%EA%B0%9C%EC%84%A0</link>
      <description>&lt;p&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;0. 테스트 환경.&lt;/span&gt;&lt;/p&gt;&lt;blockquote class=&quot;tx-quote-tistory&quot;&gt;&lt;p&gt;OS : OS X&lt;br /&gt;CPU : 3.2G Intel Core i5&lt;br /&gt;Mem : 16GB 1600MHz DDR3&lt;br /&gt;Storage : HDD&lt;/p&gt;&lt;p&gt;source resolution : 1080 x 480&lt;br /&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;source format : PNG&lt;br /&gt;target resolution : 720 x 320&lt;br /&gt;target format : PNG&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;1. 이미지 개략 정보(width, height) 얻어오기.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;비추천)&lt;/span&gt;&lt;/p&gt;&lt;blockquote class=&quot;tx-quote-tistory&quot;&gt;







&lt;p class=&quot;p1&quot;&gt;BufferedImage &lt;span class=&quot;s1&quot;&gt;image&lt;/span&gt; = ImageIO.read(&lt;span class=&quot;s1&quot;&gt;tempFile&lt;/span&gt;);&lt;br /&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;image&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.getWidth() != 140 || &lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;image&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.getHeight() != 140) {&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; &amp;nbsp;return&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; simpleScriptResultView(&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&quot;프로필 사이즈는 140px x 140px 이어야 합니다.&quot;&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;장점) 이미지 파일이 어떤 형식인지 구분하지 않고 바로 사용이 가능하다.&lt;/p&gt;&lt;p&gt;단점 )&amp;nbsp;이미지 전체를 메모리로 불러온 후 이미지의 정보를 얻어오게 되므로 메모리 로딩에 시간이 많이 걸리게 된다.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;추천)&lt;/span&gt;&lt;/p&gt;&lt;blockquote class=&quot;tx-quote-tistory&quot;&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;Iterator&amp;lt;ImageReader&amp;gt; &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;iter&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; = ImageIO.getImageReadersBySuffix(&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;suffix&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;iter&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.hasNext()) {&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;ImageReader &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;reader&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;iter&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.next();&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;try&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;ImageInputStream &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;stream&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; FileImageInputStream(&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;orgFile&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;reader&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.setInput(&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;stream&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;reader&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.getWidth(&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;reader&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.getMinIndex());&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;reader&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.getHeight(&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;reader&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.getMinIndex());&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;} &lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; (IOException &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;) {&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;s4&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot;&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s5&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;logger&lt;/span&gt;&lt;span class=&quot;s4&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.warn(&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&quot;checkImageSize fail.&quot;&lt;/span&gt;&lt;span class=&quot;s4&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;s4&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;} &lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;finally&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;reader&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.dispose();&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;} &lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;s5&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; &amp;nbsp; logger&lt;/span&gt;&lt;span class=&quot;s4&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.debug(&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&quot;No reader found for given format: &quot;&lt;/span&gt;&lt;span class=&quot;s4&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; + &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;suffix&lt;/span&gt;&lt;span class=&quot;s4&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;장점 ) 이미지 전체를 메모리에 불러오지 않고도 헤더만 확인 후&amp;nbsp;바로 이미지의 기본 정보를 알 수 있다. 즉 훨씬 빠르다. (900kb 실사형 png에서 100배 가량의 속도향상)&lt;/p&gt;&lt;p&gt;단점) 이미지가 어떤 포맷인지 미리 확인해야 한다. (이미지 포맷은 아래에서 다시 설명.)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;2. ContentType(포맷) 확인하기&lt;/span&gt;&lt;/p&gt;&lt;p&gt;비추천)&lt;/p&gt;&lt;blockquote class=&quot;tx-quote-tistory&quot;&gt;&lt;p&gt;







&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;File orgFile = new File(path);&lt;br /&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;String contentType = orgFile.toURI().toURL().openConnection().getContentType();&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;추천)&lt;/p&gt;&lt;blockquote class=&quot;tx-quote-tistory&quot;&gt;&lt;p&gt;String contentType = &lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;URLConnection.guessContentTypeFromStream(&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; BufferedInputStream(&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; FileInputStream(&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;orgFile&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;)));&lt;/span&gt;&lt;/p&gt;







&lt;/blockquote&gt;&lt;p&gt;결과) 두 경우 모두&amp;nbsp;&amp;nbsp;contentType 에는&amp;nbsp;&amp;nbsp;&quot;image/png&quot; 형식의 contentType을 얻을 수 있다.&lt;br /&gt;파일크기 등에 따라 다르겠지만 후자가 훨씬 빠르다.&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;(900kb 실사형 png에서 10배 가량의 속도향상)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;앞 부분의 &quot;image&quot;를 떼고 뒷부분만 잘라서 사용하면 되겠다.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt; line-height: 1.5;&quot;&gt;3&lt;span style=&quot;font-size: 12pt;&quot;&gt;.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 1.5;&quot;&gt;ImageIO.read(File imageFile)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;매우 무거운 작업임. file copy보다 수 십배는 오래 걸리는 작업이므로 사용하는 부분을 최소화 하는 것이 필요함. 개인적으로 테스트를 수행한 결과는 30배 가량 차이가 났음.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;







&lt;p&gt;&lt;span style=&quot;font-size: 12pt; line-height: 1.5;&quot;&gt;4. resize image&lt;/span&gt;&lt;/p&gt;&lt;blockquote class=&quot;tx-quote-tistory&quot;&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;Image&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;img&lt;/span&gt; = &lt;span class=&quot;s2&quot;&gt;orgImg&lt;/span&gt;.getScaledInstance(&lt;span class=&quot;s2&quot;&gt;width&lt;/span&gt;, &lt;span class=&quot;s2&quot;&gt;height&lt;/span&gt;, &lt;span class=&quot;s1&quot;&gt;Image&lt;/span&gt;.SCALE_SMOOTH);&lt;br /&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;BufferedImage &lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;resized&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; BufferedImage(&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;, BufferedImage.&lt;/span&gt;&lt;span class=&quot;s4&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;TYPE_INT_RGB&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;resized&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.getGraphics().drawImage(&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;img&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;, 0, 0 , &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;s5&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;resized&lt;/span&gt;&lt;span class=&quot;s5&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;1080-&amp;gt;720의 비율로 줄이는 경우&amp;nbsp;위 코드가 ImageIO.read() 의 2배 걸렸음.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;5. ImageWriter.write(IIOImage img)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;4의 image resizing과 속도가 비슷함.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt; line-height: 1.5;&quot;&gt;6. ImageWriter 생성&lt;/span&gt;&lt;/p&gt;&lt;blockquote class=&quot;tx-quote-tistory&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;Iterator&amp;lt;ImageWriter&amp;gt; &lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;iter&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; = ImageIO.getImageWritersByFormatName(&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;saveFormat&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;ImageWriter &lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;writer&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;iter&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.next();&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;충분히 빠르다고 판단됨.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;7. &amp;nbsp;FileImageOutputStream 생성&lt;/p&gt;&lt;blockquote class=&quot;tx-quote-tistory&quot;&gt;







&lt;p class=&quot;p1&quot;&gt;FileImageOutputStream &lt;span class=&quot;s1&quot;&gt;output&lt;/span&gt; = &lt;span class=&quot;s2&quot;&gt;new&lt;/span&gt; FileImageOutputStream(&lt;span class=&quot;s1&quot;&gt;resizedFile&lt;/span&gt;);&lt;br /&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;writer&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.setOutput(&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;output&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;);&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;충분히 빠르다고 판단됨.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;8.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 1.5;&quot;&gt;File.createTempFile(String prefix, String suffix)&lt;/span&gt;&lt;/p&gt;&lt;blockquote class=&quot;tx-quote-tistory&quot;&gt;







&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;File.createTempFile(&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&quot;resized&quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; + &lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;saveFormat&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;







&lt;p&gt;의외로 많이&amp;nbsp;느림. file copy하는 정도로 느림. string 연산이 포함되었다 해도 예상을 넘음. 새로운 파일을 생성하는 것 자체가 많이 느리다고 생각이 됨.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- 2015.06.25&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Java/Image</category>
      <category>BufferedImage</category>
      <category>ImageIO</category>
      <category>imagewriter</category>
      <category>Java</category>
      <author>별나라추장</author>
      <guid isPermaLink="true">https://tech-nebula.tistory.com/2</guid>
      <comments>https://tech-nebula.tistory.com/entry/Java-ImageIO-%EC%82%AC%EC%9A%A9-%EA%B4%80%EB%A0%A8-%EC%86%8D%EB%8F%84-%EA%B0%9C%EC%84%A0#entry2comment</comments>
      <pubDate>Thu, 25 Jun 2015 16:29:23 +0900</pubDate>
    </item>
  </channel>
</rss>