imagecreatefrompng()가 투명한 영역 대신 검정색 배경을 생성하는 이유는 무엇입니까?
imagecreatefrompng()가 투명한 영역 대신 검은색 배경을 생성합니까?
PHP에서 imagecreatefrompng() 함수는 PNG 작업에 일반적으로 사용됩니다. 이미지. 그러나 이 기능을 사용하면 PNG 투명도가 단색 검정색으로 변환될 수 있는 것으로 관찰되었습니다.
이 문제를 해결하려면 imagecreatetruecolor()를 사용하여 새 캔버스를 만든 후 다음 단계를 구현할 수 있습니다.
- 검은색 할당: imagecolorallocate() 함수를 사용하여 정수 변수에 검정색을 할당합니다.
- 투명도에서 검정색 제거: imagecolortransparent() 함수를 활용하여 검은색을 투명한 색상으로 설정하여 효과적으로 보이지 않게 만듭니다.
- 알파 블렌딩 비활성화: 알파 채널을 방지하려면 false 값으로 imagealphablending()을 사용하세요.
- 알파 채널 보존 활성화: 전체 투명도 범위를 유지하려면 실제 값으로 Imagesavealpha()를 사용하세요.
By 이러한 수정 사항을 구현하면 PNG 이미지의 알파 채널 정보가 유지되어 검정색 배경으로 변환되지 않습니다. 업데이트된 코드는 다음과 유사합니다.
<code class="php"><?php // ... Before imagecreatetruecolor() $dimg = imagecreatetruecolor($width_new, $height_new); // png ?: gif // start changes switch ($stype) { case 'gif': case 'png': // integer representation of the color black (rgb: 0,0,0) $background = imagecolorallocate($dimg , 0, 0, 0); // removing the black from the placeholder imagecolortransparent($dimg, $background); // turning off alpha blending (to ensure alpha channel information // is preserved, rather than removed (blending with the rest of the // image in the form of black)) imagealphablending($dimg, false); // turning on alpha channel information saving (to ensure the full range // of transparency is preserved) imagesavealpha($dimg, true); break; default: break; } // end changes $wm = $w/$nw; $hm = $h/$nh; // ...</code>
위 내용은 imagecreatefrompng()가 투명한 영역 대신 검정색 배경을 생성하는 이유는 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

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

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

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

Stock Market GPT
더 현명한 결정을 위한 AI 기반 투자 연구

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

phparrayshandledataCollectionsefficiativeStructure; heidearecreatedwitharray () 또는 [], ac

TheObserverdesignpatternenablesautomaticnotificationofdependentobjectswhenasubject'sstatechanges.1)Itdefinesaone-to-manydependencybetweenobjects;2)Thesubjectmaintainsalistofobserversandnotifiesthemviaacommoninterface;3)Observersimplementanupdatemetho

$ _cookieisapppsuperglobalforaccessingcookiessentBythebrowser; cookiesAresetUsingSetCookie () preveroutput, readVia $ _cookie [ 'name'], values, anddeletedBySettanExpiredTimestamp, withSecurityBestFORTETTRATS, withSecurityBestPonly

interfacestodefinecontractsforUnratedClasses, theyimplesmentspecificmethods를 보장합니다

b-treeindexesarebestformostphpapplications, asysupportequalityandrangequeries, 분류, andareidealforcolumnsusedinwhere, ororderbyclauses;

공개 회원은 마음대로 액세스 할 수 있습니다. 2. 개인 회원은 반 내에 만 액세스 할 수 있습니다. 3. 보호 된 회원에게 수업 및 서브 클래스에서 액세스 할 수 있습니다. 4. 합리적 사용은 코드 보안과 유지 관리를 향상시킬 수 있습니다.

MySQLI 객체 지향 메소드 사용 : 연결을 설정하고, 전처리 업데이트 문을, 매개 변수를 바인딩하고, 결과를 실행하고 확인하고, 마지막으로 리소스를 닫습니다. 2. MySQLI 프로 시저 사용 방법 : 기능을 통해 데이터베이스에 연결하고, 진술을 준비하고, 매개 변수를 바인딩하고, 업데이트를 수행하고, 오류를 처리 한 후 연결을 닫습니다. 3. PDO 사용 : PDO를 통해 데이터베이스에 연결하고, 예외 모드를 설정하고, 사전 프로세스 SQL, 파라미터를 바인딩하고, 업데이트를 수행하고, Try-Catch를 사용하여 예외를 처리하고, 최종적으로 리소스를 해제하십시오. SQL 주입을 방지하고 사용자 입력을 확인하고 정시에 연결을 닫으십시오.

usedateTimefordatesInphp : createWitHnewDateTime (), formatwithFormat (), modifyViaAdd () ormodify (), settimezoneswithDateMezone 및 compareUsingOperatorsOrdiff () togetIntervals.
