what's the most painless way to programmatically open a PNG file on my computer, rotate it 90 degrees, then save it as another PNG file - with no loss of quality and no other changes? it's a five-second task in microsoft paint but all of the plotting, raster, image, device answers to related SO questions have me confused about the simplest way to do this? thanks
Asked
Active
Viewed 3,431 times
2 Answers
4
Try package magick
:
library(magick)
newlogo <- image_read("https://www.r-project.org/logo/Rlogo.png")
newlogo <- image_scale(newlogo, "400x400") # logo is too big
# rotate
image_rotate(newlogo, 90)
# save
image_rotate(newlogo, 45) %>% image_write("newlogoRotated.png")
I think that's the easiest way !

Victorp
- 13,636
- 2
- 51
- 55
-
Uh... why the scale? That will produce a different image – leonbloy Jul 10 '17 at 19:28
-
The original logo is 800x700, a little large for RStudio viewer, it's just for the demo – Victorp Jul 10 '17 at 19:34