Reputation: 10516
Suppose I have an image on disk, image.jpg
. How can I determine image width in pixels using R?
Upvotes: 16
Views: 9262
Reputation: 51670
You can use the jpeg
package.
Code should be pretty self-explanatory:
require(jpeg)
img <- readJPEG("myimage.jpg")
dim(img)
[1] 700 700 3
The same author (Simon Urbanek) also provided the png
and tiff
package, that have functions with similar syntax (readPNG
and readTIFF
)
Upvotes: 19