COPCSE-NTNU / thesis-NTNU

An NTNU thesis LaTeX document class for bachelor, master, and PhD theses
MIT License
96 stars 369 forks source link

Adds enforcing of image dpi within document #35

Closed morngrar closed 2 years ago

morngrar commented 3 years ago

This PR adds enforcing of the DPI of images within the document to 150, which is the minimum to pass the validation of "grafisk senter". I chose to put the command in the main preamble, so that the user could choose to increase this if wanted.

This option greatly simplified our process of validation, so I thought it would be worthwhile to send a PR.

ifarup commented 3 years ago

Thanks. Very good point with the requirement from 'grafisk senter'. Exactly what does this command do? Does it check that the image files satisfy a minimum DPI, or does it do any actual image conversion/rescaling in generating the PDF output file? In the latter case, it could cause problems for students writing about image processing related topics where a one-to-one pixel level image representation might be needed in the PDFs. Does it apply to all image input formats, or only PDF images?

I also see that this TeX primitive is available only for the pdfTeX engine, so having it as a part of the template could potentially cause problems for those using the template on a stand-alone LaTeX installation (yes, I am aware that this applies also to the setup for gnuplot that we have actually included in the template, and I am not too happy with it...):

https://www.overleaf.com/learn/latex/TeX_primitives_listed_by_TeX_engine

morngrar commented 3 years ago

I'm not quite sure of the specifics, but it seems to adjust the scaling of the images, such that the puxel density at scaling factor 1 matches the supplied dpi. A png doesn't after all have a dpi, it only has pixels. And this is what the validation checks.

So instead of fiddling and guessing at the sizes of the images to get an acceptable dpi for printing, this command gives you an acceptable dpi from the get go, and then you can either scale the image down inside latex, or create a larger image.

We actually wasted time on enlarging some images needlessly before I added the command.

As far as I can tell, this works in both texlive and overleaf, which I'd think would cover most use cases? 🤔 I'm an intermediate latex user, to be fair.

morngrar commented 3 years ago

Ah, I now see that png has an optional header for dpi.

What I believe this to do, is overwrite any dpi-settings of images, and enforce scaling of the output to the target. This might indeed cause problems in the case you outlined above.

Most of our figures have been screen shots and output from draw.io, and these files don't seem to have a dpi header.

What if I redo this as an optional class option instead?

ifarup commented 3 years ago

A class option would be perfect! It should probably be documented in thesis.tex also.

morngrar commented 3 years ago

A class option would be perfect! It should probably be documented in thesis.tex also.

I'll take a look at it when things have quieted down for the semester. Should the dpi-emforcing be opt-in or opt-out?

ifarup commented 3 years ago

I am leaning towards opt-in due to the potential problems it may cause for users on other LaTeX backends than pdfTeX (TeX, LuaTeX, XeTeX).

ifarup commented 2 years ago

@morngrar Any news about this?

morngrar commented 2 years ago

I haven't worked on this since. Honestly as soon as summer hit I forgot about it 😅

I don't foresee being able to prioritize this for some time. I'll add it to my calendar, but no promises.

You may close the issue if you wish, and I'll do a new PR if and when I have time to do this.

ifarup commented 2 years ago

OK, I see. Fine, thanks for the feedback!