php - Using cURL to download images to ZipArchive -


I to am trying to download images in a Jiparkiv, social networking sites via their API, I have the following I'm using the code:

  ... download public functionAlbumjip ($ album_name, $ photo) {$ zip = new ziparchive (); $ Album_name = $ this- & gt; _cleanAlbumName ($ album_name); $ Filename = 'album.zip'; $ File = tempnam (Photo, "{$ album_name} -") '. Zip '; ($ Zip- & gt; open ($ file, zipfi + :: created) === true) {foreach ($ photos as $ photos) {$ image = $ photo ['pid'] '.jpg' ; $ Binary = $ this- & gt; _getImage ($ photo ['src']); $ Zip- & gt; Add Frame String ($ image, $ binary); } $ Output = print_a ($ zip, true); $ Zip- & gt; near (); Exit ('Zip Safe. & Lt; br / & gt; & lt; a href = "javascript: history.go (-1);" & gt; Go back to the album overview & lt; / a & gt; ); } Else (die ( 'ZIP fail. ");}} Private function _getImage ($ img) {If (function_exists (' curl_init ')) {$ ch = curl_init ($ img); Curl_setopt ($ CH, CURLOPT_HEADER, 0) ; Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, 1); Curl_setopt ($ CH, CURLOPT_BINARYTRANSFER, 1); $ Kchchadeta = Krl_akssi ($ ch); curl_close ($ ch); return $ raw data;  

P>

You should first download all the images, verify that they are okay, then at the end of time Re-download.

You can use images in parallel

Remember, the key to speed up anything is that it is detected that what is the barrier. Is this file zipping? You can use a basic binary And if that's the case then open it out. Is this picture download? Is it the size of the images?

You should do some profiling, even if it's only the time () To see which work is taking longest time


Comments