The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniGraffle General (http://forums.omnigroup.com/forumdisplay.php?f=10)
-   -   Exporting omnigraffle canvases to PDF,SVG,PNG,EPS from command line (http://forums.omnigroup.com/showthread.php?t=21327)

fikovnik 2011-06-07 05:17 AM

Exporting omnigraffle canvases to PDF,SVG,PNG,EPS from command line
 
Hi,

I use OmniGraffle a lot especially when composing LaTeX documents. For that the manual export to PDF or EPS would be to cumbersome. Therefore I created a small utility that does the job automatically using the Applescript interface from OmniGraffle. It allows to export a specific canvas or all of them into various formats. Also it does integrate with rubber - a wrapper for LaTeX document compilation so the whole process can be automated.

It is available at github.com under my username (fikovnik) as omnigraffle-export (I'm sorry I cannot post URLs).

Any feedback will be greatly appreciated!

/cheers
Filip

kent 2011-06-12 10:31 PM

I can use this for iOS images
 
Filip:

I have not used python before, but the script looks clean. I need to specify a resolution for each canvas to support the different screens in iOS. An example of a OmniGraffle Pro document where each canvas is an icon (i.e.: a deck of cards).

[CODE]$ omnigraffle-export -f png --resolution 1.0 cards.graffle DeckImages

$ omnigraffle-export -f png --resolution 2.0 --suffix "@2x~iphone" cards.graffle DeckImages[/CODE]

The --resolution is the omnigraffle applescript "export setting - resolution"
The --suffix will be added to the filename.

If the canvas was named ace, then ace.png, and [email]ace@2x~iphone.png[/email] would be generated.

When I get to the point of export my cards, I'll make the changes to your script. Unless, of course, you add it first ;)

fikovnik 2011-06-13 05:28 AM

Hi Kent,

Glad you find it useful. Please feel free to clone it on github and add these functionalities.

The [I]--resolution[/I] will be very simple to add:

From the ASDictionary for OmniGraffle suites:
[LIST][*] [I]resolution[/I] short_float -- The number of pixels per point in the resulting exported image (1.0 for 72 DPI)[/LIST]so in the [I]export[/I] method you add new parameter and use it like:

[CODE]self.og.current_export_settings.resolution.set(resolution)[/CODE]

The [I]--suffix[/I] will be probably even easier as you could reuse the [I]namemap[/I] argument for the export all. It is a lambda function (like a block in objc) and so you call it:

[CODE]
schema.export_all(target, fmt=format, force=options.force, namemap=lambda c, f: "%s%s.%s" % (c, suffix, f)))
[/CODE]
The [I]c[/I] is the canvas name and [I]f[/I] is the target format and the [I]suffix[/I] is your suffixed obtained from the [I]options.suffix[/I]. You need to add both options to the option parser: [I]parser.add_option[/I].

Hope it help,

/cheers
Filip


All times are GMT -8. The time now is 02:32 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.