Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: php images

  1. #1
    Join Date
    May 2006
    Location
    New York City
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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.

  2. #2
    Join Date
    May 2006
    Location
    New York City
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So . . . nobody?

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    May 2006
    Location
    New York City
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    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.

  5. #5
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    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...
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  6. #6
    Join Date
    May 2006
    Location
    New York City
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by boxxertrumps View Post
    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.

  7. #7
    Join Date
    Apr 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by kosi View Post
    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.

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  9. #9
    Join Date
    May 2006
    Location
    New York City
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    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?

  10. #10
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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').
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •