Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static string LoadAndProcessImageUrl(this DocumentCardSet documentCardSet
}
}

if (documentCardSet.ConvertToCmyk)
if (documentCardSet.GetConvertToCmyk(config))
{
imageFromEmbeddedUrl.ConvertToCmyk();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
using System.Text.Json.Serialization;

namespace Argumentum.AssetConverter
{
public class DocumentCardSet
{

public string CardSetName { get; set; }


//public string TemplateDocumentName { get; set; }

public int NbCopies { get; set; } = 1;


public bool SaveOriginalImage { get; set; } = true;

public bool ConvertToCmyk { get; set; } = true;

public DocumentCard FrontCards { get; set; } = new DocumentCard();

public DocumentCard BackCards { get; set; } = new DocumentCard();

}
using System.Text.Json.Serialization;

namespace Argumentum.AssetConverter
{
public class DocumentCardSet
{

public string CardSetName { get; set; }


//public string TemplateDocumentName { get; set; }

public int NbCopies { get; set; } = 1;


public bool SaveOriginalImage { get; set; } = true;

public bool ConvertToCmyk { get; set; } = true;

/// <summary>CMYK conversion for Debug builds (preview-friendly, smaller files).</summary>
public bool ConvertToCmykDebug { get; set; } = false;

/// <summary>CMYK conversion for Release builds (printer quality).</summary>
public bool ConvertToCmykRelease { get; set; } = true;

public bool GetConvertToCmyk(AssetConverterConfig config)
=> config.UseDebugParams ? ConvertToCmykDebug : ConvertToCmykRelease;

public DocumentCard FrontCards { get; set; } = new DocumentCard();

public DocumentCard BackCards { get; set; } = new DocumentCard();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void GenerateBackFirstOneDocPerBack(string baseName, List<CardImages> car
GeneratePdfsFromImages(targetFiles, overwriteExistingDocs);
}

public void GeneratePrintAndPlay(string fileName, CardSetDocumentConfig docConfig, List<CardImages> images, bool configOverwriteExistingDocs)
public void GeneratePrintAndPlay(string fileName, CardSetDocumentConfig docConfig, List<CardImages> images, bool configOverwriteExistingDocs, bool useReleaseMode = false)
{
if (File.Exists(fileName) && !configOverwriteExistingDocs)
{
Expand All @@ -146,15 +146,13 @@ public void GeneratePrintAndPlay(string fileName, CardSetDocumentConfig docConfi
return;
}

// 1. Lire toutes les images en mémoire une seule fois
// Convert to JPEG Q=85 for Print&Play to reduce PDF size (PNG lossless = 223 MB → ~15-30 MB)
var frontImagesData = images
.Select(img => !string.IsNullOrEmpty(img.Front) && File.Exists(img.Front) ? ConvertToJpeg(File.ReadAllBytes(img.Front), 85) : null)
.ToList();
// 1. Read images — JPEG Q=85 for Debug (Edge preview), PNG lossless for Release (printer)
byte[] ProcessImage(string path) => !string.IsNullOrEmpty(path) && File.Exists(path)
? (useReleaseMode ? File.ReadAllBytes(path) : ConvertToJpeg(File.ReadAllBytes(path), 85))
: null;

var backImagesData = images
.Select(img => !string.IsNullOrEmpty(img.Back) && File.Exists(img.Back) ? ConvertToJpeg(File.ReadAllBytes(img.Back), 85) : null)
.ToList();
var frontImagesData = images.Select(img => ProcessImage(img.Front)).ToList();
var backImagesData = images.Select(img => ProcessImage(img.Back)).ToList();

// La logique de livret sera gérée à l'intérieur de PrintAndPlayDocument
// if (isBooklet) { ... }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public void GenerateCardSetDocuments(ConcurrentDictionary<(CardSetDocumentConfig
break;
case CardDocumentFormat.PrintAndPlay:
objPdfManager.GeneratePrintAndPlay(baseName, docImageList.Key.document,
docImageList.Value, AssetConverterConfig.OverwriteExistingDocs);
docImageList.Value, AssetConverterConfig.OverwriteExistingDocs,
AssetConverterConfig.UseReleaseParams);
break;
default:
throw new InvalidOperationException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ public class WebBasedGeneratorConfig
{
CardSetName = KnownCardSets.RulesPrintAndPlay,
NbCopies = 1,
ConvertToCmyk = false,
SaveOriginalImage = false,
FrontCards = new DocumentCard()
{
Expand All @@ -528,7 +527,6 @@ public class WebBasedGeneratorConfig
{
CardSetName = KnownCardSets.FallaciesPrintAndPlay,
NbCopies = 1,
ConvertToCmyk = false,
SaveOriginalImage = false,
FrontCards = new DocumentCard()
{
Expand Down Expand Up @@ -566,7 +564,6 @@ public class WebBasedGeneratorConfig
{
CardSetName = KnownCardSets.MemoPrintAndPlay,
NbCopies = 5,
ConvertToCmyk = false,
SaveOriginalImage = false,
FrontCards = new DocumentCard()
{
Expand Down Expand Up @@ -602,7 +599,6 @@ public class WebBasedGeneratorConfig
{
CardSetName = KnownCardSets.ScenariiPrintAndPlay,
NbCopies = 1,
ConvertToCmyk = false,
SaveOriginalImage = false,
FrontCards = new DocumentCard()
{
Expand Down