mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Fix JPEG format detection
Detect JPEG files using the magic number FF D8 (so-called SOI marker) instead of the string JFIF, which does not appear in all JPEG files.
This commit is contained in:
parent
822e171762
commit
096204e23f
@ -206,7 +206,7 @@ string guessFormatFromContents(FileName const & fn)
|
|||||||
// FIG #FIG...
|
// FIG #FIG...
|
||||||
// FITS ...BITPIX...
|
// FITS ...BITPIX...
|
||||||
// GIF GIF...
|
// GIF GIF...
|
||||||
// JPG JFIF
|
// JPG \377\330... (0xFFD8)
|
||||||
// PDF %PDF-...
|
// PDF %PDF-...
|
||||||
// PNG .PNG...
|
// PNG .PNG...
|
||||||
// PBM P1... or P4 (B/W)
|
// PBM P1... or P4 (B/W)
|
||||||
@ -280,6 +280,9 @@ string guessFormatFromContents(FileName const & fn)
|
|||||||
} else if (stamp == "BM") {
|
} else if (stamp == "BM") {
|
||||||
format = "bmp";
|
format = "bmp";
|
||||||
|
|
||||||
|
} else if (stamp == "\377\330") {
|
||||||
|
format = "jpg";
|
||||||
|
|
||||||
} else if (stamp == "\001\332") {
|
} else if (stamp == "\001\332") {
|
||||||
format = "sgi";
|
format = "sgi";
|
||||||
|
|
||||||
@ -335,9 +338,6 @@ string guessFormatFromContents(FileName const & fn)
|
|||||||
else if (contains(str, "Grace"))
|
else if (contains(str, "Grace"))
|
||||||
format = "agr";
|
format = "agr";
|
||||||
|
|
||||||
else if (contains(str, "JFIF"))
|
|
||||||
format = "jpg";
|
|
||||||
|
|
||||||
else if (contains(str, "%PDF"))
|
else if (contains(str, "%PDF"))
|
||||||
// autodetect pdf format for graphics inclusion
|
// autodetect pdf format for graphics inclusion
|
||||||
format = "pdf6";
|
format = "pdf6";
|
||||||
|
Loading…
Reference in New Issue
Block a user