Downsize MB is now user-configurable
Probably doesn't matter most of the time since we resize down HEIC and PNG anyway... Closes #7
This commit is contained in:
@@ -15,6 +15,7 @@ class Settings : ChangeNotifier
|
|||||||
private bool _useDocnetPDFImageRendering;
|
private bool _useDocnetPDFImageRendering;
|
||||||
private bool _saveOutputPdfInWorkingDir;
|
private bool _saveOutputPdfInWorkingDir;
|
||||||
private string _outputPdfDir;
|
private string _outputPdfDir;
|
||||||
|
private decimal _imageResizeThreshold;
|
||||||
|
|
||||||
public Settings()
|
public Settings()
|
||||||
{
|
{
|
||||||
@@ -22,6 +23,7 @@ class Settings : ChangeNotifier
|
|||||||
_useDocnetPDFImageRendering = true;
|
_useDocnetPDFImageRendering = true;
|
||||||
_saveOutputPdfInWorkingDir = true;
|
_saveOutputPdfInWorkingDir = true;
|
||||||
_outputPdfDir = "";
|
_outputPdfDir = "";
|
||||||
|
_imageResizeThreshold = 1.5m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Settings(Settings other)
|
public Settings(Settings other)
|
||||||
@@ -30,6 +32,7 @@ class Settings : ChangeNotifier
|
|||||||
_useDocnetPDFImageRendering = other.UseDocnetPDFImageRendering;
|
_useDocnetPDFImageRendering = other.UseDocnetPDFImageRendering;
|
||||||
_saveOutputPdfInWorkingDir = other.SaveOutputPdfInWorkingDir;
|
_saveOutputPdfInWorkingDir = other.SaveOutputPdfInWorkingDir;
|
||||||
_outputPdfDir = other.OutputPdfDir;
|
_outputPdfDir = other.OutputPdfDir;
|
||||||
|
_imageResizeThreshold = other.ImageResizeThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonInclude]
|
[JsonInclude]
|
||||||
@@ -61,6 +64,13 @@ class Settings : ChangeNotifier
|
|||||||
set { _outputPdfDir = value; NotifyPropertyChanged(); }
|
set { _outputPdfDir = value; NotifyPropertyChanged(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonInclude]
|
||||||
|
public decimal ImageResizeThreshold
|
||||||
|
{
|
||||||
|
get => _imageResizeThreshold;
|
||||||
|
set { _imageResizeThreshold = value; NotifyPropertyChanged(); }
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetSettingsFileName()
|
public static string GetSettingsFileName()
|
||||||
{
|
{
|
||||||
return "settings.json";
|
return "settings.json";
|
||||||
|
|||||||
@@ -706,7 +706,7 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
|
|||||||
didAdjust = true;
|
didAdjust = true;
|
||||||
}
|
}
|
||||||
// perform needed image manipulations
|
// perform needed image manipulations
|
||||||
if (isHEIC || isWebp || isPNG || (!isPDF && info.Length > 1.5 * 1024 * 1024 /* 1.5 MB */))
|
if (isHEIC || isWebp || isPNG || (!isPDF && info.Length > _settings.ImageResizeThreshold * 1024 * 1024))
|
||||||
{
|
{
|
||||||
// Save image as jpg
|
// Save image as jpg
|
||||||
mImage.Quality = 80;
|
mImage.Quality = 80;
|
||||||
|
|||||||
@@ -87,6 +87,16 @@ class SettingsViewModel: ChangeNotifier
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public decimal ImageResizeThreshold
|
||||||
|
{
|
||||||
|
get => _settings.ImageResizeThreshold;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_settings.ImageResizeThreshold = value;
|
||||||
|
NotifyPropertyChanged(nameof(ImageResizeThreshold));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async void ChooseOutputFolder()
|
public async void ChooseOutputFolder()
|
||||||
{
|
{
|
||||||
var topLevel = _topLevelGrabber?.GetTopLevel();
|
var topLevel = _topLevelGrabber?.GetTopLevel();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
xmlns:models="clr-namespace:MayShow.Models"
|
xmlns:models="clr-namespace:MayShow.Models"
|
||||||
xmlns:vm="clr-namespace:MayShow.ViewModels"
|
xmlns:vm="clr-namespace:MayShow.ViewModels"
|
||||||
x:DataType="vm:SettingsViewModel"
|
x:DataType="vm:SettingsViewModel"
|
||||||
MaxWidth="350">
|
MaxWidth="450">
|
||||||
<ScrollViewer AllowAutoHide="False">
|
<ScrollViewer AllowAutoHide="False">
|
||||||
<StackPanel Orientation="Vertical"
|
<StackPanel Orientation="Vertical"
|
||||||
Spacing="8"
|
Spacing="8"
|
||||||
@@ -18,6 +18,19 @@
|
|||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
FontWeight="Bold" />
|
FontWeight="Bold" />
|
||||||
|
<TextBlock TextWrapping="Wrap"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Width="300">
|
||||||
|
Always reduce size of images if above this file size in megabytes (MB):
|
||||||
|
</TextBlock>
|
||||||
|
<NumericUpDown Value="{Binding ImageResizeThreshold}"
|
||||||
|
Increment="0.1"
|
||||||
|
Minimum="0.5"
|
||||||
|
FormatString="0.00"
|
||||||
|
Maximum="10"
|
||||||
|
Width="150"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="0,0,0,4" />
|
||||||
<CheckBox IsChecked="{Binding !UseDocnetPDFImageRendering}">Use legacy PDF handling (does not work with macOS annotations)</CheckBox>
|
<CheckBox IsChecked="{Binding !UseDocnetPDFImageRendering}">Use legacy PDF handling (does not work with macOS annotations)</CheckBox>
|
||||||
<CheckBox IsChecked="{Binding SaveOutputPdfInWorkingDir}">Always save report PDF in working directory</CheckBox>
|
<CheckBox IsChecked="{Binding SaveOutputPdfInWorkingDir}">Always save report PDF in working directory</CheckBox>
|
||||||
<Grid ColumnDefinitions="*, *"
|
<Grid ColumnDefinitions="*, *"
|
||||||
|
|||||||
Reference in New Issue
Block a user