댓글 검색 목록

[php] 썸네일 이미지 만들기

페이지 정보

작성자 운영자 작성일 15-05-18 21:46 조회 1,973 댓글 0

<?php

$max_width = 150;

$image = imageCreateFromJPEG("s&le.jpg");

$current_width = imagesx($image);

$current_height = imagesy($image);

// Set thumbnail width

$widths = array($current_width, $max_width);

$new_width = min($widths);

// Calculate thumbnail height from given width to maintain ratio

$new_height = $current_height / $current_width*$new_width;

// Create new image using thumbnail sizes

$thumb = imagecreatetruecolor($new_width,$new_height);

// Copy original image to thumbnail

imagecopyres&led($thumb,$image,0,0,0,0,$new_width,$new_height,imagesx($image),imagesy($image));

// Show thumbnail on screen

imagejpeg($thumb, "thumbnail.jpg");

imagedestroy($thumb);

?> 

댓글목록 0

등록된 댓글이 없습니다.

웹학교 로고

온라인 코딩학교

코리아뉴스 2001 - , All right reserved.