I have this piece of code, taking a pdf file as argument and convert it to JPG. My problem is, when the pdf have more than one page wand create image like this : test-0.jpg, test-1.jpg etc..
with Img(filename=args['pdf'] + file, resolution=300) as pic:
pic.compression_quality = 100
pic.save(filename='images/test.jpg')
How could I say to wand to just convert the first page of the given pdf ?
Thanks !
Easiest way would be to append [0]
to the filename.
with Img(filename=args['pdf'] + file + '[0]', resolution=300) as pic:
Or you can use pic.sequence
, but that would be slower as it would require all the pages to be decoded.
with Img(filename=args['pdf'] + file, resolution=300) as pic:
with Img(pic.sequence[0]) as first_page:
first_page.save(filename='images/test.jpg')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.