ive seen on some places people using php to create dynamic images with the extension of .png
does anyone know how this is done?

also i have an image set up but with a variable within the call
would i have to change to something else if i got it to work as a .png file instead of .php?

    You could generate the image, save it to a PNG file, and use it as a regular image, or you might be able to do somehting strange with Apache's ForceType directive, it is most likely a VERY BAD idea though.

      You could parse .png files as PHP, but, as superwormy said, that is a bad idea. It may end up screwing up preexisting PNGs.

        thats the image, can save it as a filename, but its still got to call the php file first and then change to the image file. I was just wondering how them dynasig people do it.

        but ah well, might do a bit of research into it
        thanks anyway

        =edit=
        hehe, even this forum doesnt like [img] files to have non-ordinary file extensions

          16 days later

          in the mime types where you put:
          *.php | php.exe
          to parse it as a php file could you do the same with a php image file?
          like:
          dynaimg.png | php.exe
          so it only parses that single png file as php?

            header("Content-Type: image/png");
            header("Content-Disposition: inline; filename=whatever.png");

            the content-disposition header will have your file appear as "whatever.png" in the download/save-as prompt verses "script-that-made-whatever.php"

            EDIT: sorry, I don't think I answered the question correctly.

            If you are wanting the image to actually appear as .png (in the source or right-click-properties) then I think you have to dynamically create the image first (saving to file) and reference the resulting image later.

            The bad thing is that may be useless if you are wanting to externally link to a php-generated-png without running any php first ... there is probably something we're missing, though (there is a solution for almost any problem ... some are just hard as heck to find!!)

              normally for an image in my signature i would use:

              but the problem is that with some forums they only accept images from the normal file extensions (.jpg .gif .png etc)
              so you would have to point the image to a png file, that is really a php file in disguise

                instead of having Apache process all .png's with php (which may cause some problems) you can try dropping a .htaccess file in the directory of your png-generating-php script with something like:

                RewriteEngine on
                RewriteRule ^(.*)\.png $1.php [NC]
                

                Now I haven't ever used Mod Rewrite myself, so please excuse me if that is not proper.

                From my understanding that will allow you to link to whatever.png and Apache will internally convert all requests for whatever.png to whatever.php

                  Write a Reply...