I have a working image script which resizes a image and writes words on them, it currently gets images from within my webserver...

However I'm wondering if when used from home instead of getting pictures from within my webserver via the URL would it be possible to get the original image from my hard drive???

    Er... if it's running on the web server would it not be getting the images from the server's own hard drive? Why would the web server need a URL?

    Need more detail.

      Weedpacket;10883398 wrote:

      Er... if it's running on the web server would it not be getting the images from the server's own hard drive? Why would the web server need a URL?

      Need more detail.

      URL or path to the directly own my web servers hard drive, which ever way you want to look at it YES.

      My question is however, on my own personal PC. Via Path C:\My Doc Settings\ etc etc

      Will this work?

        NZ_Kiwis wrote:

        URL or path to the directly own my web servers hard drive, which ever way you want to look at it YES.

        URLs are not filepaths. If it's one then it's not the other.

        Will this work?

        have you tried it?

          Weedpacket;10883492 wrote:

          URLs are not filepaths. If it's one then it's not the other.

          have you tried it?

          URL or filepaths, either will work.

          yes and my code does not work. Hence my post, maybe there is another way of doing it.

            Maybe we need to see the code that does not work?

              NZ_Kiwis wrote:

              maybe there is another way of doing it.

              I'm sure there is, and there's probably even another way that will actually work.

              Notice that I'm giving you about the same amount of information as you're giving us.

                NogDog;10883506 wrote:

                Maybe we need to see the code that does not work?

                This is my working code, I've tried to change filename to be

                "
                $filename = "C:\Photos\$file";
                

                But it does not work even thought this is the file location on my hard drive....

                
                $file = $_GET['file'];
                
                $filename = "http://www.mysite.com/photos/$file";
                $degrees = $_GET['degrees'];
                
                // Content type
                header('Content-type: image/jpeg');
                
                // Get new sizes
                list($width, $height) = getimagesize($filename);
                $newwidth = 570;
                $newheight = 365;
                
                // Load
                $thumb = imagecreatetruecolor($newwidth, $newheight);
                $source = imagecreatefromjpeg($filename);
                
                
                imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
                
                
                define("DS_OFFSET", 5);
                define("DS_STEPS", 10);
                define("DS_SPREAD", 1);
                
                $width  = $newwidth + DS_OFFSET;
                $height = $newheight + DS_OFFSET;
                
                $image = imagecreatetruecolor($width, $height);
                $background = array("r" => 255, "g" => 255, "b" => 255);
                $step_offset = array("r" => ($background["r"] / DS_STEPS), "g" => ($background["g"] / DS_STEPS), "b" => ($background["b"] / DS_STEPS));
                
                $current_color = $background;
                
                for ($i = 0; $i <= DS_STEPS; $i++) {
                  $colors[$i] = imagecolorallocate($image, round($current_color["r"]), round($current_color["g"]), round($current_color["b"]));
                
                  $current_color["r"] -= $step_offset["r"];
                  $current_color["g"] -= $step_offset["g"];
                  $current_color["b"] -= $step_offset["b"];
                }
                
                imagefilledrectangle($image, 0,0, $width, $height, $colors[0]);
                
                for ($i = 0; $i < count($colors); $i++) {
                imagefilledrectangle($image, DS_OFFSET, DS_OFFSET, $width, $height, $colors[$i]);
                $width -= DS_SPREAD;
                $height -= DS_SPREAD;
                }
                
                imagecopymerge($image, $thumb, 0,0, 0,0, $newwidth, $newheight, 100);
                
                $image2 = imagerotate($image, $degrees, 0);
                imagejpeg($image2, "", 90);
                
                
                ?>
                

                  C😛hotos$file is not a valid filepath on any operating system. I'm guessing it should be C:\Photos$file. Also, if I understand you right, do you want the remote web server to be able to resize images on your computer? If so, then this is not possible. You need to upload the image first to the web server. If you have a second copy of the script on a web server running on your local computer, then make sure you are using the correct path (as I mentioned above) and also that the GD extension is correctly installed for PHP.

                    Ashley Sheridan;10883562 wrote:

                    C😛hotos$file is not a valid filepath on any operating system. I'm guessing it should be C:\Photos$file. Also, if I understand you right, do you want the remote web server to be able to resize images on your computer? If so, then this is not possible. You need to upload the image first to the web server. If you have a second copy of the script on a web server running on your local computer, then make sure you are using the correct path (as I mentioned above) and also that the GD extension is correctly installed for PHP.

                    Thank you!!!!!

                    I didn't think so just wanted to remove the idea from my head

                      NZ_Kiwis wrote:
                      $filename = "http://www.example.com/photos/$file";

                      If that's a URL to the same server that is running the script then you're making a mistake. The web server is having to send a request to the web server to read the file from the hard drive and serve it back to the web server that requested it.

                      Use a file path instead.
                      (And I changed the URL as well. Compare http&#58;//www.mysite.com/ and http&#58;//www.example.com/)

                        Weedpacket;10883594 wrote:

                        If that's a URL to the same server that is running the script then you're making a mistake. The web server is having to send a request to the web server to read the file from the hard drive and serve it back to the web server that requested it.

                        Use a file path instead.
                        (And I changed the URL as well. Compare http://www.mysite.com/ and http://www.example.com/)

                        So if I used the file path against the URL then it would save on bandwidth?

                          It would be a darn bit faster, as file access is much quicker than http access.

                            It would require a lot less memory, since the web server doesn't have to handle two entire requests instead of just the one.

                            Here's what you're doing at the moment. It's evening, you're sitting at your desk with a mug of coffee in your hand. You want to take a sip. You get up, walk to the kitchen, open the kitchen cupboard, get a mug out, pour the coffee from the one mug into the other, take a sip from the other mug, pour the coffee back into the one mug, wash the other mug, put it back in the cupboard, and walk back to your desk.

                            The earlier version of that scenario had you getting a friend to come in and take the sip for you....

                              so I should locate the file this way??

                              $filename = "../travel/$file";
                              

                                You can do it that way, or you might get an absolute path with something like:

                                $filename = $_SERVER['DOCUMENT_ROOT'] . "/travel/$file";
                                
                                  Write a Reply...