mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
PDF Output: Dont dedup images that cannot be uncompressed
Fixes #1856564 [pdf conversion error](https://bugs.launchpad.net/calibre/+bug/1856564)
This commit is contained in:
parent
5ad63e6d9a
commit
4706561f57
@ -19,7 +19,11 @@ class Image {
|
||||
public:
|
||||
Image(const PdfReference &reference, const PdfObject *o) : buf(NULL), sz(0), width(0), height(0), ref(reference) {
|
||||
const PdfStream *stream = o->GetStream();
|
||||
stream->GetFilteredCopy(&buf, &sz);
|
||||
try {
|
||||
stream->GetFilteredCopy(&buf, &sz);
|
||||
} catch(...) {
|
||||
buf = NULL; sz = -1;
|
||||
}
|
||||
const PdfDictionary &dict = o->GetDictionary();
|
||||
if (dict.HasKey("Width") && dict.GetKey("Width")->IsNumber()) width = dict.GetKey("Width")->GetNumber();
|
||||
if (dict.HasKey("Height") && dict.GetKey("Height")->IsNumber()) height = dict.GetKey("Height")->GetNumber();
|
||||
@ -36,7 +40,7 @@ class Image {
|
||||
}
|
||||
~Image() noexcept { if (buf) podofo_free(buf); buf = NULL; }
|
||||
bool operator==(const Image &other) const noexcept {
|
||||
return other.sz == sz && other.width == width && other.height == height && memcmp(buf, other.buf, sz) == 0;
|
||||
return other.sz == sz && sz > -1 && other.width == width && other.height == height && memcmp(buf, other.buf, sz) == 0;
|
||||
}
|
||||
std::size_t hash() const noexcept { return sz; }
|
||||
const PdfReference& reference() const noexcept { return ref; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user