Jump to content

Non-PHP Files


Onetoomanysodas

Recommended Posts

Firstly, I wouldn't really recommend doing it the way your thinking as in doing so all .png files will be processed as php.

 

Having said that, all you need do is add...

 

AddType application/x-httpd-php .php .png

 

to your .htaccess file. This forces all .png files to be processed as php. Then your image script....

 

<?php

  header("content-type: image/png");
  imagecreatefrompng('image.png');
  imagepng($image);
  imagedestroy($image);

?>

 

A better method may be to have a simple image.php file which is passed a filename via the url....

 

<?php

  if (isset($_GET['img'])) {
    header("content-type: image/png");
    imagecreatefrompng($_GET['img']);
    imagepng($image, '', 75);
    imagedestroy($image);
  }

?>

 

You can then have a mod_rewrite rule which will allow urls like /images/foo.png to display foo.png as processed via php. Something like....

 

RewriteRule ^/images/(.*)$ image.php?img=$1 [L]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.