Unable to resize an image in Bookdown

Viewed 174

We have an image in hdf5 file, which we want to extract and drop it into the BookDown pdf

here is the code which is doing that

insertImage <- function(hdfFilepath, datasetPath) {
  library(rhdf5)
  library(magick)
  hdfimagedata <- h5read(hdfFilepath, datasetPath)
  image <- image_read(hdfimagedata)
  image <- image_scale(image,"300%")
  plot(image)
}

what every I give the scale the image size does no increase and sticks to the size shown below The image is a very HQ image

We have also tried with option of image_scale(image,"2000x2000!") and we also tried fig.height and fig.width options, but did not yield the expected result. The image size remains the same irrespective of any number assigned to height and width

How to enlarge the image i.e. zoom to fit to page

PN: we don not have any problem with render quaility

sample pdf with image

Hi, I got it to maxime but now the image overlaps the text

  image_resize(image,geometry_size_pixels(width = 300, height = 300))

Image overlapping text

And the Image rendered is Inverted too.

here is the header defined in index.rmd

--- 
title: "Document"
author: ""
site: bookdown::bookdown_site
output: bookdown::pdf_book
documentclass: book
classoption: openany,oneside
link-citations: NO
geometry: margin=2cm
description: "This is a minimal example of using the bookdown package to write a book."
language:
  ui:
    chapter_name: 'Chapter'
---

please help

1 Answers

The Solution to the above problem is

insertImage <- function(hdfFilepath, datasetPath) {
  library(rhdf5)
  library(magick)
  hdfimagedata <- h5read(hdfFilepath, datasetPath)
  image <- image_read(hdfimagedata)
  image <- image_scale(image,"300%")
  par(mar=c(0,0,0,0))
  plot(image)
}

This helped

par(mar=c(0,0,0,0))
Related