Command line conversion of PNG to PDF - stop the dialog box

Post questions on how to use or achieve an effect in Inkscape.
martinrune
Posts: 2
Joined: Mon Nov 05, 2012 6:44 pm

Command line conversion of PNG to PDF - stop the dialog box

Postby martinrune » Mon Nov 05, 2012 7:00 pm

Hi there

I am a Windows 7 user trying to convert PNG images to PDF files using Inkscape in command line mode, issuing the command "inkscape inputfile.png -z -D --export-pdf=outputfile.pdf". I have successfully used similar commands for converting WMF files, but when I try it with PNG files, a dialog box pops up asking me if I want the resulting PDF to link to the original file or have it embedded. This is quite annoying, since I am including the command in a program I am writing and want the conversion to happen completely automatically. I have searched the web in vain and also looked through the list of Inkscape verbs without luck.
So, please: Does anyone know of an option I can specify that will stop the dialog box from popping up?
Thanks in advance.

Kind regards, Martin
Attachments
dialog box.png
The dialog box that pops up upon issuing the command (I have no idea why it says something about an SVG file, because if I press OK, a PDF file is produced. Must be a glitch).
dialog box.png (23.77 KiB) Viewed 3105 times

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Command line conversion of PNG to PDF - stop the dialog

Postby brynn » Mon Nov 05, 2012 9:05 pm

Welcome Martin!

First I should say that I don't understand how to use the command line, although I do have an idea what it is. But I know where that dialog is coming from, so perhaps that will help you write a better code for the command line.

Whenever you open a raster image in Inkscape, you're technically importing it (according to Inkscape, at this time). So this dialog asks if you want the imported image linked or embedded. If you're clicking Ok on the dialog you've shown above, that means all your images are being embedded.

The difference between linking and embedding, if is you link the image to the file, and you later move either the image or the file, the image won't be there the next time you open the SVG. (I know you're exporting PDFs, but I'll get there.) So if we're talking about SVGs, and you plan to take the SVG to a different computer, without bringing the image with it, it would be better to embed the raster image. But there's another factor to consider. Embedded raster images (such as PNGs) makes for a much larger file size, than linked.

So by using the command line to convert PNG to PDF, apparently you're not making a direct conversion. Apparently the code says to import the PNG into Inkscape, then save the file as PDF. And here's the part I don't understand. After importing the raster image, then saving as PDF, I don't know if it matters anymore whether the raster was linked or embedded. If it doesn't matter, and file size does matter, you'd probably be better of choosing link. But if it does matter, you'll want to continue embedding.

Maybe you already know whether it matters whether the imported raster is linked or embedded? If so, I guess you would need to write the commandline code so that it instructs Inkscape what to do. If you don't know, you could do a test. Run your current commandline code, but when the dialog comes up, choose link and OK. Then locate that PNG that was saved as PDF. Move it to a different folder. Open the PDF to find out if the image is still there. If it is, you can have a smaller file size (if it matters) by telling Inkscape to link the image. If not, you''ll know that you need to keep embedding the PNGs.

So that's where the dialog comes from. Possibly the reason why it didn't happen with the WMFs is that you might have been using an older version of Inkscape. It seems like the link vs embed dialog has only shown up in more recent versions of Inksape. Although I could be wrong about that. Or maybe you weren't importing raster images for the WMFs?

Anyway, my guess is that you need to make the commandline code so that it makes the choice for you. However, here's another caveat to my comments. I don't know if the commandline has the ability to make that choice for you. But I'm pretty sure that a script could be written to do that. Although again, I wouldn't know how to write a script.

So yes, not much help, I know. But I hope the info about the reason for that dialog will help you figure out what to do. And hopefully, someone else will reply who knows more about the commandline. Good luck :D

PS -- Or maybe you could find a program that will make a more direct conversion? I'm pretty sure that Irfanview can make batch file conversions. It is, or at least used to be, one of it's best features. Although I don't know if PNG to PDF is one of the options it offers.

Or another idea. If I'm right about the link vs embed dialog being recent, you could get an older version of Inkscape, and continue using the commandline.

All best :D

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: Command line conversion of PNG to PDF - stop the dialog

Postby v1nce » Thu Nov 08, 2012 3:19 am

I don't know if inkscape is the right tool to do this.
If you just want to convert 1 image to pdf I think imagemagic would be better.
http://www.imagemagick.org/script/convert.php

martinrune
Posts: 2
Joined: Mon Nov 05, 2012 6:44 pm

Re: Command line conversion of PNG to PDF - stop the dialog

Postby martinrune » Thu Nov 22, 2012 7:46 pm

Thank you very much for both of your replies. I ended up using imagemagick instead of Inkscape, as I could not find command line option to kill the dialog box.

Regards, Martin


Return to “Help with using Inkscape”