Godaddy will not enable mod_gzip for me personally, so I must use headers such as this:

<?php 
ob_start ("ob_gzhandler");
header("Content-type: text/css; charset: UTF-8");
header("Cache-Control: must-revalidate");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
$offset = 60 * 60 * 24 * 7;
$ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>

Within this situation, that might be for CSS files

Anyways, how do i use by using my images? I am talking about, making the look: image.php and putting that code at the very top but using header("Content-type: image/png; charset: UTF-8"); does not work so, tell me.

GZipping images isn't worthwhile. The shrinkage is minuscule as well as negative, because image formats perform a pretty optimal job blending already. Try zipping a Digital file to determine what i'm saying.

Also, blending data that's difficult to compress is very processor intensive and you'll finish up using more assets instead of less.

The Yahoo performance rules confirm this:

Image and PDF files shouldn't be gzipped since they're already compressed. Attempting to gzip them not just wastes CPU but could potentially increase file dimensions.

also, keep in mind that when you are performing compression in PHP, a PHP process is began whenever a request is available in. You may be best not blending static assets whatsoever (unless of course you are having to pay lots of money for traffic). Compression should generally function as the web server's job, not PHP's.

Generally, gzipping Presen,PNG or JPEG images won't yield gains on the couple percent (actually, the "compressed" file might be bigger compared to original). If you want to achieve that in plain php, use mod_rewrite(or modified image Web addresses) to redirect the Web addresses to some php script. Then, outputting the look like

<?php
header('Content-Type:image/png');
echo file_get_contents('img.php');

does work (inside your experiments, you've most likely unintentionally added spaces right into a binary PNG image and therefore damaged it).