How to track the progress of the conversion, PDF to JPG using Imagick?

I am using PHP exec () for -convert Image Magick and I want to convert more than one page.

Given that this may take several minutes, I need some kind of progress indicator to track the conversion.

Any ideas how I could do this?

+4
source share
2 answers

Well, you cannot really track the progress of a single conversion. but you can do something like the following for exmaple when you want to convert multiple documents:

  • number of pages = 100%
  • current page number / number of pages * 100 = progress in percent

therefore, after each processed page, you can update the course. you can write information to a file or database (associated with a user session for multi-user software) and query the status using ajax reqeust for a php script that reads this / db file.

+3
source

The solution to this problem is message queues. I was looking for sample code on how to use Pheanstalkd (PHP framework for beanstalkd) here

This example shows how to have a sender who queues jobs, an employee who pulls jobs out of the queue, and an observer who follows the jobs (this part essentially does what you ask).

You can download Pheanstalk from here

0
source

Source: https://habr.com/ru/post/1489250/


All Articles