|
|
@@ -115,37 +115,10 @@ begin
|
|
|
|
|
|
if FileExists(OutBase + '.png') then
|
|
|
begin
|
|
|
+ // Return the full‑resolution PNG generated by pdftoppm.
|
|
|
+ // Do NOT overwrite it with a scaled-down image; scaling is handled in UI rendering.
|
|
|
Result := OutBase + '.png';
|
|
|
- // Scale down to requested cover size
|
|
|
- if (W > 0) and (H > 0) then
|
|
|
- begin
|
|
|
- SrcImg := TLazIntfImage.Create(0, 0);
|
|
|
- Img := TLazIntfImage.Create(W, H);
|
|
|
- Canvas := TLazCanvas.Create(Img);
|
|
|
- Png := TPortableNetworkGraphic.Create;
|
|
|
- try
|
|
|
- SrcImg.LoadFromFile(Result);
|
|
|
- Img.FillPixels(colTransparent);
|
|
|
- if (SrcImg.Width > 0) and (SrcImg.Height > 0) then
|
|
|
- begin
|
|
|
- scale := Min(W / SrcImg.Width, H / SrcImg.Height);
|
|
|
- if scale > 1 then scale := 1;
|
|
|
- dstW := Round(SrcImg.Width * scale);
|
|
|
- dstH := Round(SrcImg.Height * scale);
|
|
|
- offX := (W - dstW) div 2;
|
|
|
- offY := (H - dstH) div 2;
|
|
|
- Canvas.StretchDraw(offX, offY, dstW, dstH, SrcImg);
|
|
|
- end;
|
|
|
- Png.Assign(Img);
|
|
|
- Png.SaveToFile(Result);
|
|
|
- LogInfoFmt('Generated cover: %s', [Result]);
|
|
|
- finally
|
|
|
- Png.Free;
|
|
|
- Canvas.Free;
|
|
|
- Img.Free;
|
|
|
- SrcImg.Free;
|
|
|
- end;
|
|
|
- end;
|
|
|
+ LogInfoFmt('Generated cover: %s', [Result]);
|
|
|
end
|
|
|
else
|
|
|
begin
|