/**
* 기능: 썸네일 생성
* 작성자: phpox
* 날짜: 2007년 5월 17일 목요일 09:57:05 CST
*/
class CreatMiniature
{
//공용 변수
var $srcFile="" //원본 이미지
var $ echoType; //출력 이미지 형식, 링크--파일로 저장되지 않음--파일로 저장됨
var $im=""; //임시 변수
var $srcW=""; 원본 이미지 너비
var $srcH=""; //원본 이미지 높이
//변수 설정 및 초기화
function SetVar($srcFile,$echoType)
{
if (!file_exists ($ srcFile)){
echo '소스 이미지 파일이 없습니다!'
exit()
}
$this->srcFile=$srcFile
$this; ->echoType =$echoType;
$info = "";
$data = GetImageSize($this->srcFile,$info)
스위치($data[2])
{
사례 1:
if(!function_exists("imagecreatefromgif")){
echo "GD 라이브러리는 GIF 형식 이미지를 사용할 수 없습니다. Jpeg 또는 PNG 형식을 사용하세요!반환 a> ;";
exit();
}
$this->im = ImageCreateFromGIF($this->srcFile);
break;
사례 2:
if ( !function_exists("imagecreatefromjpeg")){
echo "GD 라이브러리는 jpeg 형식의 이미지를 사용할 수 없습니다. 다른 형식의 이미지를 사용하세요!返回";
exit();
}
$this->im = ImageCreateFromJpeg($this->srcFile);
break;
사례 3:
$this->im = ImageCreateFromPNG($this->srcFile)
break
}
$this->srcW=ImageSX($this-> ;im);
$this->srcH=ImageSY($this->im)
}
//生成扭曲型缩图
function Distortion($toFile,$toW, $toH)
{
$cImg=$this->CreatImage($this->im,$toW,$toH,0,0,0,0,$this->srcW,$this ->srcH);
return $this->EchoImage($cImg,$toFile)
ImageDestroy($cImg)
//生成按比例缩放的缩图🎜>함수 비례 배분($toFile,$toW,$toH)
{
$toWH=$toW/$toH
$srcWH=$this->srcW/$this->srcH;
if($toWH{
$ftoW=$toW;
$ftoH=$ftoW*($this->srcH/$this->srcW);
}
그 외
{
$ftoH=$toH
$ftoW=$ftoH*($this->srcW/$this->srcH);
if($this->srcW>$toW||$this->srcH>$toH)
{
$cImg=$this->CreatImage($this->im, $ftoW,$ftoH,0,0,0,0,$this->srcW,$this->srcH)
return $this->EchoImage($cImg,$toFile);
이미지파괴($cImg);
}
else
{
$cImg=$this->CreatImage($this->im,$this->srcW,$this->srcH,0,0, 0,0,$this->srcW,$this->srcH);
return $this->EchoImage($cImg,$toFile);
이미지파괴($cImg);
}
}
//生成最小裁剪后的缩图
function Cut($toFile,$toW,$toH)
{
$toWH=$toW/$toH ;
$srcWH=$this->srcW/$this->srcH;
if($toWH{
$ctoH=$toH;
$ctoW=$ctoH*($this->srcW/$this->srcH);
}
그밖에
{
$ctoW=$toW;
$ctoH=$ctoW*($this->srcH/$this->srcW);
}
$allImg=$this->CreatImage($this->im,$ctoW,$ctoH,0,0,0,0,$this->srcW,$this-> srcH);
$cImg=$this->이미지 생성($allImg,$toW,$toH,0,0,($ctoW-$toW)/2,($ctoH-$toH)/2,$toW,$ 에H);
return $this->EchoImage($cImg,$toFile);
이미지파괴($cImg);
ImageDestroy($allImg);
}
//生成背景填充的缩图
함수 BackFill($toFile,$toW,$toH,$bk1=255,$bk2=255,$bk3=255)
{
$toWH=$toW/$toH;
$srcWH=$this->srcW/$this->srcH;
if($toWH{
$ftoW=$toW;
$ftoH=$ftoW*($this->srcH/$this->srcW);
}
그밖에
{
$ftoH=$toH;
$ftoW=$ftoH*($this->srcW/$this->srcH);
}
if(function_exists("imagecreatetruecolor"))
{
@$cImg=ImageCreateTrueColor($toW,$toH);
if(!$cImg)
{
$cImg=ImageCreate($toW,$toH);
}
}
else
{
$cImg=ImageCreate($toW,$toH);
}
$backcolor = imagecolorallocate($cImg, $bk1, $bk2, $bk3); //좋은 색상
ImageFilledRectangle($cImg,0,0,$toW,$toH,$backcolor);
if($this->srcW>$toW||$this->srcH>$toH)
{
$proImg=$this->CreatImage($this->im, $ftoW,$ftoH,0,0,0,0,$this->srcW,$this->srcH);
if($ftoW{
ImageCopy($cImg,$proImg,($toW-$ftoW)/2,0,0,0,$ftoW,$ftoH);
}
else if($ftoH{
ImageCopy($cImg,$proImg,0,($toH-$ftoH)/2,0,0,$ftoW, $ftoH);
}
else
{
ImageCopy($cImg,$proImg,0,0,0,0,$ftoW,$ftoH);
}
}
else
{
ImageCopyMerge($cImg,$this->im,($toW-$ftoW)/2,($toH-$ftoH)/2 ,0,0,$ftoW,$ftoH,100);
}
return $this->EchoImage($cImg,$toFile);
이미지파괴($cImg);
}
function CreatImage($img,$creatW,$creatH,$dstX,$dstY,$srcX,$srcY,$srcImgW,$srcImgH)
{
if(function_exists("imagecreatetruecolor) "))
{
@$creatImg = ImageCreateTrueColor($creatW,$creatH);
if($creatImg)
ImageCopyResampled($creatImg,$img,$dstX,$dstY,$srcX,$srcY,$creatW,$creatH,$srcImgW,$srcImgH);
그 외
{
$creatImg=ImageCreate($creatW,$creatH);
ImageCopyReised($creatImg,$img,$dstX,$dstY,$srcX,$srcY,$creatW,$creatH,$srcImgW,$srcImgH);
}
}
else
{
$creatImg=ImageCreate($creatW,$creatH);
ImageCopyReised($creatImg,$img,$dstX,$dstY,$srcX,$srcY,$creatW,$creatH,$srcImgW,$srcImgH);
}
$creatImg를 반환합니다.
}
//输出图文,link---只输流,不保存文件。file--保存为文件
function EchoImage($img,$to_File)
{
switch( $this->echoType)
{
case "link":
if(function_exists('imagejpeg')) return ImageJpeg($img);
그렇지 않으면 ImagePNG($img)를 반환합니다.
휴식;
케이스 "파일":
if(function_exists('imagejpeg')) return ImageJpeg($img,$to_File);
그렇지 않으면 ImagePNG($img,$to_File)를 반환합니다.
휴식;
}
}
}
?>
以上就介绍了php生成略图 php生成略图的类代码, 包括了php生成缩略图사이드의 内容, 希望对PHP教程有兴趣的朋友帮助。

TheBesteptroachForendingeMailsInphPisusingThephPmailerlibraryDuetoitsReliability, featurerichness 및 reaseofuse.phpmailersupportssmtp, proversDetailErrorHandling, supportSattachments, andenhancessecurity.foroptimalu

의존성 주입 (DI)을 사용하는 이유는 코드의 느슨한 커플 링, 테스트 가능성 및 유지 관리 가능성을 촉진하기 때문입니다. 1) 생성자를 사용하여 종속성을 주입하고, 2) 서비스 로케이터 사용을 피하고, 3) 종속성 주입 컨테이너를 사용하여 종속성을 관리하고, 4) 주입 종속성을 통한 테스트 가능성을 향상 시키십시오.

phpperformancetuningiscrucialbecauseitenhancesspeedandefficies, thearevitalforwebapplications.1) cachingsdatabaseloadandimprovesResponsetimes.2) 최적화 된 databasequerieseiesecessarycolumnsingpeedsupedsupeveval.

theBestPracticesForendingEmailsSecurelyPinphPinclude : 1) usingecureconfigurations와 whithsmtpandstarttlSencryption, 2) 검증 및 inputSpreverventInseMeStacks, 3) 암호화에 대한 암호화와 비도시를 확인합니다

