R determine the width and height of the image in pixels

Say I have an image on disk, name it image.jpg, how can I determine what is the width and height of the image in pixels using the statistical language R.

I don’t know where to start, so there is no minimal example that I am afraid of.

If someone can just advise the package and function, I can probably work out the rest.

+6
source share
1 answer

You can use jpeg package. The code should be pretty straightforward:

 require(jpeg) img <- readJPEG("myimage.jpg") dim(img) [1] 700 700 3 

The same author (Simon Urbanek) also provided the png and tiff package, which has functions with similar syntax ( readPNG and readTIFF )

+7
source

Source: https://habr.com/ru/post/972910/


All Articles