Skip to content

Commit

Permalink
Render/UI: fix image sequence file extension
Browse files Browse the repository at this point in the history
We now check the codec and only use proper extensions for PNG, TIFF and JPEG.

Ref: #219
  • Loading branch information
rodlie committed Aug 14, 2024
1 parent 8e30c23 commit 88c1f7b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
46 changes: 40 additions & 6 deletions src/app/GUI/RenderWidgets/renderinstancewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,13 @@ void RenderInstanceWidget::updateOutputDestinationFromCurrentFormat() {
outputDst = Document::sInstance->projectDirectory() + "/untitled";
}
const QString tmpStr = QString(format->extensions);
const QStringList supportedExt = tmpStr.split(",");
QStringList supportedExt = tmpStr.split(",");
if (isImgSeq) {
const auto exts = getExportImageExtensions(outputSettings);
if (!exts.second.isEmpty()) {
supportedExt = exts.second.join(" ").split("*.", Qt::SkipEmptyParts);
}
}
const QString fileName = outputDst.split("/").last();
const QStringList dividedName = fileName.split(".");
QString currExt;
Expand Down Expand Up @@ -346,12 +352,18 @@ void RenderInstanceWidget::openOutputDestinationDialog() {
QString selectedExt;
const OutputSettings &outputSettings = mSettings.getOutputRenderSettings();
const auto format = outputSettings.fOutputFormat;
if(format) {
if (format) {
QString tmpStr = QString(format->extensions);
const QStringList supportedExt = tmpStr.split(",");
selectedExt = "." + supportedExt.first();
tmpStr.replace(",", " *.");
supportedExts = "Output File (*." + tmpStr + ")";
const auto exts = getExportImageExtensions(outputSettings);
if (!exts.first.isEmpty() && !exts.second.isEmpty()) {
selectedExt = exts.first;
supportedExts = tr("Output File (%1)").arg(exts.second.join(" "));
} else {
const QStringList supportedExt = tmpStr.split(",");
selectedExt = "." + supportedExt.first();
tmpStr.replace(",", " *.");
supportedExts = "Output File (*." + tmpStr + ")";
}
}
QString iniText = mSettings.getOutputDestination();
if(iniText.isEmpty()) {
Expand All @@ -378,6 +390,28 @@ void RenderInstanceWidget::openRenderSettingsDialog() {
delete dialog;
}

const QPair<QString, QStringList> RenderInstanceWidget::getExportImageExtensions(const OutputSettings &settings)
{
const auto format = settings.fOutputFormat;
const auto codec = settings.fVideoCodec;
QPair<QString,QStringList> ext;
if (!format) { return ext; }
if (QString(format->long_name).startsWith("image2") && codec) {
const auto codecName = QString(codec->name);
if (codecName == "png") {
ext.first = ".png";
ext.second << "*.png";
} else if (codecName == "tiff") {
ext.first = ".tif";
ext.second << "*.tif" << "*.tiff";
} else if (codecName.endsWith("jpeg")) {
ext.first = ".jpg";
ext.second << "*.jpg" << "*.jpeg";
}
}
return ext;
}

void RenderInstanceWidget::write(eWriteStream &dst) const {
mSettings.write(dst);
dst << isChecked();
Expand Down
2 changes: 2 additions & 0 deletions src/app/GUI/RenderWidgets/renderinstancewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class RenderInstanceWidget : public ClosableContainer {
void openOutputSettingsDialog();
void openOutputDestinationDialog();
void openRenderSettingsDialog();

const QPair<QString,QStringList> getExportImageExtensions(const OutputSettings &settings);
};

#endif // RENDERINSTANCEWIDGET_H

0 comments on commit 88c1f7b

Please sign in to comment.