tooptimizephPapplicationsperperperperperperperperperferferferferferferferferferferperferferperferperperferferfercations.1) ubsicationScachingwithApcuTeDucedAtaFetchTimes.2) 최적화 된 ABASEABASES.3)

expendencyInphpisaDesignpatternpattern thatenhances-flexibility, testability 및 maintainabilitable externaldenciestoclasses.itallowsforloosecoupling, easiertesting throughmocking 및 modulardesign, berrequirecarefultructuringtoavoid-inje

PHP 성능 최적화는 다음 단계를 통해 달성 할 수 있습니다. 1) 스크립트 상단에 require_once 또는 include_once를 사용하여 파일로드 수를 줄입니다. 2) 데이터베이스 쿼리 수를 줄이기 위해 전처리 문 및 배치 처리를 사용하십시오. 3) Opcode 캐시에 대한 Opcache 구성; 4) PHP-FPM 최적화 프로세스 관리를 활성화하고 구성합니다. 5) CDN을 사용하여 정적 자원을 배포합니다. 6) 코드 성능 분석을 위해 Xdebug 또는 Blackfire를 사용하십시오. 7) 배열과 같은 효율적인 데이터 구조를 선택하십시오. 8) 최적화 실행을위한 모듈 식 코드를 작성하십시오.

opCodeCachingsIntIficInlyIntImeRimproveSphpperformanceCachingCompileDCode, retingServerLoadandResponsEtimes.1) itStoresCompyledPhpCodeInMemory, BYPASSINGPARSINGCOMPILING.2) UseOpCacheSettingParametersInphP.Ini, likeMoryConsAncme AD


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

SecList
SecLists는 최고의 보안 테스터의 동반자입니다. 보안 평가 시 자주 사용되는 다양한 유형의 목록을 한 곳에 모아 놓은 것입니다. SecLists는 보안 테스터에게 필요할 수 있는 모든 목록을 편리하게 제공하여 보안 테스트를 더욱 효율적이고 생산적으로 만드는 데 도움이 됩니다. 목록 유형에는 사용자 이름, 비밀번호, URL, 퍼징 페이로드, 민감한 데이터 패턴, 웹 셸 등이 포함됩니다. 테스터는 이 저장소를 새로운 테스트 시스템으로 간단히 가져올 수 있으며 필요한 모든 유형의 목록에 액세스할 수 있습니다.

안전한 시험 브라우저
안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

SublimeText3 영어 버전
권장 사항: Win 버전, 코드 프롬프트 지원!

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기