Re: dynamic image will not print properly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I got it figured out finally!

It is so stupid with what the issue was...

My image was being created exactly as it should have been - and the code was fine. Now where my issue was: I had a line of code in there that was to prevent people from calling the script directly (had to be referred from a particular page). Well IE did not like that for printing. Even though the script acted exactly as it should have by design. I saved the image to my desktop to test it, and when opening in an image app - it would not even open (even though displaying fine in a browser). So I changed the file ext of the downloaded file to that of a text file and opened it... and what do you know - there was the error my php script generates when the page is not called properly.

So I removed that line of code (completely irrelevant to the image itself) And win/IE could print like all the other browsers could.

doh!

Dustin

On 14-Apr-05, at 5:41 PM, Richard Lynch wrote:


You'd want to http://php.net/urlencode the text, then.

<?php
  $text = "This is an example!";
  $text_url = urlencode($text);
  $url = "http://example.com/gd_script/text=$text_url/fool_ie.jpg";;
?>


On Wed, April 13, 2005 5:42 pm, DuSTiN KRySaK said:
One thing I feel is important to point out before I keep banging my
head off of the wall here...

In the URL parameter that is sent to the file, the url parameter is
just carrying text that is printed into the image. It is not actually
the image name, or anything. The image is generated in the cstl file
(which actually is the image - sends JPEG headers,etc) - with the text
on it (grabbed from the URL parameter).

d


On 13-Apr-05, at 5:03 PM, Richard Lynch wrote:

Yup.

$_PATH['x'] for the items that look like this: .../x=42/

And $PATH (without the underscore) is a string concatenation of all
elements (after the PHP script) that look like this /whatever/

So you might use something like a PHP script named 'scale' and then:

http://example.com/scale/width=100/height=100/images/subdir/ bigpic.jpg

and then you know that you want to scale the image in your
images/subdir
naemd bigpic.jpg down to 100x100 at maximum.

You'll have:
$_PATH['width'] -> 100
$_PATH['height'] -> 100
$PATH = '/images/subdir/bigpic.jpg'



On Tue, April 12, 2005 6:21 pm, DuSTiN KRySaK said:
And then all I should have to do is change my $_REQUESTS to $PATH in
hte cstl file right?


d


On 12-Apr-05, at 5:46 PM, Richard Lynch wrote:

On Mon, April 11, 2005 1:14 pm, DuSTiN KRySaK said:
hey - thanks a lot for the code snip - I am trying to use it now....

Just to confirm - the $path include file is included in the file
that
calls the cstl file - correct?

Yes.

Something like:

<?php require 'pathinfo.inc'; ?>

You can use this same technique for not just JPEG, but also PDF, SWF
(Ming) and FDF files, all of which Microsoft will screw up if you
don't
"fool" them with a URL that "looks" like static content.




d


On 5-Apr-05, at 5:57 PM, Richard Lynch wrote:

On Tue, April 5, 2005 2:26 pm, DuSTiN KRySaK said:
Hi there - I had my first crack at creating a dynamic image. The
thing
is - the image is displayed fine in the browser, but when you go
to
print it, the image is either missing, or part of it is missing.
Is
there something special needed to print a dynamic image?

What you did, *should* work just fine.

But we're talking *MICROSOFT* here!

These people do *NOT* follow standards.  Period.

Here is a code snippet used to create the image....

header("Content-type: image/jpg");
$image = imagecreatefromjpeg("template_cpn.jpg");
$red = imagecolorallocate( $image, 255,0,0 );
imagestring($image, 2, 306, 200, $couponcode, $red);
imagestring($image, 2, 306, 235, $exp, $red);
imagestring($image, 2, 175, 338, $myname, $red);
imagestring($image, 2, 175, 360, $myemail, $red);
imagejpeg($image);
imagedestroy($image);

Now the way I have it set up, is that there is a PHP file that
generates the image (the above code). Then I have a parent PHP
page
that calls that page like so:

$theurl = "cstl.php?dk=soemthinghere
echo "<img src=\"$theurl\">";

See any issues in my code or setup?

Any ideas?

Here's what you do: You make it *IMPOSSIBLE* for Microsoft to screw up.

This means you make your URL look JUST LIKE any other JPEG URL.

$theurl = "cstl/dk=somethinghere/whatever.jpg";

Step 1:
Add/Create an .htaccess file with this:
<Files cstl>
ForceType application/x-httpd-php
</Files>
This forces Apache to treat the file named 'cstl' as a PHP script.


Step 2:
Rename cstl.php to just 'cstl' (see Step 1)

Step 3:
Instead of using $_GET['dk'] do this:
$pathinfo = $_SERVER['PATH_INFO'];
$pathinfo = explode('/', $pathinfo);
//Key-Value pairs:
$_PATH = array();
//Path information buried in URL for source image sub-directories:
$PATH = array();
while (list(, $keyval) = each($pathinfo)){
$parts = explode('=', $keyval);
switch(count($parts)){
case 0: break; //do nothing with bogus extra '/' in URL
case 1: $PATH[] = $keyval;
default:
$key = $parts[0];
unset($parts[0]);
$_PATH[$key] = implode('=', $parts);
break;
}
}


Now you can use $_PATH['dk'] instead of $_GET['dk'] to get your dk
value
from the URL. You'll only change $_GET to $_PATH in cstl (formerly
cstl.php) and you're all set.


Now, there is *NO* *WAY* Microsoft can manage to screw up your URL
and
decide that it must not be a JPEG because it has GET data, or ends
in
.php
or whatever.


This same technique must be applied to PDF, FDF, SWF/Ming files if
you
want to avoid a zillion MS IE bugs related to multi-media.


So you might as well put the code for $_PATH/$PATH in an include
file.
 I
guarantee you'll need it again and again as you use more and more
multi-media in your web-site.

--
Like Music?
http://l-i-e.com/artists.htm





--
Like Music?
http://l-i-e.com/artists.htm





--
Like Music?
http://l-i-e.com/artists.htm





--
Like Music?
http://l-i-e.com/artists.htm


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux