Okay, I'm going to preface this with the disclaimer that I have no code that I've tried, primarily because I can't find anything or figure out anything that might work in this particular case. Be gentle with the downvotes lol
I have an application that uses the Cropit image cropping plugin. This passes an image back to my controller in Base64 format where I process it and save it. The issue is with some images the save is quite lengthy, 6-20 seconds. Long enough that a user might think the application has hung up.
So my client thought a progress bar would be nice, which I agree it's better than a spinner or just making the user wait. The problem is I don't know how to get the progress of the save, or if I even can. If it were an iterative process it would be easy, but since this is just one event that as far as I can tell doesn't return any sort of progress I'm baffled as to how to do this.
This is the code that is running for so long (ps any tips on how to speed this process are welcome as well!) The script does some resizing and other database functions, but I've done some benchmarking and narrowed it down to the actual save function. For the record the previous iteration of this code did things a little differently and used file_put_contents. The time result was exactly the same.
if(imagejpeg($image_p,$new_dir.$postData['page_image'],$compression)) {
$return['updated'] = "updated";
$return['image_src'] = 'assets/dist/img/user_images/'.$page.'/'.$postData['page_image'];
$return['image_name'] = $postData['page_image'];
$this->clean_up_images($page);
} else {
$return['updated'] = "error";
}
Oddly (to me at least) images that are complex take much longer to save, regardless of actual file size. So for example a photo of a letterhead that is 3mb will take 200-300 milliseconds, a photo of a bunch of people that is only 1.7mb will take 5-6 seconds.
Help?