In this PHP section, the external link image in titlepic is automatically downloaded. I want it to automatically scale down to a fixed size image during download. How can I modify it? The PHP section {code...} automatically downloads the external link image in titlepic. I want it to automatically scale down to a fixed size image during download. How can I modify it?
$ Sqltext = "SELECT id, titlepic FROM {$ dbtbpre} _ article where titlepic like 'HTTP: // % 'order by id limit 1 "; $ r = $ empire-> fettings ($ sqltext); if ($ r) {$ path = ECMS_PATH. "uploads \ pic \"; $ yname = $ path. basename ($ r [titlepic]); $ filename = '/uploads/pic /'. basename ($ r [titlepic]); if (file_exists ($ yname) & filesize ($ yname)> 0) {echo ($ yname. "already exists
"); // The file exists // exit ('s: '. filesize ($ yname);} else {echo ($ yname ."
Down :". $ r [titlepic]); $ string = ReadFiletext ($ r [titlepic]); WriteFiletext_n ($ yname, $ string); sleep (1 );} $ sqltext = "update {$ dbtbpre} _ article set titlepic = '$ filename' where id =' $ r [id] '"; echo ('
'. $ Sqltext); $ empire-> query ($ sqltext); sleep (1); echo"
";} Else {// echo"
"; Echo" completed ";} db_close (); $ empire = null;
Reply content:
In this PHP section, the external link image in titlepic is automatically downloaded. I want it to automatically scale down to a fixed size image during download. How can I modify it?
$ Sqltext = "SELECT id, titlepic FROM {$ dbtbpre} _ article where titlepic like 'HTTP: // % 'order by id limit 1 "; $ r = $ empire-> fettings ($ sqltext); if ($ r) {$ path = ECMS_PATH. "uploads \ pic \"; $ yname = $ path. basename ($ r [titlepic]); $ filename = '/uploads/pic /'. basename ($ r [titlepic]); if (file_exists ($ yname) & filesize ($ yname)> 0) {echo ($ yname. "already exists
"); // The file exists // exit ('s: '. filesize ($ yname);} else {echo ($ yname ."
Down :". $ r [titlepic]); $ string = ReadFiletext ($ r [titlepic]); WriteFiletext_n ($ yname, $ string); sleep (1 );} $ sqltext = "update {$ dbtbpre} _ article set titlepic = '$ filename' where id =' $ r [id] '"; echo ('
'. $ Sqltext); $ empire-> query ($ sqltext); sleep (1); echo"
";} Else {// echo"
"; Echo" completed ";} db_close (); $ empire = null;
This is not the western cms. Your need should be to save the remote image and auto scale crop it. Then write a function to add it to WriteFiletext_n. Google can use imagecopyresampled directly or install ImageMagick, which is better than the GD class library.