Jump to content

imagepng (PHP)


Recommended Posts

Posted

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

Posted

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.

Posted (edited)

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
Posted

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?

Posted
<?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. 

Posted (edited)

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
Posted

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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