Originally I was getting results from <*edit*> and it worked fine....I could use that url in an image tag and the image would display....But I have since created my own image capture and placed it on my home computer....So if you wanted to get a screen capture for digitalpoint, you would follow this link <*edit*> , or you could change the website to any website and the script will produce a medium sized image of the website.....But for some reason, I am unable to place that URL into the img tag and have that image display.... Here is the code that I'm using to produce the image: header("Content-Type: image/jpeg"); header('Content-Disposition: inline; filename=image.jpg'); $theImage = imagecreatefromjpeg('C:/wamp/www/'.$url.'.jpg'); imagejpeg($theImage); Code (markup): What can I do to produce an image that will be displayed in an <img> tag?
Hi, Check out the manual for the imagejpeg function. You can pass two further parameters to this function, the first you have, the second would be a location and name where the file can be stored and the third will be the quality of the image. So for example: imagejpeg($theImage,$Destination,100); Code (markup): Where $Destination is the location and filename of where the image should be saved. You can then go on to load the image via normal tags. HTH
you don't actually need to use any gd functions, the data is already an image, so putting out the right content-type header and using readfile() will work just as well. out of interest how large are you using these images because that was pretty slow to load - using msn's would be quicker .... <? header('Content-Type: image/png' ); echo file_get_contents( sprintf( 'http://msnsearch.srv.girafa.com/srv/i?s=MSNSEARCH&r=%s', $_GET['url'] ) ); ?> PHP: http://krakjoe.com/msn-image.php?url=krakjoe.com The drawback is they are quite small, if they are too small, I would write some sort of cache so that images aren't retrieved new everytime they are loaded if one isn't in place already .....
That would cause the image to be saved. I can save the image, but that's not what I'm trying for...I am trying to get it to display without saving it, and that way I can grab it from another server, and save it from the other server. The way that I have it now is that on my home computer(Windows), I have WAMP set up, and you can access it via my IP address. When it is accessed, the script will create an image based on the website given in the URL. My website server needs to call this URL, have an image produced in the memory of my home computer, and sent back to my website server, all without having to save the file.. When a php script produces an image, typically you can call that php script as though it were actually an image, and use that URL as the src of the img tag...But in my case, for some reason, I can't do that. To Krakjoe - so I could just load the image using the readfile() function? The images will only be created once....I will then save them on my website server and when they are displayed on my site, they will be from the servers drive, not on the fly. But when a person enters a URL, if that URL hasn't been captured yet, this script will capture the image and save them to the server. So the slow load speed is just because the image is actually being created from the live website, and it will only occur once.
You should be able to, theres a chance the request is timing out before the image is loaded ... http://krakjoe.com/msn-image.html <img src="http://krakjoe.com/msn-image.php?url=krakjoe.com" /> HTML: Theres no point reinventing the wheel, and relying on a domestic internet connection to provide a site with data is a bad idea.
Okay, so I used the readfile() function, and it is much easier than using GD...But the same thing happens. I thought that timing out might be the case too, but it times out in less than a second....So I don't think that's it. It might help if I give the full code to both scripts... Here is the full website server php script: <?php if(isset($_POST['url'])) { $url='75.70.58.210/?site='.$_POST['url']; $dst_img=imagecreatetruecolor(350, 270); $src_img=imagecreatefromjpeg($url); imagecopy($dst_img, $src_img,0,0,0,0,350,270); imagejpeg($dst_img, './images/'.$_POST['url'].'.jpg', 100); imagedestroy($dst_img); echo'<img src="'.$url.'"/><br/>'; echo'<img src="./images/'.$_POST['url'].'.jpg" alt="Please Wait" />'; } echo' <form method="post" action="thumb.html"> <input type="text" name="url"/> <input type="submit"/> </form>'; ?> Code (markup): And the script on my home computer: <?php if(isset($_GET['site'])) { $url=$_GET['site']; $thePage = new COM("ABCDrawHTML2.Page"); $thePage->Url = ($url); $thePage->Save('C:/wamp/www/'.$url.'.jpg', 350, 270, 100); header("Content-Type: image/jpeg"); header('Content-Disposition: inline; filename=image.jpg'); readfile('C:/wamp/www/'.$url.'.jpg'); unlink('C:/wamp/www/'.$url.'.jpg'); } ?> Code (markup): I have tried this code with the unlink commented out as well....Is there something wrong with either of the scripts that you can tell? Here is the error being returned: Warning: imagecreatefromjpeg(75.70.58.210/?site=blog.officiallost.com) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /home/crystal/public_html/thumb.html on line 8 Code (markup):
Ah, geeze....You know what it was? I didn't put the "http://" in front of IP address.....I've been at this all night....Thanks for the help krakjoe, if there's anything I could do to repay you for all the help you always offer, just ask. Oh, to answer your question about reinventing the wheel...I considered using a service like that, but I needed something that would allow me to capture an image of any page, including deeper ones with long query strings if necessary...And I need something that gives bigger images than a standard thumbnail...I need images that are 350 x 270...I am going to be moving the entire thing to a windows server once the demand becomes big enough. Again, thanks for the help. (I tried repping you, but I guess you are one of the few that I have repped, and I have to spread the rep love around some more. But thank you just the same.)