Jump to content

imagepng (PHP)


zScripz

Recommended Posts

Aight, so I've made a dynamic signature, all that is fine, etc however, for some reason, even when specified to output a png image, I get a php page.

 

The code (this is a test for it, this theoretically should work):

<?php
$my_img = imagecreate( 200, 80 );
$background = imagecolorallocate( $my_img, 0, 0, 255 );
$text_colour = imagecolorallocate( $my_img, 255, 255, 0 );
$line_colour = imagecolorallocate( $my_img, 128, 255, 0 );
imagestring( $my_img, 4, 30, 25, "testing",
  $text_colour );
imagesetthickness ( $my_img, 5 );
imageline( $my_img, 30, 45, 165, 45, $line_colour );

header( "Content-type: image/png" );
imagepng( $my_img );
imagecolordeallocate( $line_color );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img );
?>

Output:

http://www.zscriptz.x10.mx/gensig/12.php

Notice that when you go there, it will say "12.php" not "12.png"

Could this be my webhost?

Any help is appreciated

Link to comment
Share on other sites

Figure it out on yourself then.

 

All I did was ask for help. What I didn't ask for is for you to vent your superiority issues on me. I don't know what you're trying to prove here, that I'm not as skilled as you in a language that I have learned very little about? Because you're right. There was absolutely no need for your comment other than to enlarge dat e-peen, which I guess you did. So congrats.

Link to comment
Share on other sites

All I did was ask for help. What I didn't ask for is for you to vent your superiority issues on me. I don't know what you're trying to prove here, that I'm not as skilled as you in a language that I have learned very little about? Because you're right. There was absolutely no need for your comment other than to enlarge dat e-peen, which I guess you did. So congrats.

I gave you an answer and I gave my own opinion. This had nothing at all to do with the language, it's basic understanding of file extensions which any computer user who has more knowledge than my grandmother should know about. It's not like I only posted the insult, I posted it together with an answer. Now either you can continue bitching about it or take it as a man and take a look at the answer I provided you with, it's up to you.

Edited by Parameter
  • Like 2
Link to comment
Share on other sites

I gave you an answer and I gave my own opinion. This had nothing at all to do with the language, it's basic understanding of file extensions which any computer user who has more knowledge than my grandmother should know about. It's not like I only posted the insult, I posted it together with an answer. Now either you can continue bitching about it or take it as a man and take a look at the answer I provided you with, it's up to you.

 

 

<?php
header('Content-Type: image/png');
?>

So tell me why this didn't work?

Link to comment
Share on other sites

<?php
header('Content-Type: image/png');
?>

So tell me why this didn't work?

 

Alright. You see, you've saved the file as .php, the file extension won't magically change so you'll need to save it as .png if you want it to look like a .png file. Now, here comes the 'tricky' part, you need to modify (or create if you don't already have it) your .htaccess file. Why? Then your .png files will be parsed as .php files. 

Link to comment
Share on other sites

EDIT: For anyone who may use this at a later, none of the above worked for me. I came up with another solution however;

 

.htaccess:

<Files fakelogo.png> //whatever file you use below
ForceType application/x-httpd-php //parses it as a php file
</Files>

Then create a fakelogo (mine was fakelogo.png), edit it and put your output method :)

Edited by zScripz
Link to comment
Share on other sites

EDIT: For anyone who may use this at a later, none of the above worked for me. I came up with another solution however;

 

.htaccess:

<Files fakelogo.png> //whatever file you use below
ForceType application/x-httpd-php //parses it as a php file
</Files>

Then create a fakelogo (mine was fakelogo.png), edit it and put your output method smile.png

You do know that's exactly what we told you to do lol

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...