2010-04-24 4 views

답변

3

한 가지 방법은 phpThumb를 사용 할 수 있습니다. 여기

기본 참조 :

<img src="../phpThumb.php?src=path/to/image/image.jp&fltr[]=mask|path/to/mask/mask.png&f=png" alt=""> 

출력하려면 PNG로 : http://phpthumb.sourceforge.net/demo/demo/phpThumb.demo.demo.php#x31

한 간단하게 비행이 될 무언가에 새로운 이미지를 생성합니다.

이미지 업로드 후 이렇게하면 새로운 이미지를 만들 경우

은 phpThumb의 기초 밖으로 서버, 첫 번째 그림에 저장하고 나머지는 모두와 마스크 매개 변수를 설정한다 : 예를 들어

:

... 
require_once('phpThumb/phpthumb.class.php'); 

//Begin phpThumb work to resize image and create thumbnail 
$uploaddir = $_SERVER['DOCUMENT_ROOT'] . $destination; 
$uploadfile = $uploaddir . $file; 

$phpThumb = new phpThumb(); 

// set data source -- do this first, any settings must be made AFTER this call 
$phpThumb->setSourceFilename($uploadfile); 

$phpThumb->setParameter('w', 360); //change to update the picture size 
$phpThumb->setParameter('h', 470); //change to update the picture size 

$phpThumb->setParameter('fltr[]', 'mask|path/to/mask/mask.png'); //set mask 
    $phpThumb->setParameter('f', 'png'); //set png output format 

$outputdir = $_SERVER['DOCUMENT_ROOT'] . $destination; 

$output_filename = $outputdir . "masked" . $file; 

$phpThumb->setParameter('config_allow_src_above_docroot', true); 

if ($phpThumb->GenerateThumbnail()) { // this line is VERY important, do not remove it! 

    if ($phpThumb->RenderToFile($output_filename)) { 

... 
+0

굉장합니다. 가능한 한 맨손으로 뼈 코드를 제안하는 대답을 좀 더 기다릴 것이지만 이것은 수용된 대답의 후보입니다. 감사. – henrijs

+0

그것이 이보다 더 많은 뼈를 얻지 못할지 모르겠다면, 나는 그것에 관심이있을 것이다;) –