ImageMagick: Receiving invalid filename error when converting first page of pdf to jpg
- Dominant language
- C++
- Stars
- 18.7k
- Forks
- 3.1k
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 2
Description
Environment: Ubuntu 14.04, HHVM 3.5
I'm using ImageMagick to convert a pdf to a jpg in a script I have...it works fine if I give the full server path to the uploaded pdf without the page specifier, but when I add the `[0]` onto the end of the file path to specify that I only want to read the first page, it bombs out with the following error:
> "Fatal error: Uncaught exception 'ImagickException' with message
> 'Invalid filename provided' Imagick->readImage()"
I've also tried using `'/path/to/file.pdf[0]'` directly in the constructor with no luck, but without the page specifier, that also works fine.
According to what I've read in the PHP docs and tested, this code should work, but gives the error seen above when using the page specifier.
``` php
$doc_preview = new Imagick();
$doc_preview->setResolution(180,180);
$doc_preview->readImage('/path/to/file.pdf[0]');
$doc_preview->setImageFormat('jpeg');
$doc_preview->writeImage('/path/to/file.jpg');
$doc_preview->clear();
$doc_preview->destroy();
```
Contributor guide
Assessment
This issue has not been assessed yet.