How do I fix terrible image scaling in Apache FOP?












0















We're currently using apache fop to render a bunch of images in PDF format, but we've notice that the quality of just about any image is complete garbage and anything with text in it is incredibly unreadable.



I have looked through the documentation about source and target resolutions here.



And I thought that maybe I could force fit some good image quality in by assuming a default (source) resolution of 72 pixels per inch for all bitmaps/pngs/etc and desiring a target resolution of 300 pixels per inch. I figured this would theoretically cause FOP to cram way more image into a smaller space netting me an increase in quality with less of a need to smash my images into such a small space. Also I did the math and before where things were 72 72 it seemed like we were getting 5 * 72 = 375 pixel Nokia phone screen resolutions so I was like no wonder they are terrible quality.



Well, it seems like even with a target PPI of 300 instead of netting me a generous space of about 1500 pixels, I'm still getting the same crappy Nokia phone quality. I tried many combinations of source and target PPI 300/300 72/300 and 300/72 respectively, but nothing seems to cause any form or resampling or better image output. In the end I'm always left with this.



terrible image quality.



This is an actual screenshot of my PDF at almost full screen size. It may be worth noting that we are using the org.apache.commons.codec.binary.Base64 encoder to take images from memory and turn them into strings to embed into PDF. I don't know what kind of compression if any is being done through this encoder, but I hope to dump a string to the filesystem soon to take a look and make sure that isn't the issue.



In the meantime, does anyone know what PPI settings I might have messed up or what better options I may have to render clear cleaner images out to PDF with FOP?










share|improve this question























  • What image format are you using? According to the documentation, source resolution applies only to formats that don't have an intrinsic resolution.

    – Tony Graham
    Nov 14 '18 at 13:40











  • The images we've tested are in PNG format. I haven't tested other formats, but I'll look at it shortly.

    – TheeRFG
    Nov 14 '18 at 18:27






  • 2





    A PNG knows its own resolution, so the source resolution setting will not apply. Consider changing the resolution of the PNG to 300dpi and then doing a 'pixel resize' to the largest size at 300dpi that won't cause FOP to scale it down to fit the available space.

    – Tony Graham
    Nov 15 '18 at 8:49
















0















We're currently using apache fop to render a bunch of images in PDF format, but we've notice that the quality of just about any image is complete garbage and anything with text in it is incredibly unreadable.



I have looked through the documentation about source and target resolutions here.



And I thought that maybe I could force fit some good image quality in by assuming a default (source) resolution of 72 pixels per inch for all bitmaps/pngs/etc and desiring a target resolution of 300 pixels per inch. I figured this would theoretically cause FOP to cram way more image into a smaller space netting me an increase in quality with less of a need to smash my images into such a small space. Also I did the math and before where things were 72 72 it seemed like we were getting 5 * 72 = 375 pixel Nokia phone screen resolutions so I was like no wonder they are terrible quality.



Well, it seems like even with a target PPI of 300 instead of netting me a generous space of about 1500 pixels, I'm still getting the same crappy Nokia phone quality. I tried many combinations of source and target PPI 300/300 72/300 and 300/72 respectively, but nothing seems to cause any form or resampling or better image output. In the end I'm always left with this.



terrible image quality.



This is an actual screenshot of my PDF at almost full screen size. It may be worth noting that we are using the org.apache.commons.codec.binary.Base64 encoder to take images from memory and turn them into strings to embed into PDF. I don't know what kind of compression if any is being done through this encoder, but I hope to dump a string to the filesystem soon to take a look and make sure that isn't the issue.



In the meantime, does anyone know what PPI settings I might have messed up or what better options I may have to render clear cleaner images out to PDF with FOP?










share|improve this question























  • What image format are you using? According to the documentation, source resolution applies only to formats that don't have an intrinsic resolution.

    – Tony Graham
    Nov 14 '18 at 13:40











  • The images we've tested are in PNG format. I haven't tested other formats, but I'll look at it shortly.

    – TheeRFG
    Nov 14 '18 at 18:27






  • 2





    A PNG knows its own resolution, so the source resolution setting will not apply. Consider changing the resolution of the PNG to 300dpi and then doing a 'pixel resize' to the largest size at 300dpi that won't cause FOP to scale it down to fit the available space.

    – Tony Graham
    Nov 15 '18 at 8:49














0












0








0








We're currently using apache fop to render a bunch of images in PDF format, but we've notice that the quality of just about any image is complete garbage and anything with text in it is incredibly unreadable.



I have looked through the documentation about source and target resolutions here.



And I thought that maybe I could force fit some good image quality in by assuming a default (source) resolution of 72 pixels per inch for all bitmaps/pngs/etc and desiring a target resolution of 300 pixels per inch. I figured this would theoretically cause FOP to cram way more image into a smaller space netting me an increase in quality with less of a need to smash my images into such a small space. Also I did the math and before where things were 72 72 it seemed like we were getting 5 * 72 = 375 pixel Nokia phone screen resolutions so I was like no wonder they are terrible quality.



