1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-11-16 12:20:12 +01:00

fix: use JPEGFactory for jpeg

This commit is contained in:
sbplat 2023-12-24 12:52:55 -05:00
parent 1efefcfcb8
commit 3f50979d3e

View File

@ -266,7 +266,10 @@ public class PdfUtils {
} else { } else {
BufferedImage image = ImageIO.read(file.getInputStream()); BufferedImage image = ImageIO.read(file.getInputStream());
BufferedImage convertedImage = ImageProcessingUtils.convertColorType(image, colorType); BufferedImage convertedImage = ImageProcessingUtils.convertColorType(image, colorType);
PDImageXObject pdImage = LosslessFactory.createFromImage(doc, convertedImage); // Use JPEGFactory if it's JPEG since JPEG is lossy
PDImageXObject pdImage = (contentType != null && contentType.equals("image/jpeg"))
? JPEGFactory.createFromImage(doc, convertedImage)
: LosslessFactory.createFromImage(doc, convertedImage);
addImageToDocument(doc, pdImage, fitOption, autoRotate); addImageToDocument(doc, pdImage, fitOption, autoRotate);
} }
} }