mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Support Photos in RasterImage template
Actually photos (i.e. .jpg files) where supported previously, but for pdflatex output an unneeded conversion to png was done. The RasterImage templates behaves now exactly as InsetGraphics for these files: If the input format is jpg, use that for pdflatex, else convert to png.
This commit is contained in:
parent
c63d486b2e
commit
0f4c5df9f4
@ -1,5 +1,5 @@
|
||||
#LyX 2.2 created this file. For more info see http://www.lyx.org/
|
||||
\lyxformat 495
|
||||
\lyxformat 497
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin /systemlyxdir/doc/
|
||||
@ -24112,6 +24112,47 @@ $$Extension
|
||||
\end_inset
|
||||
|
||||
The file extension (including the dot).
|
||||
\change_inserted -195340706 1437418878
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
||||
\change_inserted -195340706 1437418878
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted -195340706 1437418878
|
||||
$$pngOrjpg
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
This will be the string
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
jpg
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
if the file is in JPEG format, otherwise it will be the string
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
png
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
.
|
||||
This is useful to avoid uneeded conversions for output formats that support
|
||||
both PNG and JPEG fomats.
|
||||
The predefined RasterImage template uses this macro for the PDFLATeX output
|
||||
format.
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
@ -86,11 +86,7 @@ Template RasterImage
|
||||
# what the template can provide him with.
|
||||
HelpText
|
||||
A bitmap file.
|
||||
Use this template to include bitmap images of any kind except
|
||||
photos in JPEG format: These will be uncompressed by this
|
||||
template, therefore it is better to include them with a
|
||||
graphics inset, since the graphics inset preserves the
|
||||
compression if the pdflatex compiler is used.
|
||||
Use this template to include bitmap images of any kind.
|
||||
HelpTextEnd
|
||||
# ANY file type can be displayed as a RasterImage.
|
||||
# Specifically, LyX will attempt to interrogate the file itself
|
||||
@ -134,10 +130,10 @@ Template RasterImage
|
||||
TransformOption Extra ExtraOption
|
||||
Option Arg "[$$Extra,$$Rotate,$$Resize,$$Clip]"
|
||||
Product "\\includegraphics$$Arg{$$AbsOrRelPathMaster$$Basename}"
|
||||
UpdateFormat png
|
||||
UpdateResult "$$AbsPath$$Basename.png"
|
||||
UpdateFormat "$$pngOrjpg"
|
||||
UpdateResult "$$AbsPath$$Basename.$$pngOrjpg"
|
||||
Requirement "graphicx"
|
||||
ReferencedFile pdflatex "$$AbsPath$$Basename.png"
|
||||
ReferencedFile pdflatex "$$AbsPath$$Basename.$$pngOrjpg"
|
||||
FormatEnd
|
||||
Format Ascii
|
||||
Product "$$Contents(\"$$AbsPath$$Basename.asc\")"
|
||||
|
@ -83,6 +83,21 @@ string const doSubstitution(InsetExternalParams const & params,
|
||||
bool external_in_tmpdir,
|
||||
Substitute what)
|
||||
{
|
||||
string result = s;
|
||||
if (what != PATHS && contains(result, "$$pngOrjpg")) {
|
||||
// This is for raster images and pdflatex:
|
||||
// Since pdflatex supports both jpg and png, we choose the best format:
|
||||
// jpg if the original file is jpg to retain the compression, else png.
|
||||
string format = formats.getFormatFromFile(params.filename);
|
||||
if (format == "jpg")
|
||||
result = subst(result, "$$pngOrjpg", "jpg");
|
||||
else
|
||||
result = subst(result, "$$pngOrjpg", "png");
|
||||
}
|
||||
|
||||
if (what == FORMATS)
|
||||
return result;
|
||||
|
||||
Buffer const * masterBuffer = buffer.masterBuffer();
|
||||
string const parentpath = external_in_tmpdir ?
|
||||
masterBuffer->temppath() :
|
||||
@ -94,7 +109,6 @@ string const doSubstitution(InsetExternalParams const & params,
|
||||
onlyFileName(filename), string());
|
||||
string const absname = makeAbsPath(filename, parentpath).absFileName();
|
||||
|
||||
string result = s;
|
||||
if (what != ALL_BUT_PATHS) {
|
||||
string const filepath = onlyPath(filename);
|
||||
string const abspath = onlyPath(absname);
|
||||
@ -235,7 +249,8 @@ void updateExternal(InsetExternalParams const & params,
|
||||
return; // FAILURE
|
||||
}
|
||||
|
||||
string const to_format = outputFormat.updateFormat;
|
||||
string const to_format = doSubstitution(params, buffer,
|
||||
outputFormat.updateFormat, false, external_in_tmpdir, FORMATS);
|
||||
if (to_format.empty())
|
||||
return; // NOT_NEEDED
|
||||
|
||||
|
@ -37,7 +37,8 @@ void editExternal(InsetExternalParams const & params,
|
||||
enum Substitute {
|
||||
ALL,
|
||||
PATHS,
|
||||
ALL_BUT_PATHS
|
||||
ALL_BUT_PATHS,
|
||||
FORMATS
|
||||
};
|
||||
|
||||
/** Substitute meta-variables in string \p s, making use of \p params and
|
||||
|
Loading…
Reference in New Issue
Block a user