Skip to content

Commit

Permalink
Merge pull request #245 from EpicGazel/main
Browse files Browse the repository at this point in the history
Fixed issue #234
  • Loading branch information
Lymphatus authored Jan 7, 2024
2 parents 447a9de + 0f62c14 commit 5e3b646
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/models/CImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,24 @@ bool CImage::compress(const CompressionOptions& compressionOptions)
}
}

bool copyResult = false;
if (!outputIsBiggerThanInput) {
inputCopyFile = tempFileFullPath;
copyResult = QFile::copy(inputCopyFile, outputFullPath);
} else {
this->status = CImageStatus::WARNING;
this->additionalInfo = QIODevice::tr("Skipped: compressed file is bigger than original");
// Overwrite output file name with original file name to avoid broken extension (ex: .png named .webp)
fullFileName = inputFileInfo.fileName();
outputFullPath = outputDir.absoluteFilePath(fullFileName);
copyResult = QFile::copy(inputCopyFile, outputFullPath);
if (outputAlreadyExists) {
QFileInfo outputFileInfo = QFileInfo(outputFullPath);
this->setCompressedInfo(outputFileInfo);
return true;
}
}
bool copyResult = QFile::copy(inputCopyFile, outputFullPath);

if (!copyResult) {
qCritical() << "Failed to copy from" << inputCopyFile << "to" << outputFullPath;
this->additionalInfo = QIODevice::tr("Cannot copy output file, check your permissions");
Expand Down

0 comments on commit 5e3b646

Please sign in to comment.