Override mode fix
This commit is contained in:
parent
abdd2a313a
commit
12d1bd57dc
7 changed files with 249 additions and 181 deletions
|
|
@ -680,6 +680,9 @@ public class ImageCreatorSharp(PicSettings picSettings, ILogger<ImageCreatorShar
|
|||
|
||||
private void SalvaFoto(Bitmap imgOutputBig, ImageState imgState, ImageFormat thisFormat)
|
||||
{
|
||||
|
||||
var fileName = Path.Combine(imgState.DestDir.FullName, imgState.NomeFileBig);
|
||||
|
||||
using var image1Stream = new MemoryStream();
|
||||
if (picSettings.FotoGrandeDimOrigina == false)
|
||||
{
|
||||
|
|
@ -699,52 +702,60 @@ public class ImageCreatorSharp(PicSettings picSettings, ILogger<ImageCreatorShar
|
|||
using var g2 = Image.FromStream(image1Stream);
|
||||
imgState.ThumbSizeBig = g2.Width > g2.Height ? NewthumbSize(g2.Width, g2.Height, picSettings.LarghezzaBig, "Larghezza") : NewthumbSize(g2.Width, g2.Height, picSettings.AltezzaBig, "Altezza");
|
||||
using var imgOutputBig2 = new Bitmap(g2, imgState.ThumbSizeBig.Width, imgState.ThumbSizeBig.Height);
|
||||
if (thisFormat.Equals(ImageFormat.Jpeg))
|
||||
SalvaImmagineCustomQuality(imgOutputBig2, Path.Combine(imgState.DestDir.FullName, imgState.NomeFileBig), picSettings.JpegQuality);
|
||||
|
||||
if (!picSettings.OverwriteFiles && File.Exists(fileName))
|
||||
{
|
||||
logger.LogInformation("Saltata foto {FileName}, esiste", fileName);
|
||||
}
|
||||
else
|
||||
imgOutputBig2.Save(Path.Combine(imgState.DestDir.FullName, imgState.NomeFileBig), thisFormat);
|
||||
|
||||
//imgOutputBig2.Dispose();
|
||||
|
||||
//imgOutputBig.Dispose();
|
||||
//g2.Dispose();
|
||||
{
|
||||
if (thisFormat.Equals(ImageFormat.Jpeg))
|
||||
SalvaImmagineCustomQuality(imgOutputBig2, fileName, picSettings.JpegQuality);
|
||||
else
|
||||
imgOutputBig2.Save(fileName, thisFormat);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
if (thisFormat.Equals(ImageFormat.Jpeg))
|
||||
SalvaImmagineCustomQuality(imgOutputBig, Path.Combine(imgState.DestDir.FullName, imgState.NomeFileBig), picSettings.JpegQuality);
|
||||
if (!picSettings.OverwriteFiles && File.Exists(fileName))
|
||||
{
|
||||
logger.LogInformation("Saltata foto {FileName}, esiste", fileName);
|
||||
}
|
||||
else
|
||||
imgOutputBig.Save(Path.Combine(imgState.DestDir.FullName, imgState.NomeFileBig), thisFormat);
|
||||
|
||||
//imgOutputBig.Dispose();
|
||||
{
|
||||
if (thisFormat.Equals(ImageFormat.Jpeg))
|
||||
SalvaImmagineCustomQuality(imgOutputBig, fileName, picSettings.JpegQuality);
|
||||
else
|
||||
imgOutputBig.Save(fileName, thisFormat);
|
||||
}
|
||||
}
|
||||
|
||||
image1Stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
if (!picSettings.CreaMiniature) return;
|
||||
if (!picSettings.AggiungiScritteMiniature) return;
|
||||
|
||||
using var g1 = picSettings.FotoGrandeDimOrigina ? (Image)imgOutputBig.Clone() : Image.FromStream(image1Stream);
|
||||
//if (_picSettings.FotoGrandeDimOrigina == false)
|
||||
// g1 = Image.FromStream(image1Stream);
|
||||
////g1 = System.Drawing.Image.FromFile(Path.Combine(DestDir.FullName, "Temp_" + NomeFileBig));
|
||||
//else
|
||||
// g1 = (Image)imgOutputBig.Clone();
|
||||
//g1 = System.Drawing.Image.FromFile(Path.Combine(DestDir.FullName, NomeFileBig));
|
||||
using Bitmap imgOutputSmall = new Bitmap(g1, imgState.ThumbSizeSmall.Width, imgState.ThumbSizeSmall.Height);
|
||||
|
||||
using var imgOutputSmall = new Bitmap(g1, imgState.ThumbSizeSmall.Width, imgState.ThumbSizeSmall.Height);
|
||||
|
||||
if (string.Equals(picSettings.DirectorySorgente, picSettings.DirectoryDestinazione, StringComparison.OrdinalIgnoreCase))
|
||||
imgState.NomeFileSmall = imgState.NomeFileSmall.Substring(0, imgState.NomeFileSmall.Length - 4) + picSettings.Codice + imgState.NomeFileSmall.Substring(imgState.NomeFileSmall.Length - 4);
|
||||
//
|
||||
if (thisFormat.Equals(ImageFormat.Jpeg))
|
||||
SalvaImmagineCustomQuality(imgOutputSmall, Path.Combine(imgState.DestDir.FullName, imgState.NomeFileSmall), picSettings.JpegQualityMin);
|
||||
|
||||
var tnFileName = Path.Combine(imgState.DestDir.FullName, imgState.NomeFileSmall);
|
||||
|
||||
if (!picSettings.OverwriteFiles && File.Exists(tnFileName))
|
||||
{
|
||||
logger.LogInformation("Saltata miniatura foto {TnFileName}, esiste", tnFileName);
|
||||
}
|
||||
else
|
||||
imgOutputSmall.Save(Path.Combine(imgState.DestDir.FullName, imgState.NomeFileSmall), thisFormat);
|
||||
|
||||
//imgOutputSmall.Dispose();
|
||||
|
||||
//g1.Dispose();
|
||||
|
||||
//if (File.Exists(Path.Combine(DestDir.FullName, "Temp_" + NomeFileBig)))
|
||||
// File.Delete(Path.Combine(DestDir.FullName, "Temp_" + NomeFileBig));
|
||||
{
|
||||
if (thisFormat.Equals(ImageFormat.Jpeg))
|
||||
SalvaImmagineCustomQuality(imgOutputSmall, tnFileName, picSettings.JpegQualityMin);
|
||||
else
|
||||
imgOutputSmall.Save(tnFileName, thisFormat);
|
||||
}
|
||||
}
|
||||
|
||||
private void SalvaImmagineCustomQuality(Bitmap imageToSave, string nomeFileFinale, long quality)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue