You can improve performance by reading page after page. If you read the entire file, there will be 703 pages in memory. Your machine may not allocate as much memory, and ImageMagick will use a disk to store pixels, which will decrease performance.
You can specify the page you want to read using the FrameIndex property of the MagickReadSettings class. If you specify a page that is too high, an exception will be added (Magick.NET 7.0.0.0005 or higher is required) with a message stating that you are requesting an invalid page. You need to do this because ImageMagick does not know the number of pages of a PDF file. The following is an example of how you could do this.
int page = 0; while (true) { MagickReadSettings settings = new MagickReadSettings() { FrameIndex = page }; try { using (MagickImage image = new MagickImage(@"C:\YourFile.pdf", settings)) { // Do something with the image.... } } catch (MagickException ex) { if (ex.Message.Contains("Requested FirstPage is greater")) break; else throw; } page++; }
source share