Skip to content

Normalize dimension of images in report

I used this function in seinebasin2 to compute the out.width parameter of chunks containing one png image in order to get images with same dpi even if they have different dimensions:

get_outwidth4png <- function(file, dpi = 96 * 1.5, page.width = 18 / 2.54) {
    pp <- png::readPNG(file)
    y <- dim(pp)[2]
    paste0(min(100, round(y / (page.width * dpi) * 100)), "%")
}

Could be great to implement it in the package.