digitalmars.D.learn - How to convert PDF to PNG using DMagick?
- tastyminerals (8/8) Sep 25 2021 When I need to convert a PDF image in console, I use ImageMagick:
- Mike Wey (11/18) Sep 25 2021 It's been awhile since i used it myself, but if imagemagick supports
- Tejas (10/28) Sep 25 2021 For his personal use you think there's any problem just using
- tastyminerals (3/27) Sep 25 2021 Yes, this is an option although I want to use it as a dub
When I need to convert a PDF image in console, I use ImageMagick: `convert doc.pdf doc.png` command. Today I found ImageMagick D bindings -- DMagick https://github.com/MikeWey/DMagick. I would like to script this operation using DMagick. However, I couldn't find any code samples and was not able to find anything about image conversion in official ImageMagick C API docs either (maybe I need to spend more time though). But maybe someone has code samples of how to convert PDF?
Sep 25 2021
On 25-09-2021 15:21, tastyminerals wrote:When I need to convert a PDF image in console, I use ImageMagick: `convert doc.pdf doc.png` command. Today I found ImageMagick D bindings -- DMagick https://github.com/MikeWey/DMagick. I would like to script this operation using DMagick. However, I couldn't find any code samples and was not able to find anything about image conversion in official ImageMagick C API docs either (maybe I need to spend more time though). But maybe someone has code samples of how to convert PDF?It's been awhile since i used it myself, but if imagemagick supports reading PDF's this might work: ``` Image pdf = new Image("./test.pdf") pdf.write("./test.png") ``` DMagick hasn't been updated in a while so it will probably not work with newer versions of ImageMagick. -- Mike Wey
Sep 25 2021
On Saturday, 25 September 2021 at 15:14:50 UTC, Mike Wey wrote:On 25-09-2021 15:21, tastyminerals wrote:For his personal use you think there's any problem just using `std.process`? I mean: ```d rdmd --eval='import std.process; auto dmd = execute(["convert", `Screenshot from 2021-09-12 18-14-22.png` , `hello.pdf`]);' ``` I don't see why go beyond that if it's guaranteed that the user has `convert` on their machineWhen I need to convert a PDF image in console, I use ImageMagick: `convert doc.pdf doc.png` command. Today I found ImageMagick D bindings -- DMagick https://github.com/MikeWey/DMagick. I would like to script this operation using DMagick. However, I couldn't find any code samples and was not able to find anything about image conversion in official ImageMagick C API docs either (maybe I need to spend more time though). But maybe someone has code samples of how to convert PDF?It's been awhile since i used it myself, but if imagemagick supports reading PDF's this might work: ``` Image pdf = new Image("./test.pdf") pdf.write("./test.png") ``` DMagick hasn't been updated in a while so it will probably not work with newer versions of ImageMagick.
Sep 25 2021
On Saturday, 25 September 2021 at 16:27:35 UTC, Tejas wrote:On Saturday, 25 September 2021 at 15:14:50 UTC, Mike Wey wrote:Yes, this is an option although I want to use it as a dub dependency as part of the project.On 25-09-2021 15:21, tastyminerals wrote:For his personal use you think there's any problem just using `std.process`? I mean: ```d rdmd --eval='import std.process; auto dmd = execute(["convert", `Screenshot from 2021-09-12 18-14-22.png` , `hello.pdf`]);' ``` I don't see why go beyond that if it's guaranteed that the user has `convert` on their machine[...]It's been awhile since i used it myself, but if imagemagick supports reading PDF's this might work: ``` Image pdf = new Image("./test.pdf") pdf.write("./test.png") ``` DMagick hasn't been updated in a while so it will probably not work with newer versions of ImageMagick.
Sep 25 2021