Yeah, i don't have anything at all in the page other than code, because i was just testing it out. Here's the whole page:
<?php
include_once("Image.php");
$i = new Image(null);
$rslt=$i->RandomImg("667");
?>
And here's the whole Image class:
<?php
class Image{
public $img;
public $imgsize;
function __construct($img){
if(@$img != false){
switch (exif_imagetype($img)){
case "1":
$this->img=imagecreatefromgif($img);
break;
case "2":
$this->img=imagecreatefromjpeg($img);
break;
case "3":
$this->img=imagecreatefrompng($img);
break;
case "6":
$this->img=imagecreatefromwbmp($img);
break;
default:
echo "<h1>Not a valid image type!: $img</h1>";//<meta http-equiv='refresh' content='4;/?action=EditProfile&name=EditProfileAll'><link rel='stylesheet' href='/css/default.css'/><h1>This is not a supported image type. Go back and do it again! ".exif_imagetype($_FILES['avatar']['tmp_name'])."</h1>";
exit;
}
$this->imgsize = getimagesize($img);
}
}
function __desctruct(){
imagedestroy($image);
imagedestroy($this->img);
}
function Resize($path){// Resize
if ($this->imgsize[0] > 1 && $this->imgsize[1] > 1){
$N = 600;
if (($N / $this->imgsize[0]) < ($N / $this->imgsize[1])){
$ratio = $N / $this->imgsize[0];
$w = $this->imgsize[0] * $ratio;
$h = ceil($this->imgsize[1] * $ratio);
}else if (($N / $this->imgsize[0]) > ($N / $this->imgsize[1])){
$ratio = $N / $this->imgsize[1];
$w = ceil($this->imgsize[0] * $ratio);
$h = $this->imgsize[1] * $ratio;
}else{
echo "<h1>Cannot resize this image! It's probably because i can't detect the image header. Save this image again with your image editor, and then try to upload it. Dump:<br/> $path<br/>$this->img<br/><br/></h1>";
//exit;
}
$image = imagecreatetruecolor($w,$h);
imagecopyresampled ($image, $this->img, 0, 0, 0, 0, $w, $h, $this->imgsize[0], $this->imgsize[1]);
imagejpeg($image,$path.".jpg",100);
//echo "<meta http-equiv='refresh' content='2;/?action=EditProfile&name=EditProfileAll'><link rel='stylesheet' href='/css/default.css'/><h1>Avatar Successfully uploaded and resized!</h1>";
}else{
//echo "<h1>Cannot resize this image! It's probably because i can't detect the image header. Save this image again with your image editor, and then try to upload it.</h1>";
//echo "<h1>Width:".$this->imgsize[0]." <br/>Height: ".$this->imgsize[1]." <br/>Type: ".$this->imgsize[2]." <br/>String Size: ".$this->imgsize[3]." <br/>MIME type: ".$this->imgsize[4]." </h1>";
exit;
}
}
function Preview($path){// Resize
if ($this->imgsize[0] > 1 && $this->imgsize[1] > 1){
$N = 160;
if (($N / $this->imgsize[0]) < ($N / $this->imgsize[1])){
$ratio = $N / $this->imgsize[0];
$w = $this->imgsize[0] * $ratio;
$h = ceil($this->imgsize[1] * $ratio);
}else if (($N / $this->imgsize[0]) > ($N / $this->imgsize[1])){
$ratio = $N / $this->imgsize[1];
$w = ceil($this->imgsize[0] * $ratio);
$h = $this->imgsize[1] * $ratio;
}else{
echo "<h1>Cannot create thumbnail! It's probably because i can't detect the image header. Save this image again with your image editor, and then try to upload it. Dump:<br/> $path<br/>$this->img<br/><br/></h1>";
//exit;
}
$image = imagecreatetruecolor($w,$h);
imagecopyresampled ($image, $this->img, 0, 0, 0, 0, $w, $h, $this->imgsize[0], $this->imgsize[1]);
imagejpeg($image,$path.".jpg",100);
//echo "<meta http-equiv='refresh' content='2;/?action=EditProfile&name=EditProfileAll'><link rel='stylesheet' href='/css/default.css'/><h1>Avatar Successfully uploaded and resized!</h1>";
}else{
//echo "<h1>Cannot resize this image! It's probably because i can't detect the image header. Save this image again with your image editor, and then try to upload it.</h1>";
//echo "<h1>Width:".$this->imgsize[0]." <br/>Height: ".$this->imgsize[1]." <br/>Type: ".$this->imgsize[2]." <br/>String Size: ".$this->imgsize[3]." <br/>MIME type: ".$this->imgsize[4]." </h1>";
exit;
}
}
function S(){// ?
}
function C(){// Crop
}
function Watermark($file,$wmloc){// Watermark
$watermark = imagecreatefrompng($wmloc);
imagecopy($this->img ,$watermark, 0 , 0 , 0 , 0 , 348 , 46 );
imagejpeg($this->img,$file,100);
}
function RandomImg($str){
header("Content-type: image/png");
$im = imagecreatetruecolor(130, 60);
$red = imagecolorallocate($im, 255, 0, 0);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $black);
$font = '../resources/Vera.ttf';
imagettftext($im, 20, 0, 13, 36, $red, $font, "sdffgsdffff");
imagepng($im);
imagedestroy($im);
}
}
?>
And here's the output if you take OUT the header, it appears to be a valid png?:
�PNG ��� IHDR�������<���%�����IDATx���Mh\U���bA���J$��X$� �).čEJ����j��Z��BJ A�(��EJP�5�P?("RA!�Zcuju\\N�p�����y��b8ϛy�'��9��!� � � � � ����-ZER/�9�B�y�ku#Y��׽�����H� �S��K��4~�;h�h�F�W7��P��a(�9ĕ�jMXM�m��Re�M�yy�&l\��f��,�=��\�M�v�g�����PtG��_Ռ�\����F([�K����8�V��tQ͛]�i��"u�ȫ�*O�$-�1� �pOqvi�ɶ��`�S���3���4�h{uTq:I'SWCL�x�0B#wv`��;� '�9i"w-/��f|uW?���(�a�� Kt/��T�4�I�iv����'sҁ"�FȨ0 s� �,���\�I��T�$�K9�"ӹ�FȨ0 iro1�po�l'8_�!e�+#��D͏�0BF�i�b���V�5��[i+�n���Š;-�Qѫ�2���x��%>���=K5Y�e��;-�Ju��E�X�)� s���+x9��]%[6�22�;KԲqu���ڇ_���bs��8�@��3ɫ/'�#�!��4�]\;Ѷ��=�U��ӽ_L��9���y�0Be���0���s<�J��*��������Z�}�n;je�AN�w���<9�tA+{ s���*3�3[�5����>�J_J��*�M����<������y��h���4{�{���/�M��'ٛ�4�k�·��ɹ���g�5�/�f7���Aُ�'�w��Fw�%��ү;�L����no�0\��e�f��%7lv��7~�oz� ��)��,�orwAAAAAAAl4�v�.:�@�����IEND�B`