Skip to content

Commit

Permalink
Merge pull request #77 from rodlie/1.2-next
Browse files Browse the repository at this point in the history
Added support for output compression quality
  • Loading branch information
rodlie authored Nov 2, 2019
2 parents 1c5ec0d + ad5f762 commit c0d48c0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
3 changes: 2 additions & 1 deletion docs/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## 1.2.2 - 20191103

* Fixed GIMP support on Linux
* Added support for output compression quality
* Added support for ImageMagick 7
* Support for system theme
* Fixed GIMP support on Linux

## 1.2.1 - 20181204

Expand Down
3 changes: 2 additions & 1 deletion src/FXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ void FXX::clearImage(FXX::Image data)
data.layers.clear();
}

bool FXX::saveImage(FXX::Image data)
bool FXX::saveImage(FXX::Image data, int quality)
{
if (data.imageBuffer.size()==0 || data.filename.empty()) {
return false;
Expand All @@ -711,6 +711,7 @@ bool FXX::saveImage(FXX::Image data)
}
if (image.columns() == 0 && image.rows() == 0) { return false; }
try {
image.quality(quality);
image.write(data.filename);
}
catch(Magick::Error &error_ ) {
Expand Down
2 changes: 1 addition & 1 deletion src/FXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class FXX
std::string backendInfo();

void clearImage(FXX::Image data);
bool saveImage(FXX::Image data);
bool saveImage(FXX::Image data, int quality = 100);

bool hasJPEG();
bool hasPNG();
Expand Down
44 changes: 22 additions & 22 deletions src/cyan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Cyan::Cyan(QWidget *parent)
, progBar(Q_NULLPTR)
, prefsMenu(Q_NULLPTR)
, nativeStyle(false)
, qualityBox(Q_NULLPTR)
{
// get style settings
QSettings settings;
Expand Down Expand Up @@ -233,28 +234,19 @@ Cyan::Cyan(QWidget *parent)
renderingIntent->addItem(renderIcon, tr("Relative"),
FXX::RelativeRenderingIntent);

QLabel *inputLabel = new QLabel(this);
QLabel *outputLabel = new QLabel(this);
QLabel *monitorLabel = new QLabel(this);
QLabel *renderLabel = new QLabel(this);
QLabel *blackLabel = new QLabel(this);
QLabel *rgbLabel = new QLabel(this);
QLabel *cmykLabel = new QLabel(this);
QLabel *grayLabel = new QLabel(this);
QLabel *bitDepthLabel = new QLabel(this);

inputLabel->setText(tr("Input"));
outputLabel->setText(tr("Output"));
monitorLabel->setText(tr("Monitor"));
renderLabel->setText(tr("Intent"));
blackLabel->setText(tr("Black Point"));
rgbLabel->setText(tr("RGB"));
cmykLabel->setText(tr("CMYK"));
grayLabel->setText(tr("GRAY"));
bitDepthLabel->setText(tr("Depth"));
QLabel *inputLabel = new QLabel(tr("Input"), this);
QLabel *outputLabel = new QLabel(tr("Output"), this);
QLabel *monitorLabel = new QLabel(tr("Monitor"), this);
QLabel *renderLabel = new QLabel(tr("Intent"), this);
QLabel *blackLabel = new QLabel(tr("Black Point"), this);
QLabel *rgbLabel = new QLabel(tr("RGB"), this);
QLabel *cmykLabel = new QLabel(tr("CMYK"), this);
QLabel *grayLabel = new QLabel(tr("GRAY"), this);
QLabel *bitDepthLabel = new QLabel(tr("Depth"), this);
QLabel *qualityLabel = new QLabel(tr("Quality"), this);

if (!nativeStyle) {
QString padding = "margin-right:5px;";
QString padding = "margin-right:5px;";
inputLabel->setStyleSheet(padding);
outputLabel->setStyleSheet(padding);
monitorLabel->setStyleSheet(padding);
Expand All @@ -264,6 +256,7 @@ Cyan::Cyan(QWidget *parent)
cmykLabel->setStyleSheet(padding);
grayLabel->setStyleSheet(padding);
bitDepthLabel->setStyleSheet(padding);
qualityLabel->setStyleSheet(padding);
}

inputLabel->setToolTip(tr("Input profile for image"));
Expand All @@ -278,20 +271,27 @@ Cyan::Cyan(QWidget *parent)
grayLabel->setToolTip(tr("Default GRAY profile, "
"used when image don't have an embedded profile"));
bitDepthLabel->setToolTip(tr("Adjust image output bit depth"));
qualityLabel->setToolTip(tr("Compression quality on output image."));

progBar = new QProgressBar(this);
progBar->setTextVisible(false);
progBar->setRange(0,1);
progBar->setValue(1);
progBar->setMaximumWidth(70);

qualityBox = new QSpinBox(this);
qualityBox->setRange(0, 100);
qualityBox->setValue(100);

convertBar->addWidget(inputLabel);
convertBar->addWidget(inputProfile);
convertBar->addSeparator();
convertBar->addWidget(outputLabel);
convertBar->addWidget(outputProfile);
convertBar->addWidget(bitDepthLabel);
convertBar->addWidget(bitDepth);
convertBar->addWidget(qualityLabel);
convertBar->addWidget(qualityBox);
convertBar->addWidget(progBar);

profileBar->addWidget(rgbLabel);
Expand Down Expand Up @@ -634,7 +634,7 @@ void Cyan::saveImageDialog()
}

file = QFileDialog::getSaveFileName(this, tr("Save image"), dir,
tr("Image files (*.tif *.psd *.jpg)"));
tr("Image files (*.tif *.tiff *.psd *.jpg)"));
if (!file.isEmpty()) {
QFileInfo imageFile(file);
if (imageFile.suffix().isEmpty()) {
Expand Down Expand Up @@ -736,7 +736,7 @@ void Cyan::saveImage(QString file, bool notify, bool closeOnSave)
}

disableUI();
if (fx.saveImage(output)) {
if (fx.saveImage(output, qualityBox->value())) {
if (notify) {
QMessageBox::information(this, tr("Image save"), tr("Image saved to %1.")
.arg(file));
Expand Down
2 changes: 2 additions & 0 deletions src/cyan.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <QMap>
#include <QThread>
#include <QFutureWatcher>
#include <QSpinBox>

#include "imageview.h"
#include "profiledialog.h"
Expand Down Expand Up @@ -102,6 +103,7 @@ class Cyan : public QMainWindow
QProgressBar *progBar;
QMenu *prefsMenu;
bool nativeStyle;
QSpinBox *qualityBox;

private slots:
void readConfig();
Expand Down

0 comments on commit c0d48c0

Please sign in to comment.