Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add function fpr_photo_rename to sort photos into directories and append photo name to end of photo file name #39

Open
NewGraphEnvironment opened this issue Oct 23, 2023 · 5 comments

Comments

@NewGraphEnvironment
Copy link
Owner

may as well use fpr for this for now. will close this when added NewGraphEnvironment/dff-2022#65

@NewGraphEnvironment
Copy link
Owner Author

NewGraphEnvironment commented Oct 30, 2023

could just append the _ds_ef1 or _ds as the col_string_add by pointing to location column after running some iteration of tidyr::separate(local_name, into = c('site_id', 'location', 'ef'), remove = F) type of thing to get site_id and ds_ef1 type split..... would reduce the size of the photo name and reduce risk of issues related to long file names we have seen in the past.....

may want to use a mutate and stringr::strsplit https://stackoverflow.com/questions/49752900/strsplit-and-keep-part-before-first-underscore though

@NewGraphEnvironment
Copy link
Owner Author

when photos are resized from original we change their extension to .JPG. This can cause errors in the function because the id of the photo is now different. Ideally we will resize and sort at the same time but for now we will put a mutate in the function to assume all .jpg are .JPG. This is a bit fragile but will do for now

@NewGraphEnvironment
Copy link
Owner Author

interestingly - the capitalization of .JPG vs .jpg is not an issue. not revising

@NewGraphEnvironment NewGraphEnvironment changed the title add function to sort photos into directories and append photo name to end of photo file name add function fpr_photo_rename to sort photos into directories and append photo name to end of photo file name Nov 1, 2023
@NewGraphEnvironment
Copy link
Owner Author

make default param col_string_append = location as per tidyr::separate(local_name, into = c('site_id', 'location'), remove = F, extra = "merge") call in fiss_site_tidy.R in

reason is to keep photo names as short as possible. b/c they are sorted to directories site_id is redundant

NewGraphEnvironment added a commit to NewGraphEnvironment/fish_passage_peace_2023_reporting that referenced this issue Nov 1, 2023
@NewGraphEnvironment
Copy link
Owner Author

NewGraphEnvironment commented Oct 29, 2024

just added photo_extra3 - 5 to the function but if they are not there in the dataframe the function now fails with

Error in `stopifnot()`:
ℹ In argument: `photo_renamed = dplyr::case_when(...)`.
Caused by error in `dplyr::case_when()`:
! Failed to evaluate the right-hand side of formula 5.
Caused by error:
! object 'photo_extra5_tag' not found
Backtrace:
  1. fpr::fpr_photo_rename(...)
 18. janitor::make_clean_names(...)
 19. janitor:::warn_micro_mu(string = string, replace = replace)
 20. base::grepl(x = string, pattern = current_unicode, fixed = TRUE)
 21. base::is.factor(x)
 22. 

The function fails if there is no photo_extra5_tag (like one of the old monitoring forms). removed the 5th one for now. Tried to abstrac the name of the tag column but couldn't get it to work yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant