mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 06:15:16 +00:00
Let imagemagick detect file format (bug #2332)
Imagemagick detects the inut file format based on contents. Therefore it does not make sense that we prefix the to be converted file name with the extension (assuming that the file extension matches the imagemagick format name). This breaks formats where the extension used by LyX does not match the imagemagick format name.
This commit is contained in:
parent
4a44dfc325
commit
88c274eee7
@ -15,7 +15,7 @@
|
||||
# The user can also redefine this default converter, placing their
|
||||
# replacement in ~/.lyx/scripts
|
||||
|
||||
# converts an image from $1 to $2 format
|
||||
# converts an image $2 (format $1) to $4 (format $3)
|
||||
import os, re, sys
|
||||
|
||||
# We may need some extra options only supported by recent convert versions
|
||||
@ -42,15 +42,15 @@ else:
|
||||
|
||||
opts = "-depth 8"
|
||||
|
||||
# If supported, add the -define option for pdf source formats
|
||||
if sys.argv[1][:4] == 'pdf:' and (version >= 0x060206 or gm):
|
||||
# If supported, add the -define option for pdf source formats
|
||||
if sys.argv[1] == 'pdf' and (version >= 0x060206 or gm):
|
||||
opts = '-define pdf:use-cropbox=true ' + opts
|
||||
|
||||
# If supported, add the -flatten option for ppm target formats (see bug 4749)
|
||||
if sys.argv[2][:4] == 'ppm:' and (version >= 0x060305 or gm):
|
||||
if sys.argv[3] == 'ppm' and (version >= 0x060305 or gm):
|
||||
opts = opts + ' -flatten'
|
||||
|
||||
if os.system(r'convert %s "%s" "%s"' % (opts, sys.argv[1], sys.argv[2])) != 0:
|
||||
if os.system(r'convert %s "%s" "%s"' % (opts, sys.argv[2], sys.argv[3] + ':' + sys.argv[4])) != 0:
|
||||
print >> sys.stderr, sys.argv[0], 'ERROR'
|
||||
print >> sys.stderr, 'Execution of "convert" failed.'
|
||||
sys.exit(1)
|
||||
|
@ -299,10 +299,10 @@ bool Converters::convert(Buffer const * buffer,
|
||||
string const command =
|
||||
os::python() + ' ' +
|
||||
quoteName(libFileSearch("scripts", "convertDefault.py").toFilesystemEncoding()) +
|
||||
' ' +
|
||||
quoteName(from_ext + ':' + from_file.toFilesystemEncoding()) +
|
||||
' ' +
|
||||
quoteName(to_ext + ':' + to_file.toFilesystemEncoding());
|
||||
' ' + from_ext + ' ' +
|
||||
quoteName(from_file.toFilesystemEncoding()) +
|
||||
' ' + to_ext + ' ' +
|
||||
quoteName(to_file.toFilesystemEncoding());
|
||||
LYXERR(Debug::FILES, "No converter defined! "
|
||||
"I use convertDefault.py:\n\t" << command);
|
||||
Systemcall one;
|
||||
|
@ -324,13 +324,15 @@ static void build_script(string const & from_file,
|
||||
ostringstream os;
|
||||
os << os::python() << ' '
|
||||
<< commandPrep("$$s/scripts/convertDefault.py") << ' ';
|
||||
if (!from_format.empty())
|
||||
os << strip_digit(from_format) << ':';
|
||||
if (from_format.empty())
|
||||
os << "unknown ";
|
||||
else
|
||||
os << strip_digit(from_format) << ' ';
|
||||
// The extra " quotes around infile and outfile are needed
|
||||
// because the filename may contain spaces and it is used
|
||||
// as argument of os.system().
|
||||
os << "' + '\"' + infile + '\"' + ' "
|
||||
<< strip_digit(to_format) << ":' + '\"' + outfile + '\"' + '";
|
||||
<< strip_digit(to_format) << " ' + '\"' + outfile + '\"' + '";
|
||||
string const command = os.str();
|
||||
|
||||
LYXERR(Debug::GRAPHICS,
|
||||
|
Loading…
Reference in New Issue
Block a user