Dobakat Posted January 17, 2007 Share Posted January 17, 2007 For starters, I would like to clarify that I understand what I want might no be possible and that I would not get dissapointed. Secondly, I understand it might be very hard, but I am willing to try it.Here is the scoop:I have my website in which I want to display an image that is roughly around 1000x1000 pixels. This picture is the 'map'. Each members on my site have a position, lets say 500,500. I want to display the same image, in the 100x100 pixel box. The only parts I would like to show are from 450,450 to 550,550. This being x,y of pixels. I know how to make it get the users position, but not how to only show a 10000pixel square(the 100x100 box) with the user's position as center, without any shrinkings.I don't if this is possible with palne html and php code. I understand that it might use another coding language, if it does, let me know which one it is. Quote Link to comment Share on other sites More sharing options...
scott212 Posted January 17, 2007 Share Posted January 17, 2007 look into the GD library. It's generally installed on every commercial hosting server. The function is imagecopyresampled(). Use it in conjunction with other image operations but any decent image resize php tutorial will give you a lot of info on it. Quote Link to comment Share on other sites More sharing options...
mattbridges Posted January 17, 2007 Share Posted January 17, 2007 Hi,I use GD to handle image resizing on my site. I've found it to be really good, but it can be a bit memory hungry with larger images.If you have problems, you might need to ini_set('memory_usage', xxM); where xx = the max amount of memory your page consumes.If you're on a shared server you might not be able to ini_set('memory_usage) GD tends do die rather quietly we've found so if you find you're getting a blank page i'd check the memory usage first :-)Depending on the version of php you've got you might be able to user memory_get_usage or memory_peak_usage()Cheers Matt Quote Link to comment Share on other sites More sharing options...
Dobakat Posted January 17, 2007 Author Share Posted January 17, 2007 I have been trying to figure out the imagecopyresampled() functions and I have only found examples that rize the image, not that buts an specific part of the mage and then display it.. anyone has an example I can see? Quote Link to comment Share on other sites More sharing options...
Dobakat Posted January 17, 2007 Author Share Posted January 17, 2007 I figured it out, thanks. That functio does work for what I wanted. Quote Link to comment Share on other sites More sharing options...
Dobakat Posted January 17, 2007 Author Share Posted January 17, 2007 I always had a problem with headers, and this is no exception.My function: [code] function getMaps($x,$y ){ //Get srcx and srcy $src_x=$x-5; $src_y=$y-5; $src_image="images/ice.jpg"; header('Content-type: image/jpeg'); $dst_image= imagecreatetruecolor(200,200); $dst_x=0; $dst_y=0; $dst_h=200; $dst_w=200; $src_w=10; $src_h=10; $image = imagecreatefromjpeg($src_image); imagecopyresampled ($dst_image, $image, $dst_x, $dst_y,$src_x,$src_y,$dst_w, $dst_h, $src_w, $src_h ); imagejpeg($dst_image, null, 100); }[/code]Works fine a page on its own, but when I added it to my function.php page and then tried to call t from another page I get this header message:Warning: Cannot modify header information - headers already sent by (output started at .../city.php:11) in .../functions.php on line 106As you can see my problem here is this line of the function:[code] header('Content-type: image/jpeg');[/code]My header is:[code]<head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><script type="text/javascript" src="main_functions.js"></script></head>[/code]I tried changing my header to [code]<head><meta http-equiv="Content-Type" content="image/jpeg; charset=ISO-8859-1" /><script type="text/javascript" src="main_functions.js"></script></head>[/code]but it does not work. Like I said, I am not good at headers, can someone help me!? Quote Link to comment Share on other sites More sharing options...
Dobakat Posted January 17, 2007 Author Share Posted January 17, 2007 <BUMP> can somone help me with my header issue?thanks in advance. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.