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 _saveOutputPdfInWorkingDir;
|
||||
private string _outputPdfDir;
|
||||
private decimal _imageResizeThreshold;
|
||||
|
||||
public Settings()
|
||||
{
|
||||
@@ -22,6 +23,7 @@ class Settings : ChangeNotifier
|
||||
_useDocnetPDFImageRendering = true;
|
||||
_saveOutputPdfInWorkingDir = true;
|
||||
_outputPdfDir = "";
|
||||
_imageResizeThreshold = 1.5m;
|
||||
}
|
||||
|
||||
public Settings(Settings other)
|
||||
@@ -30,6 +32,7 @@ class Settings : ChangeNotifier
|
||||
_useDocnetPDFImageRendering = other.UseDocnetPDFImageRendering;
|
||||
_saveOutputPdfInWorkingDir = other.SaveOutputPdfInWorkingDir;
|
||||
_outputPdfDir = other.OutputPdfDir;
|
||||
_imageResizeThreshold = other.ImageResizeThreshold;
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
@@ -61,6 +64,13 @@ class Settings : ChangeNotifier
|
||||
set { _outputPdfDir = value; NotifyPropertyChanged(); }
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
public decimal ImageResizeThreshold
|
||||
{
|
||||
get => _imageResizeThreshold;
|
||||
set { _imageResizeThreshold = value; NotifyPropertyChanged(); }
|
||||
}
|
||||
|
||||
public static string GetSettingsFileName()
|
||||
{
|
||||
return "settings.json";
|
||||
|
||||
@@ -706,7 +706,7 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
|
||||
didAdjust = true;
|
||||
}
|
||||
// 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
|
||||
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()
|
||||
{
|
||||
var topLevel = _topLevelGrabber?.GetTopLevel();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
xmlns:models="clr-namespace:MayShow.Models"
|
||||
xmlns:vm="clr-namespace:MayShow.ViewModels"
|
||||
x:DataType="vm:SettingsViewModel"
|
||||
MaxWidth="350">
|
||||
MaxWidth="450">
|
||||
<ScrollViewer AllowAutoHide="False">
|
||||
<StackPanel Orientation="Vertical"
|
||||
Spacing="8"
|
||||
@@ -18,6 +18,19 @@
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="16"
|
||||
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 SaveOutputPdfInWorkingDir}">Always save report PDF in working directory</CheckBox>
|
||||
<Grid ColumnDefinitions="*, *"
|
||||
|
||||
Reference in New Issue
Block a user