2006-07-17 19:41:32 +00:00
|
|
|
#!/usr/bin/env python
|
2006-08-08 10:42:59 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2003-08-22 10:50:02 +00:00
|
|
|
|
2006-06-26 14:17:12 +00:00
|
|
|
# file convertDefault.py
|
2003-08-22 10:50:02 +00:00
|
|
|
# This file is part of LyX, the document processor.
|
|
|
|
# Licence details can be found in the file COPYING.
|
|
|
|
|
2006-08-08 10:42:59 +00:00
|
|
|
# \author Herbert Voß
|
2006-06-26 14:17:12 +00:00
|
|
|
# \author Bo Peng
|
2003-08-22 10:50:02 +00:00
|
|
|
|
|
|
|
# Full author contact details are available in file CREDITS.
|
|
|
|
|
2003-01-13 23:35:18 +00:00
|
|
|
# The default converter if no other has been defined by the user from the
|
|
|
|
# Conversion->Converter tab of the Preferences dialog.
|
2003-08-22 10:50:02 +00:00
|
|
|
|
2003-01-13 23:35:18 +00:00
|
|
|
# The user can also redefine this default converter, placing their
|
|
|
|
# replacement in ~/.lyx/scripts
|
2003-08-22 10:50:02 +00:00
|
|
|
|
2003-01-13 23:35:18 +00:00
|
|
|
# converts an image from $1 to $2 format
|
2006-06-26 14:17:12 +00:00
|
|
|
import os, sys
|
2007-03-31 18:21:54 +00:00
|
|
|
|
|
|
|
opts = "-depth 8"
|
|
|
|
# for pdf source formats, check whether convert supports the -define option
|
|
|
|
if sys.argv[1][:4] == 'pdf:':
|
|
|
|
defopt = "-define pdf:use-cropbox=true"
|
|
|
|
fout = os.popen('convert ' + defopt + ' 2>&1')
|
|
|
|
output = fout.read()
|
|
|
|
fout.close()
|
|
|
|
if not 'unrecognized' in output.lower():
|
|
|
|
opts = defopt + ' ' + opts
|
|
|
|
|
|
|
|
if os.system(r'convert %s "%s" "%s"' % (opts, sys.argv[1], sys.argv[2])) != 0:
|
2006-06-27 21:08:54 +00:00
|
|
|
print >> sys.stderr, sys.argv[0], 'ERROR'
|
|
|
|
print >> sys.stderr, 'Execution of "convert" failed.'
|
|
|
|
sys.exit(1)
|