jebego Posted June 5, 2010 Share Posted June 5, 2010 So, I have a very long script that I really don't think is relevant, here's the last part that actually creates this belated-file: $image_name = microtime() . ".jpeg"; $handle = fopen("mosaics/" . $image_name,"x+"); imagejpeg($final_image, "mosaics/" . $image_name); Basically, this creates an image out of the variable $final_image in the directory mosaics/ with a timestamped name. The final image size is ~10.8 mb. So, what happens... 1. I run the php script 2. The script finishes 3. I refresh the mosaics/ directory in my ftp client, but the file isn't there 4. After a few minutes, the file appears I have no idea why this is happening! Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/203928-file-appears-long-after-script-has-completed/ Share on other sites More sharing options...
dabaR Posted June 5, 2010 Share Posted June 5, 2010 Maybe you should fclose(); Quote Link to comment https://forums.phpfreaks.com/topic/203928-file-appears-long-after-script-has-completed/#findComment-1068063 Share on other sites More sharing options...
jebego Posted June 5, 2010 Author Share Posted June 5, 2010 Thanks for the response! I actually just removed the fopen() part, and the script still ran, I guess it wasn't needed However, the delay of the image creation is still happening. Quote Link to comment https://forums.phpfreaks.com/topic/203928-file-appears-long-after-script-has-completed/#findComment-1068200 Share on other sites More sharing options...
dabaR Posted June 5, 2010 Share Posted June 5, 2010 Hi there. Maybe you can try building on one of the examples here: http://php.net/manual/en/function.imagejpeg.php They seem to have some memory freeing thing at the end. Quote Link to comment https://forums.phpfreaks.com/topic/203928-file-appears-long-after-script-has-completed/#findComment-1068208 Share on other sites More sharing options...
jebego Posted June 5, 2010 Author Share Posted June 5, 2010 Thanks again for the reply! I added the imagedestroy($final_image); line to my code. It didn't fix my problem, but I should have had it there anyways, as not using it can apparently cause memory problems. Any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/203928-file-appears-long-after-script-has-completed/#findComment-1068228 Share on other sites More sharing options...
dabaR Posted June 5, 2010 Share Posted June 5, 2010 Thanks again for the reply! I added the imagedestroy($final_image); line to my code. It didn't fix my problem, but I should have had it there anyways, as not using it can apparently cause memory problems. Any other ideas? write a loop that sleeps http://ca2.php.net/sleep for a few seconds and loops until file exists http://ca2.php.net/manual/en/function.file-exists.php and prints out how many times it looped. Or something. Maybe the jpeg creation function just takes that long. :-/ Quote Link to comment https://forums.phpfreaks.com/topic/203928-file-appears-long-after-script-has-completed/#findComment-1068363 Share on other sites More sharing options...
jebego Posted June 5, 2010 Author Share Posted June 5, 2010 Yes! I looked up what you said, and ended up creating a loading bar. This send data to the browser which kept it from timing out. In the end, apparently the creating of the image takes ~10 minutes. I'll be looking for a way to make that smaller later. Thanks a ton! Quote Link to comment https://forums.phpfreaks.com/topic/203928-file-appears-long-after-script-has-completed/#findComment-1068414 Share on other sites More sharing options...
dabaR Posted June 5, 2010 Share Posted June 5, 2010 Yes! I looked up what you said, and ended up creating a loading bar. This send data to the browser which kept it from timing out. In the end, apparently the creating of the image takes ~10 minutes. I'll be looking for a way to make that smaller later. Thanks a ton! Great. What does your nickname stand for? PM if you don't want EVERYONE to know Quote Link to comment https://forums.phpfreaks.com/topic/203928-file-appears-long-after-script-has-completed/#findComment-1068416 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.