You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that when using for loops, magick acts much like the values are passed by reference rather than value (understandable, as these are externalptrs). However, I found this behavior a bit unexpected.
Toy example:
library(magick)
cutter <- function(imgs) {
for (i in seq_along(imgs)) {
img <- magick::image_crop(imgs[i], "100")
imgs[i] <- img
}
imgs
}
image_info(logo)
#> format width height colorspace matte filesize density
#> 1 GIF 640 480 sRGB FALSE 28576 72x72
image_info(cutter(logo))
#> format width height colorspace matte filesize density
#> 1 GIF 100 480 sRGB FALSE 0 72x72
image_info(logo)
#> format width height colorspace matte filesize density
#> 1 GIF 100 480 sRGB FALSE 0 72x72
The text was updated successfully, but these errors were encountered:
One part that is odd is that the final image_info doesn't do what I expect. But when reading the logo in from disk each call, it does do what I expect:
It appears that when using
for
loops,magick
acts much like the values are passed by reference rather than value (understandable, as these are externalptrs). However, I found this behavior a bit unexpected.Toy example:
The text was updated successfully, but these errors were encountered: