Re: [PHP] dynamic image will not print properly
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] =
Re: [PHP] dynamic image will not print properly
On Mon, April 11, 2005 5:48 pm, DuSTiN KRySaK said: On 11-Apr-05, at 5:05 PM, Richard Lynch wrote: On Mon, April 11, 2005 3:04 pm, DuSTiN KRySaK said: Fourth: On the broken server, take *OUT* the header() lines in your script, and surf directly to the image URL. If you see PHP messages, well, fix your script to get rid of them. If you see a bunch of weird characters, that's what it *should* be -- Pretty much the same as you would see if you opened up a real JPEG in a text editor. I get the proper JPG results. As I said earlier - the output is only messed in the win/ie combo while printing. Sorry, forgot that part... Okay, try this. Take your HTML page, scrape down as a static page, upload it, and try to print the static page with the static image. Pehaps GD, PHP, and everything else have *nothing* to do with this. Maybe the *PRINTER* just chokes on some specific JPEG images, dynamic or not. If so, then you are looking for a new printer driver, or documentation of known issues with that printer and printing JPEGs of particular characteristics. The more I think about this, the more likely it is that the printer just doesn't like that JPEG, period. If the browsers likes it just fine... -- 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
Re: [PHP] dynamic image will not print properly
I just wanted to add something to this I moved the script over to another host to test, and it worked fine there. So to me that says it should be something to do with the host... now is there anything in the php.ini that could inflict this kind of behavior? 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic image will not print properly
On Mon, April 11, 2005 3:04 pm, DuSTiN KRySaK said: I moved the script over to another host to test, and it worked fine there. So to me that says it should be something to do with the host... now is there anything in the php.ini that could inflict this kind of behavior? anything covers a lot of ground... First: Did you use the SAME browser and computer to surf in both cases. If not, re-do the test with the SAME browser and computer. Second: Is GD even installed on the non-working server? Use ?php phpinfo();? Either you see GD in one of the mini-tables or you don't have GD and it ain't gonna work. Third: Compare the *VERSIONS* of GD on both servers. Then PHP versions. Then Apache versions. Fourth: On the broken server, take *OUT* the header() lines in your script, and surf directly to the image URL. If you see PHP messages, well, fix your script to get rid of them. If you see a bunch of weird characters, that's what it *should* be -- Pretty much the same as you would see if you opened up a real JPEG in a text editor. Fifth: Re-test on the server and desktop where it didn't work -- It's possible that between test 1 and 2 somebody updated the browser out from under you (like Microsoft auto-update, for example) -- 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
Re: [PHP] dynamic image will not print properly
Replying below. On 11-Apr-05, at 5:05 PM, Richard Lynch wrote: On Mon, April 11, 2005 3:04 pm, DuSTiN KRySaK said: I moved the script over to another host to test, and it worked fine there. So to me that says it should be something to do with the host... now is there anything in the php.ini that could inflict this kind of behavior? anything covers a lot of ground... First: Did you use the SAME browser and computer to surf in both cases. If not, re-do the test with the SAME browser and computer. exact same computer. Second: Is GD even installed on the non-working server? Use ?php phpinfo();? Either you see GD in one of the mini-tables or you don't have GD and it ain't gonna work. It is installed - as the image displays in the browser as it should, but the print output is all messed up. Third: Compare the *VERSIONS* of GD on both servers. Then PHP versions. Then Apache versions. Checking out from the host. Fourth: On the broken server, take *OUT* the header() lines in your script, and surf directly to the image URL. If you see PHP messages, well, fix your script to get rid of them. If you see a bunch of weird characters, that's what it *should* be -- Pretty much the same as you would see if you opened up a real JPEG in a text editor. I get the proper JPG results. As I said earlier - the output is only messed in the win/ie combo while printing. Fifth: Re-test on the server and desktop where it didn't work -- It's possible that between test 1 and 2 somebody updated the browser out from under you (like Microsoft auto-update, for example) The tests were done back to back and always testing with the exact same setup. Did one test on another win/ie box just to see if it was the local machine that was fubar - however it had the same results. d -- 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
[PHP] dynamic image will not print properly
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? 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? d -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic image will not print properly
To test, cstl.php?dk=somethinghere and try to print that? Maybe your browser is configured to NOT print images (or bakckground) ? Maybe your printer is textonly (just kidding) Tada Andy On Tuesday 05 April 2005 23:26, DuSTiN KRySaK wrote: 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? 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? d -- Registered Linux User Number 379093 -- Feel free to check out these few php utilities that I released under the GPL2 and that are meant for use with a php cli binary: http://www.vlaamse-kern.com/sas/ -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re:Re: [PHP] dynamic image will not print properly
I wondered that myself, but all the other (not dynamic) images print fine! d On 5-Apr-05, at 4:51 PM, [EMAIL PROTECTED] wrote: From: Andy Pieters [EMAIL PROTECTED] Date: April 5, 2005 2:35:22 PM PDT To: php-general@lists.php.net Subject: Re: [PHP] dynamic image will not print properly To test, cstl.php?dk=somethinghere and try to print that? Maybe your browser is configured to NOT print images (or bakckground) ? Maybe your printer is textonly (just kidding) Tada Andy
Re: [PHP] dynamic image will not print properly
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php