seevaa.net

  • 본문 바로가기
  • 블로그 내 검색
  • 글 분류 목록
  • 최근 글 목록
  • 기타 블로그메뉴
  • about
  • photolog
  • socialpage
  • taglog
  • guestbook
  • admin

Image Thumbnail 만들기

from Application Programing/java/jsp 2011. 10. 14. 14:53 by seevaa Share on Twitter*
javax.media.jai API Docs
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.media.jai.JAI;
import javax.media.jai.RenderedOp;

import com.sun.media.jai.codec.FileSeekableStream;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.SeekableStream;

public class TestThumb {
	public void createImageThumb(String loadfile, String savefile, int width, int height) throws IOException 	{

		if (getDecoderCheck(loadfile)) {
			File 	    save = new File(savefile);
			RenderedOp    op = JAI.create("fileload", loadfile);
	     	BufferedImage im = op.getAsBufferedImage();

	     	if(im.getWidth()  < width) width = im.getWidth();
	     	if(im.getHeight() < height) height = im.getHeight();

			BufferedImage thumb = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
			Graphics2D 	  g2d   = thumb.createGraphics();

			g2d.drawImage(im, 0, 0, width, height, null);

			ImageIO.write(thumb, "png", save);
		}
	}
	protected boolean getDecoderCheck(String filename) {
		SeekableStream 	ss 	   = null;
		File 			file   = null;
		String[]		ext	   = null;
		String[]		images = {"gif","jpeg","png","tiff","bmp"};
		boolean 		check  = false;

		try {
			file = new File(filename);
			ss   = new FileSeekableStream(file);
			ext  = ImageCodec.getDecoderNames(ss);

			for(int i=0; i -1)
					{
						check = true;
						break;
					}
				}
			}
		}catch(Exception e) {}

		return check;
	}
}

'Application Programing > java/jsp' 카테고리의 다른 글

파라미터 관련 유틸  (0) 2011.10.10
JSTL <functions>  (0) 2011.10.10
Spring - ServletRequestUtils  (0) 2011.10.10
,

Categories

  • All (316)
    • Life Style (102)
    • Images (94)
      • Photo (94)
    • Web Standard (11)
      • HTML (0)
      • CSS (4)
      • JavaScript (7)
    • Application Programing (8)
      • java/jsp (8)
    • DataBase (5)
      • Oracle (3)
      • MySQL (0)
    • Programing Tool (2)
      • Eclipse (2)
    • Tistory (50)
      • Skin (22)
    • Fonts (12)
    • Bookmarks (31)

Recent Posts

Recent Comments

Recent Trackbacks

Archive

Links

  • http://wing91.tistory.com
  • http://xylosper.net
  • http://hanrss.co.kr
  • http://poty.cafe24.com
  • http://standardmag.org
  • http://www.raysoda.com/ess
  • http://startuu.net
  • http://cyoonk.com
  • http://trio.co.kr/webrefer/css…
  • http://designsen.net
  • http://tipography.tistory.com
  • http://twitter.com/seevaa_
  • http://tum.seevaa.net
  • http://clip.seevaa.net
subscribe to RSS

T Y T
subscribe to RSS, valid XHTML, CSS
Powered by , Designed by seevaa

  • 처음으로
  • 본문 바로가기
  • 블로그 내 검색
  • 글 분류 목록
  • 최근 글 목록
  • 기타 블로그메뉴
seevaa.net - Image Thumbnail 만들기
작성자 : 쎄바(seevaa)
연락처 : seevaa@seevaa.net

티스토리툴바