View Full Version : php images
Hey, everyone. I've noticed that you can't use the getimagesize() function for an image with extension .php . . . the size was dynamically created and so I'm wary of outputting it to a saved file. Is there either a way to change the extension or a function that can calculate the size of a .php image? Thanks.
djr33
03-26-2007, 06:41 AM
Interesting.
createimagefromJPEG('myimg.php') should get you the image, then you could store that as an image variable and go from there.
image_x() and image_y() I believe hold width/height values after that.
If you must change the extension, search the forum for a method to allow .htm files to be parsed as php with the php setup on the server. It uses a line in the .htaccess file.
This could easily be used to include .jpg as well, so you could create a jpg file that is from php.
HOWEVER,
1. this would require that ALL jpgs run through the php engine, which might give a bunch of errors; careful on this
2. this might not change how it works with the getimagesize function anyway... no clue, since it would still be output with php
Interesting.
createimagefromJPEG('myimg.php') should get you the image, then you could store that as an image variable and go from there.
image_x() and image_y() I believe hold width/height values after that.
If you must change the extension, search the forum for a method to allow .htm files to be parsed as php with the php setup on the server. It uses a line in the .htaccess file.
This could easily be used to include .jpg as well, so you could create a jpg file that is from php.
HOWEVER,
1. this would require that ALL jpgs run through the php engine, which might give a bunch of errors; careful on this
2. this might not change how it works with the getimagesize function anyway... no clue, since it would still be output with php
Thanks for responding. I wouldn't have thought to try that otherwise. However, it does not work.I got this message: Warning: imagecreatefrompng() [function.imagecreatefrompng]: 'images/title.php' is not a valid PNG file in /home/jasoicom/public_html/store/index.html on line 27
Also i'm wary of changing the mime/type for the reason you said. I have other png files that should not be treated as php and i have other php files that should not be treated as png.
boxxertrumps
03-26-2007, 09:35 PM
Did you send the header as type-png?
<?php header('Content-type: image/png'); ?>
use that only in the png creation script, and you dont have to worry about the others.
Hopefully the php interpreter reads the headers instead of extention...
Another problem might be having an htaccess file that says .php is sent as html...
Did you send the header as type-png?
<?php header('Content-type: image/png'); ?>
use that only in the png creation script, and you dont have to worry about the others.
Hopefully the php interpreter reads the headers instead of extention...
Another problem might be having an htaccess file that says .php is sent as html...
Yeah, the headers are set. When I display the .php image in the browser it shows up exactly the way I want it to, so I imagine that my php is not being sent as html. It's just that when i use the getimagesize() function, it does not work.
korisu
04-04-2007, 04:41 AM
Yeah, the headers are set. When I display the .php image in the browser it shows up exactly the way I want it to, so I imagine that my php is not being sent as html. It's just that when i use the getimagesize() function, it does not work.
I'd imagine that PHP is trying to fetch the contents of the file from the server side, which would be text, of course, and not the binary content it's looking for. Just a shot in the dark - have you tried using curl to fetch the page from the client side? That way, the script will be run through the PHP engine, and curl will see binary data. Unless getimagesize() requires a file to validate against, I'd think that you could throw the curl data right into the argument.
djr33
04-06-2007, 03:16 PM
Three ideas to reroute around this--
1. Use the full URL in the argument, not just a relative path. This might work in some cases.
2. reroute through another server. That won't allow them to "talk" as php, so that's easy.
3. disable some security settings locally within the page, if possible, to not allow including pages like that.
Not sure which/if any will work.
Good luck.
2. reroute through another server. That won't allow them to "talk" as php, so that's easy.
3. disable some security settings locally within the page, if possible, to not allow including pages like that.
I'm sorry but these two suggestions confuse me. how would i reroute through another server? What security settings would i disable?
And to the previous poster . . . what's curl?
djr33
04-07-2007, 07:26 AM
PHP includes on a single server include the PHP code, not the output page. But when you include from another server (or reroute to make the same effect) you get the result included, like if you included a plain html page.
It parses the code first then includes (remotely), rather than including then parsing (same server).
This might work around it. But it's certainly a roundabout method.
I'm not sure what settings you could change. I'm just throwing it out there as something to look into, perhaps.
I don't know much about curl, but you can find info on those functions on php.net (in the search box type 'curl').
Thanks, I'll look these up. :-)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.