Skip to content

Commit 5d9ad7a

Browse files
committed
New post
1 parent 250e6b4 commit 5d9ad7a

File tree

3 files changed

+478
-12
lines changed

3 files changed

+478
-12
lines changed

_Rmd/renderblog.R

Lines changed: 77 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,6 @@ diegpost_draft <- function(file) {
9393
# file <- "bertin_dots"
9494
# diegpost_draft(file)
9595

96-
97-
98-
plots <- list.files("./assets/img/blog", pattern = "png$", full.names = TRUE)
99-
lapply(plots, knitr::plot_crop)
100-
101-
knitr::plot_crop("./assets/img/drafts/xxx_celestial_map_cn-1.png")
102-
103-
rm(list = ls())
104-
105-
106-
10796
#Render 2019-04-27-Using-CountryCodes ----
10897

10998
#diegpost("2019-04-27-Using-CountryCodes")
@@ -123,7 +112,83 @@ rm(list = ls())
123112

124113
# diegpost("2022-05-25-tidyterra")
125114
# diegpost("2019-05-13-Where-in-the-world")
126-
diegpost("2025-10-24-mapping-antarctica")
115+
diegpost("2025-10-25-mapping-antarctica")
116+
117+
118+
119+
im <- list.files("./assets/img/blog", pattern = "png$", full.names = TRUE)
120+
121+
122+
lapply(im, function(x){
123+
124+
file.copy(x, "./assets/img/towebp/")
125+
unlink(x)
126+
127+
})
128+
129+
130+
plots <- list.files("./assets/img/towebp", pattern = "png$", full.names = TRUE)
131+
lapply(plots, knitr::plot_crop)
132+
133+
134+
135+
# Try converting to webp
136+
137+
138+
im <- list.files("./assets/img/towebp", pattern = "png$", full.names = TRUE)
139+
140+
x <- im[3]
141+
142+
a <- lapply(im, function(x){
143+
144+
f <- png::readPNG(x)
145+
146+
out <- gsub(".png$", ".webp", x)
147+
dim(f)
148+
aa <- try(webp::write_webp(f, out), silent = TRUE)
149+
150+
if (class(aa) == "try-error"){
151+
file.copy(x, "assets/img/blognoconv")
152+
unlink(x)
153+
154+
} else {
155+
file.copy(out, "assets/img/blog")
156+
unlink(out)
157+
unlink(x)
158+
}
159+
160+
})
161+
162+
163+
# Fix img url
164+
165+
allmds <- list.files("./collections/", recursive = TRUE, pattern = ".md$", full.names = TRUE)
166+
167+
for (newfile in allmds){
168+
message(newfile, "\n")
169+
170+
lines <- readLines(newfile)
171+
newlines <- gsub('<img src="../assets/img',
172+
'<img src="https://dieghernan.github.io/assets/img', lines)
173+
newlines <- gsub('(../assets/img',
174+
'(https://dieghernan.github.io/assets/img',
175+
newlines, fixed = TRUE)
176+
177+
178+
writeLines(newlines, newfile)
179+
}
180+
181+
182+
183+
184+
185+
186+
187+
188+
knitr::plot_crop("./assets/img/drafts/xxx_celestial_map_cn-1.png")
189+
190+
rm(list = ls())
191+
127192

128193
knitr::plot_crop("./assets/img/blog/20221017-6-finalplot-1.png")
129194

0 commit comments

Comments
 (0)