2017-05-13 1 views
1

PHP에서 gd로 이미지 출력하기, Bitnami WAMP, Windows 10? 파일로 만들 수는 있지만 출력이되지 않습니다.Bitnami WAMP, Windows 10에서 gd로 이미지를 출력하는 방법은 무엇입니까?

파일이 없기 때문에 오류가 발생합니다. http://localhost/type705b/public/index.php/test/img11.
호스트 (public/index.php/test/img11) 다음의 매개 변수는 컨트롤러 작업에 액세스하는 데 사용됩니다. 실제 파일은

어쩌면 내가 .htaccess를 수정하고 이미지 지원을 활성화해야 /type705b/src/Bundle/Resources/views/test/img/ImageOutputingError.php

은? 내 경우

Options -MultiViews 
Options -Indexes 

Options +FollowSymlinks 
RewriteEngine on 
RewriteBase /public/ 
IndexIgnore * 

RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
RewriteCond %{ENV:REQUEST_FILENAME} !-d 
RewriteCond %{ENV:REQUEST_FILENAME} !-f 
RewriteCond %{ENV:REQUEST_FILENAME} !-l 

RewriteRule ^index.php?(.+)$ index.php?url=$1 [QSA,L] 

이 이미지는, "이 오류를 포함하고 있기 때문에 이미지 http://localhost/type705b/public/index.php/test/img11, 표시 할 수 없습니다"파이어 폭스에서 오류가 발생하고, 탐색기에서 십자가와 작은 사각형을 표시 크롬과 오페라에 표시되지 않습니다.

경위는이 마크 업을 (내가 IMG || 오류 "|| 몸을 만든) 코드로 표시합니다 보여줍니다

|| body style="margin: 0px; background: #0e0e0e;"> 
|| img style="-webkit-user-select: none;background-position: 0px 0px, 10px 10px;background-size: 20px 20px;background-image:linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%),linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%);" src="http://localhost/type705b/public/index.php/test/img11"> 
</body> 
배경 이미지가 난 내 스크립트에서 사용하는 어떤 색상이 없습니다

: # 0000FF].

ImageOutputingError.php

$width = 150; 
$height = 150; 
$img = imagecreate($width, $height); 

//Create image background 
//$white = ImageColorAllocate($img, 255, 255, 255); 
//$black = ImageColorAllocate($img, 0, 0, 0); 
//$red = ImageColorAllocate($img, 255, 0, 0); 
$blue = imagecolorallocate($img, 0, 0, 255); 
ImageFill($img,$width,$height,$blue); 

header('Content-type: image/gif'); 
imagegif($img); 
imagedestroy($img); 
imagecolordeallocate($img, $blue); 

ImageCreatingWorking.php

012,327,834,714,748 번들

/* * 용은 phpinfo()

PHP 버전 5.6.30 < ...>

GD 지원

GD 버전을 활성화 (호환 2.1.0)

FreeType Support enabled 
FreeType Linkage with freetype 
FreeType Version 2.7.0 
GIF Read Support enabled 
GIF Create Support enabled 
JPEG Support enabled 
libJPEG Version 9 compatible 
PNG Support enabled 
libPNG Version 1.5.26 
WBMP Support enabled 
XPM Support enabled 
libXpm Version 30411 
XBM Support enabled 
WebP Support enabled 

*/

답변

0

imagecolordeallocate($img, $blue); (마지막 줄). $img을 이미 파괴 했으므로 쓸모가 없으며 경고 메시지가 나타납니다. 비록이 코드가 어쨌든 나를 위해 일하고있다.

도움이되지 않는 경우 PHP 파일의 header('Content-type: image/gif'); 행을 주석 처리하십시오. 그러면 브라우저에 이미지 내용이 텍스트로 표시되고 거기에 오류가 표시되지 않는지 확인하십시오. 일반적으로 GIF87a로 시작해야하고 읽을 수없는 횡설수설로 시작해야합니다. "GIF87a"이전에 무언가가 있다면 브라우저가 이미지를 표시하지 못하게됩니다. 예를 들어, 일부 PHP 경고 또는 통지.

코드 자체는 괜찮아 보이고 나를 위해 일하고 있습니다.

.htaccess 파일과 관련이 없어야합니다. 브라우저가 이미지를보고 있다는 것을 알게되면 브라우저가 올바른 URL에 도달했으며 콘텐츠 유형 헤더를 수신했음을 의미합니다. 그러나 내용은 어떤 이유로 든 유효한 GIF가 아닙니다.

+0

감사합니다. 'ImageOutputingError.php'를 localhost 디렉토리에 놓고 직접 URL localhst/ImageOutputingError.php를 사용합니다 -이 방법이 효과적입니다. 자체 프레임 워크 작업에 포함시키는 경우에만 작동합니다.대부분의 헤더는 잘못 보내지 만 어딘가에는 이미지가 표시되지 않습니다. –

관련 문제