Well, it seems like even with a target PPI of 300 instead of netting me a generous space of about 1500 pixels, I'm still getting the same crappy Nokia phone quality. I tried many combinations of source and target PPI 300/300 72/300 and 300/72 respectively, but nothing seems to cause any form or resampling or better image output. In the end I'm always left with this.



terrible image quality.



This is an actual screenshot of my PDF at almost full screen size. It may be worth noting that we are using the org.apache.commons.codec.binary.Base64 encoder to take images from memory and turn them into strings to embed into PDF. I don't know what kind of compression if any is being done through this encoder, but I hope to dump a string to the filesystem soon to take a look and make sure that isn't the issue.



In the meantime, does anyone know what PPI settings I might have messed up or what better options I may have to render clear cleaner images out to PDF with FOP?










share|improve this question














We're currently using apache fop to render a bunch of images in PDF format, but we've notice that the quality of just about any image is complete garbage and anything with text in it is incredibly unreadable.



I have looked through the documentation about source and target resolutions here.



And I thought that maybe I could force fit some good image quality in by assuming a default (source) resolution of 72 pixels per inch for all bitmaps/pngs/etc and desiring a target resolution of 300 pixels per inch. I figured this would theoretically cause FOP to cram way more image into a smaller space netting me an increase in quality with less of a need to smash my images into such a small space. Also I did the math and before where things were 72 72 it seemed like we were getting 5 * 72 = 375 pixel Nokia phone screen resolutions so I was like no wonder they are terrible quality.



Well, it seems like even with a target PPI of 300 instead of netting me a generous space of about 1500 pixels, I'm still getting the same crappy Nokia phone quality. I tried many combinations of source and target PPI 300/300 72/300 and 300/72 respectively, but nothing seems to cause any form or resampling or better image output. In the end I'm always left with this.



terrible image quality.



This is an actual screenshot of my PDF at almost full screen size. It may be worth noting that we are using the org.apache.commons.codec.binary.Base64 encoder to take images from memory and turn them into strings to embed into PDF. I don't know what kind of compression if any is being done through this encoder, but I hope to dump a string to the filesystem soon to take a look and make sure that isn't the issue.



In the meantime, does anyone know what PPI settings I might have messed up or what better options I may have to render clear cleaner images out to PDF with FOP?







image xsl-fo fop apache-fop






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 3:32









TheeRFGTheeRFG

1521314




1521314













  • What image format are you using? According to the documentation, source resolution applies only to formats that don't have an intrinsic resolution.

    – Tony Graham
    Nov 14 '18 at 13:40











  • The images we've tested are in PNG format. I haven't tested other formats, but I'll look at it shortly.

    – TheeRFG
    Nov 14 '18 at 18:27






  • 2





    A PNG knows its own resolution, so the source resolution setting will not apply. Consider changing the resolution of the PNG to 300dpi and then doing a 'pixel resize' to the largest size at 300dpi that won't cause FOP to scale it down to fit the available space.

    – Tony Graham
    Nov 15 '18 at 8:49



















  • What image format are you using? According to the documentation, source resolution applies only to formats that don't have an intrinsic resolution.

    – Tony Graham
    Nov 14 '18 at 13:40











  • The images we've tested are in PNG format. I haven't tested other formats, but I'll look at it shortly.

    – TheeRFG
    Nov 14 '18 at 18:27






  • 2





    A PNG knows its own resolution, so the source resolution setting will not apply. Consider changing the resolution of the PNG to 300dpi and then doing a 'pixel resize' to the largest size at 300dpi that won't cause FOP to scale it down to fit the available space.

    – Tony Graham
    Nov 15 '18 at 8:49

















What image format are you using? According to the documentation, source resolution applies only to formats that don't have an intrinsic resolution.

– Tony Graham
Nov 14 '18 at 13:40





What image format are you using? According to the documentation, source resolution applies only to formats that don't have an intrinsic resolution.

– Tony Graham
Nov 14 '18 at 13:40













The images we've tested are in PNG format. I haven't tested other formats, but I'll look at it shortly.

– TheeRFG
Nov 14 '18 at 18:27





The images we've tested are in PNG format. I haven't tested other formats, but I'll look at it shortly.

– TheeRFG
Nov 14 '18 at 18:27




2




2





A PNG knows its own resolution, so the source resolution setting will not apply. Consider changing the resolution of the PNG to 300dpi and then doing a 'pixel resize' to the largest size at 300dpi that won't cause FOP to scale it down to fit the available space.

– Tony Graham
Nov 15 '18 at 8:49





A PNG knows its own resolution, so the source resolution setting will not apply. Consider changing the resolution of the PNG to 300dpi and then doing a 'pixel resize' to the largest size at 300dpi that won't cause FOP to scale it down to fit the available space.

– Tony Graham
Nov 15 '18 at 8:49












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292799%2fhow-do-i-fix-terrible-image-scaling-in-apache-fop%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292799%2fhow-do-i-fix-terrible-image-scaling-in-apache-fop%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python