Current location: Hot Scripts Forums » General Community » Script Requests » Output A Text Page As Image, Via PHP...


Output A Text Page As Image, Via PHP...

Reply
  #1 (permalink)  
Old 01-05-06, 07:41 AM
w2n's Avatar
w2n w2n is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Question Output A Text Page As Image, Via PHP...

Hi,

I want to know, whether it is possible or not. If yes, then how? With complete details, and an example code, if possible...

I have some PHP pages, which are normal HTML pages (text/html). We want to create a little PHP snippet, by which, these pages will be shown as Image in the browsers. The image can be JPG, or GIF, or PNG.

I think, by some little coding in the HTTP_HEADER part of the PHP, at the very start of the page, this could be achieved.

Please help us...

Thanks in advance...


SWAGATO
Reply With Quote
  #2 (permalink)  
Old 01-05-06, 07:54 AM
YourPHPPro's Avatar
YourPHPPro YourPHPPro is offline
Community VIP
 
Join Date: Aug 2003
Posts: 430
Thanks: 0
Thanked 0 Times in 0 Posts
Reply With Quote
  #3 (permalink)  
Old 01-05-06, 08:22 AM
w2n's Avatar
w2n w2n is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up Thanks...

Hi,

Thanks for the 3 links. However, if you could help me little more, it would be great!.

Like, suppose, I have a normal HTML file... "index.html". Now, suppose, I want to make it "index.php", but, when it will be opened in browser, it would be a JPG.

Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
BODY CONTENT GOES HERE...
</body>
</html>

Now, tell me, what should the code in PHP, which I should place at the very top of the page, so that, this page could be shown as a JPG in the browser.

Thanks...


SWAGATO
Reply With Quote
  #4 (permalink)  
Old 01-05-06, 09:01 AM
YourPHPPro's Avatar
YourPHPPro YourPHPPro is offline
Community VIP
 
Join Date: Aug 2003
Posts: 430
Thanks: 0
Thanked 0 Times in 0 Posts
How about this - swiped from the link(s) above...

Code:
<?php
   // Normally $filename would depend on $_GET, etc.
   $filename = '/photoalbum/images/test.jpg';
   header('Content-type: image/jpeg');
   header('Content-transfer-encoding: binary');
   header('Content-length: '.filesize($filename));
   readfile($filename);
?>
Reply With Quote
  #5 (permalink)  
Old 01-05-06, 09:12 AM
w2n's Avatar
w2n w2n is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,

Thanks for code!

However, what I wanted is somehow different. You have called a separate JPG (/photoalbum/images/test.jpg). But, what I want is...

Put a PHP code at the very top of EVERY PHP page in my server, which output THAT page as a JPG, when someone will access it through their browser. Not any other JPG file. The browser should output THAT SAME page as a JPG, which is actually a PHP page.

I hope, I have made it clearer now!

Thanks anyway...


SWAGATO
Reply With Quote
  #6 (permalink)  
Old 01-05-06, 09:46 AM
michaeln michaeln is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Look here
http://us3.php.net/manual/en/function.imagettfbbox.php
and here
http://us3.php.net/manual/en/function.imagettftext.php

You will need the GD and FreeType libraries installed....

Michael
Reply With Quote
  #7 (permalink)  
Old 01-05-06, 09:58 AM
w2n's Avatar
w2n w2n is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation

Hi,

Many thanks for the reply! However, it seems that none is getting what I wanted to say.

To better explain it, let me ask something...

I have a HTML/PHP page. And, at the very top of the page, if I will write header('Content-type: image/jpeg'); as a PHP code, will the page will be returned to browser as a JPG image? Or nothing will happen?

Please let me know...


SWAGATO
Reply With Quote
  #8 (permalink)  
Old 01-05-06, 10:09 AM
Richard's Avatar
Richard Richard is offline
Wannabe Coder
 
Join Date: Sep 2005
Location: Oxford, UK
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Basically you're attempting to convert your page (HTML after executing PHP) to a large JPG image?
Reply With Quote
  #9 (permalink)  
Old 01-05-06, 10:16 AM
w2n's Avatar
w2n w2n is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
YES!

That's what I want.

Now, could anybody say, how can I do that?


SWAGATO
Reply With Quote
  #10 (permalink)  
Old 01-05-06, 10:22 AM
YourPHPPro's Avatar
YourPHPPro YourPHPPro is offline
Community VIP
 
Join Date: Aug 2003
Posts: 430
Thanks: 0
Thanked 0 Times in 0 Posts
Moved to script requests forum...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Script to Insert Dynamic Txet into Jpg image cyborlink PHP 3 05-05-05 05:26 AM
Request: text form and image uploading script (PHP) YHIEddie Script Requests 0 03-18-05 05:22 PM
How to Make my Php output write static Html files cebuy PHP 1 02-04-05 05:52 AM
Putting PHP into a HTML page? PigeonHead HTML/XHTML/XML 5 01-24-05 02:22 PM
Form -> text file -> php variables Bonzo PHP 1 06-16-04 07:37 AM


All times are GMT -5. The time now is 11:53 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.