MCPcopy Create free account
hub / github.com/YACReader/yacreader / saveCover

Method saveCover

common/cover_utils.cpp:3–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "cover_utils.h"
2
3bool YACReader::saveCover(const QString &path, const QImage &cover)
4{
5 QImage scaled;
6 if (cover.width() > cover.height()) {
7 scaled = cover.scaledToWidth(640, Qt::SmoothTransformation);
8 } else {
9 auto aspectRatio = static_cast<double>(cover.width()) / static_cast<double>(cover.height());
10 auto maxAllowedAspectRatio = 0.5;
11 if (aspectRatio < maxAllowedAspectRatio) { // cover is too tall, e.g. webtoon
12 scaled = cover.scaledToHeight(960, Qt::SmoothTransformation);
13 } else {
14 scaled = cover.scaledToWidth(480, Qt::SmoothTransformation);
15 }
16 }
17 return scaled.save(path, 0, 75);
18}

Callers

nothing calls this directly

Calls 1

saveMethod · 0.45

Tested by

no test coverage detected