-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 left-padding to Atlas output filenames for better ordering #31309
Labels
Comments
On it, will make a PR shortly. |
kannes
pushed a commit
to kannes/QGIS
that referenced
this issue
Apr 20, 2023
This will result in output filenames that are left-padded with leading zeros. They all have the same length as the required maximum length is determined by `length(to_string(@atlas_totalfeatures))`. E. g. "output_1.png" -> "output_01.png". The motivation for this is safer and more deterministic ordering of the output files. Different OSs, file managers or video editing tools might order numbered files differently if there are no leading zeros. The secondary benefit is a fixed length of the filenames. For example when turning Atlas output into a video with ffmpeg, the common approach is to use a fixed size placeholder in the input string like `-i output_%03d.png`. This won't work if the filenames have different lengths. The alternative approach of using globbing `-pattern_type glob -i 'output_*.jpg'` depends on the shell's ordering.
kannes
added a commit
to kannes/QGIS
that referenced
this issue
Apr 20, 2023
This will result in output filenames that are left-padded with leading zeros. They all have the same length as the required maximum length is determined by `length(to_string(@atlas_totalfeatures))`. E. g. "output_1.png" -> "output_01.png". The motivation for this is safer and more deterministic ordering of the output files. Different OSs, file managers or video editing tools might order numbered files differently if there are no leading zeros. The secondary benefit is a fixed length of the filenames. For example when turning Atlas output into a video with ffmpeg, the common approach is to use a fixed size placeholder in the input string like `-i output_%03d.png`. This won't work if the filenames have different lengths. The alternative approach of using globbing `-pattern_type glob -i 'output_*.jpg'` depends on the shell's ordering.
alexbruy
added
the
Print Layouts
Related to QGIS Print Layouts, Atlas or Reporting frameworks
label
Dec 7, 2023
@kannes are you still working on that? |
Huh, not sure what happened there in 2023. Looks like I wrote the code but stopped when tests were involved? I won't be able to work on this soon, please feel invites to take anything from my branch, with our without attribution, and make a PR. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Feature description.
I propose to change the default output filename expression used by Atlas from
'output_'||@atlas_featurenumber
to
'output_' || lpad(@atlas_featurenumber, length(to_string(@atlas_totalfeatures)), 0)
This will result in output filenames that are left-padded with leading zeros. They all have the same length as the required maximum length is determined by
length(to_string(@atlas_totalfeatures))
.The motivation for this is safer and more deterministic ordering of the output files. Different OSs, file managers or video editing tools might order numbered files differently if there are no leading zeros.
The secondary benefit is a fixed length of the filenames.
For example when turning Atlas output into a video with ffmpeg, the common approach is to use a fixed size placeholder in the input string like
-i output_%03d.png
. This won't work if the filenames have different lengths. The alternative approach of using globbing-pattern_type glob -i 'output_*.jpg'
depends on the shell's ordering (see the ls example above I guess).For example
ls
(at least on my system) will order an example output alphabetically like this:while in my file manager (Thunar) it looks like this as it considers the numbers separately:
If we pad with leading zeros, both of these exemplary tools would display the same order.
Of course people can probably configure their tools to a different order but that seems like an unnecessarily complicated thing to ask for if we could simple pad the output nicely.
Additional context
I meant to add this change in a Pull Request but the complexity of doing a proper code submission is scaring me off (not the fault of QGIS but C++ and tests and proper software development processes in general ;) ). I think I have identified all occurances in the code and edited them correctly in https://github.com/kannes/QGIS/commits/padded_atlas_output but I have no idea if tests are needed, I would need to set up an environment to compile etc. Sorry but this Feature Request is all I can do. I hope it is detailed enough that the work load is as small as possible.
The text was updated successfully, but these errors were encountered: