diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index c53cf01..9efac17 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -2,75 +2,75 @@ name: "🕷️ Bug report" description: Create a report to help us improve labels: - - bug + - bug body: - - type: dropdown - id: toolaffected - attributes: - label: Which tool is affected? - description: CZI Shrink is the GUI application while CZI Compress refers to the CLI tool. - multiple: false - options: - - CZI Compress - - CZI Shrink - validations: - required: true + - type: dropdown + id: toolaffected + attributes: + label: Which tool is affected? + description: CZI Shrink is the GUI application while CZI Compress refers to the CLI tool. + multiple: false + options: + - CZI Compress + - CZI Shrink + validations: + required: true - - type: textarea - attributes: - label: Description - description: Describe the bug and add screenshots if possible/applicable. - placeholder: A clear and concise description of what the bug is. - validations: - required: true + - type: textarea + attributes: + label: Description + description: Describe the bug and add screenshots if possible/applicable. + placeholder: A clear and concise description of what the bug is. + validations: + required: true - - type: textarea - attributes: - label: Steps to reproduce - description: Please include screenshots (if applicable) and relevant logs. - placeholder: | - 1. Go to '...' - 2. Click on '....' - 3. Scroll down to '....' - 4. See error - validations: - required: true + - type: textarea + attributes: + label: Steps to reproduce + description: Please include screenshots (if applicable) and relevant logs. + placeholder: | + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + validations: + required: true - - type: textarea - attributes: - label: Expected behavior - description: A clear and concise description of what you expected to happen. - placeholder: | - 1. Go to '...' - 2. Click on '....' - 3. Scroll down to '....' - 4. See error - validations: - required: true + - type: textarea + attributes: + label: Expected behavior + description: A clear and concise description of what you expected to happen. + placeholder: | + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + validations: + required: true - - type: dropdown - attributes: - label: OS - description: What operating system are you using? - multiple: false - options: - - Windows - - MacOS - - Linux - validations: - required: true + - type: dropdown + attributes: + label: OS + description: What operating system are you using? + multiple: false + options: + - Windows + - MacOS + - Linux + validations: + required: true - - type: input - attributes: - label: OS Version - description: What version and flavor (if applicable) of your OS are you using? - placeholder: Ubuntu 23.10 | Sonoma 14.1.2 | Windows 11 23H2 - validations: - required: true + - type: input + attributes: + label: OS Version + description: What version and flavor (if applicable) of your OS are you using? + placeholder: Ubuntu 23.10 | Sonoma 14.1.2 | Windows 11 23H2 + validations: + required: true - - type: textarea - attributes: - label: Other Context - description: Please add any other context that may be relevant. - validations: - required: false + - type: textarea + attributes: + label: Other Context + description: Please add any other context that may be relevant. + validations: + required: false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 3c8b5ca..eab4623 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ -# STOP - Read this First! +# STOP - Read this First Reporting a security vulnerability? Check out the project's [security policy](https://github.com/zeiss/czicompress/security/policy). @@ -24,7 +24,7 @@ Fixes # (issue) Describe the tests that you ran to verify your changes. Provide instructions to reproduce. -## Checklist: +## Checklist - [ ] I followed the Contributing Guidelines. - [ ] I did a self-review. diff --git a/.github/actions/cmake-build/action.yml b/.github/actions/cmake-build/action.yml index bc4a2b2..f8f7b98 100644 --- a/.github/actions/cmake-build/action.yml +++ b/.github/actions/cmake-build/action.yml @@ -1,27 +1,27 @@ --- -name: 'CMake-Build' -description: 'Install Dependencies + Configure CMake + Build' +name: "CMake-Build" +description: "Install Dependencies + Configure CMake + Build" inputs: path-cache: - description: 'Path to vcpkg cache directory' + description: "Path to vcpkg cache directory" required: true path-toolchain: - description: 'Path to vcpkg tool chain file' + description: "Path to vcpkg tool chain file" required: true os-id: - description: 'Operating System Identifier' + description: "Operating System Identifier" required: true build-type: - description: 'Build Configuration' + description: "Build Configuration" required: true package: - description: 'Using package manager for external dependencies' + description: "Using package manager for external dependencies" required: true platform: - description: 'OS platform' + description: "OS platform" required: true src-dir: - description: 'The directory with the sources' + description: "The directory with the sources" required: true runs: using: "composite" @@ -44,9 +44,9 @@ runs: shell: bash working-directory: ${{inputs.src-dir}} run: | - # We install the following packages: eigen3, catch2, cli11. Installing them with vcpkg (and caching them) - # is faster than downloading and building them from source (which is the default behavior of the CZICompress-build-system). - vcpkg install --triplet ${{inputs.platform}} eigen3 catch2 cli11 + # We install the following packages: eigen3, catch2, cli11. Installing them with vcpkg (and caching them) + # is faster than downloading and building them from source (which is the default behavior of the CZICompress-build-system). + vcpkg install --triplet ${{inputs.platform}} eigen3 catch2 cli11 - name: Configure CMake shell: bash diff --git a/.github/advanced-issue-labeler.yml b/.github/advanced-issue-labeler.yml index 1931eb5..868806f 100644 --- a/.github/advanced-issue-labeler.yml +++ b/.github/advanced-issue-labeler.yml @@ -2,9 +2,9 @@ policy: - section: - id: [toolaffected] - block-list: ['None', 'Other'] + block-list: ["None", "Other"] label: - name: czicompress - keys: ['CZI Compress'] - - name: 'czishrink' - keys: ['CZI Shrink'] + keys: ["CZI Compress"] + - name: "czishrink" + keys: ["CZI Shrink"] diff --git a/.github/workflows/czicompress_cmake.yml b/.github/workflows/czicompress_cmake.yml index bd27554..2c858be 100644 --- a/.github/workflows/czicompress_cmake.yml +++ b/.github/workflows/czicompress_cmake.yml @@ -35,24 +35,32 @@ jobs: platform: x64-windows-static, package: ON, path-cache: '${{ github.workspace }}\vcpkg\installed', - path-toolchain: 'C:/vcpkg/scripts/buildsystems/vcpkg.cmake', - os-id: 'windows', + path-toolchain: "C:/vcpkg/scripts/buildsystems/vcpkg.cmake", + os-id: "windows", } - { name: ubuntu-package-off, - os: ubuntu-20.04, # we want to use an older version in order to increase likelihood that binaries work on other distros + os: ubuntu-20.04, # we want to use an older version in order to increase likelihood that binaries work on other distros platform: x64-linux, package: OFF, - path-cache: '/usr/local/share/vcpkg/installed', - path-toolchain: '/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake', - os-id: 'linux', + path-cache: "/usr/local/share/vcpkg/installed", + path-toolchain: "/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake", + os-id: "linux", } exclude: # From https://github.com/actions/runner/issues/1512 - build: Debug - config: {name: ubuntu-package-off, os: ubuntu-20.04, platform: x64-linux, package: OFF, path-cache: '/usr/local/share/vcpkg/installed', path-toolchain: '/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake', os-id: 'linux'} + config: + { + name: ubuntu-package-off, + os: ubuntu-20.04, + platform: x64-linux, + package: OFF, + path-cache: "/usr/local/share/vcpkg/installed", + path-toolchain: "/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake", + os-id: "linux", + } steps: - - name: Checkout the source codes. uses: actions/checkout@v4 @@ -64,7 +72,7 @@ jobs: build-type: ${{matrix.build}} package: ${{matrix.config.package}} platform: ${{matrix.config.platform}} - src-dir: '${{github.workspace}}/czicompress' + src-dir: "${{github.workspace}}/czicompress" - name: Run unit tests working-directory: ${{github.workspace}}/czicompress/build @@ -77,8 +85,8 @@ jobs: if: ${{ (matrix.config.os == 'windows-latest') && (matrix.build == 'Debug') }} shell: pwsh run: | - choco install OpenCppCoverage -y - echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH + choco install OpenCppCoverage -y + echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH - name: Get Coverage if: ${{ (matrix.config.os == 'windows-latest') && (matrix.build == 'Debug') }} @@ -94,29 +102,29 @@ jobs: fail_ci_if_error: true directory: ${{ github.workspace }}/TestResults verbose: true - token: ${{ secrets.CODECOV_TOKEN }} # required + token: ${{ secrets.CODECOV_TOKEN }} # required - name: Prepare licenses if: matrix.build == 'Release' shell: bash run: | - set -e - mkdir ./czicompress-${{env.name}} - cp -R ./THIRD_PARTY_LICENSES_ARTIFACT_DISTRIBUTION.txt ./czicompress-${{env.name}}/ - cp -R ./build/app/THIRD_PARTY_LICENSES.txt ./czicompress-${{env.name}}/ + set -e + mkdir ./czicompress-${{env.name}} + cp -R ./THIRD_PARTY_LICENSES_ARTIFACT_DISTRIBUTION.txt ./czicompress-${{env.name}}/ + cp -R ./build/app/THIRD_PARTY_LICENSES.txt ./czicompress-${{env.name}}/ # gather the binaries - name: Prepare Linux binaries if: ${{ (matrix.config.os == 'ubuntu-20.04') && (matrix.build == 'Release') }} shell: bash run: | - cp ./build/app/czicompress ./build/capi/libczicompressc.so ./czicompress-${{env.name}}/ + cp ./build/app/czicompress ./build/capi/libczicompressc.so ./czicompress-${{env.name}}/ - name: Prepare Windows binaries if: ${{ (matrix.config.os == 'windows-latest') && (matrix.build == 'Release') }} shell: bash run: | - cp ./build/app/${{matrix.build}}/*.exe ./build/capi/${{matrix.build}}/libczicompressc.dll ./czicompress-${{env.name}}/ + cp ./build/app/${{matrix.build}}/*.exe ./build/capi/${{matrix.build}}/libczicompressc.dll ./czicompress-${{env.name}}/ # upload the build-results to artifacts-store - name: Upload artifacts diff --git a/.github/workflows/czicompress_codeql.yml b/.github/workflows/czicompress_codeql.yml index f04be23..129bbfd 100644 --- a/.github/workflows/czicompress_codeql.yml +++ b/.github/workflows/czicompress_codeql.yml @@ -47,13 +47,13 @@ jobs: - uses: ./.github/actions/cmake-build with: - path-cache: '/usr/local/share/vcpkg/installed' - path-toolchain: '/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake' - os-id: 'linux' + path-cache: "/usr/local/share/vcpkg/installed" + path-toolchain: "/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake" + os-id: "linux" build-type: Release package: ON platform: x64-linux - src-dir: '${{github.workspace}}/czicompress' + src-dir: "${{github.workspace}}/czicompress" - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/czishrink_codeql.yml b/.github/workflows/czishrink_codeql.yml index af1c0ed..28a9dca 100644 --- a/.github/workflows/czishrink_codeql.yml +++ b/.github/workflows/czishrink_codeql.yml @@ -16,7 +16,7 @@ on: # │ │ │ │ │ # │ │ │ │ │ # * * * * * - - cron: '30 2 * * 2' + - cron: "30 2 * * 2" workflow_dispatch: {} permissions: read-all @@ -48,7 +48,7 @@ jobs: path: ${{ github.workspace }}/.nuget/packages key: ${{ runner.os }}-czishrink-nuget-${{ hashFiles('czishrink/**/packages.lock.json') }} restore-keys: | - ${{ runner.os }}-czishrink-nuget- + ${{ runner.os }}-czishrink-nuget- - name: Initialize CodeQL uses: github/codeql-action/init@v3 diff --git a/.github/workflows/czishrink_dotnet.yml b/.github/workflows/czishrink_dotnet.yml index d50ed13..f354252 100644 --- a/.github/workflows/czishrink_dotnet.yml +++ b/.github/workflows/czishrink_dotnet.yml @@ -29,14 +29,8 @@ jobs: matrix: build: [Release, Debug] config: - - { - os: windows-latest, - osfamily: win, - } - - { - os: ubuntu-latest, - osfamily: linux, - } + - {os: windows-latest, osfamily: win} + - {os: ubuntu-latest, osfamily: linux} exclude: # From https://github.com/actions/runner/issues/1512 - build: Debug @@ -107,7 +101,7 @@ jobs: directory: ${{ github.workspace }}/TestResults files: coverage.cobertura.xml verbose: true - token: ${{ secrets.CODECOV_TOKEN }} # required + token: ${{ secrets.CODECOV_TOKEN }} # required - name: Upload dotnet test results uses: actions/upload-artifact@v4 diff --git a/.github/workflows/dependency-review.yaml b/.github/workflows/dependency-review.yaml index d0bf69b..4d9800a 100644 --- a/.github/workflows/dependency-review.yaml +++ b/.github/workflows/dependency-review.yaml @@ -1,5 +1,5 @@ --- -name: 'Dependency Review' +name: "Dependency Review" on: [pull_request] permissions: @@ -9,9 +9,9 @@ jobs: dependency-review: runs-on: ubuntu-latest steps: - - name: 'Checkout Repository' + - name: "Checkout Repository" uses: actions/checkout@v4 - - name: 'Dependency Review' + - name: "Dependency Review" uses: actions/dependency-review-action@v4 with: # Add more licenses as required. Do not add copy-left licenses or licenses incompatible with MIT (for czicompress) and GPL-3.0-or-later (for czishrink) diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml index 6c9e653..b0a3ff5 100644 --- a/.github/workflows/reuse.yml +++ b/.github/workflows/reuse.yml @@ -17,4 +17,4 @@ jobs: steps: - uses: actions/checkout@v4 - name: REUSE Compliance Check - uses: fsfe/reuse-action@v2 # current action version is 2 + uses: fsfe/reuse-action@v2 diff --git a/.mega-linter.yml b/.mega-linter.yml index 7eb76ff..dfbcf05 100644 --- a/.mega-linter.yml +++ b/.mega-linter.yml @@ -8,7 +8,8 @@ APPLY_FIXES: none DISABLE: - COPYPASTE # Comment to enable checks of excessive copy-pastes - - SPELL # Comment to enable checks of spelling mistakes + - SPELL # Comment to enable checks of spelling mistakes + - CSHARP # We are using StyleCop.Analyzers for that DISABLE_ERRORS_LINTERS: - MARKDOWN_MARKDOWN_LINK_CHECK # Make non-blocking due to network timeouts etc. DISABLE_LINTERS: @@ -21,3 +22,4 @@ UPDATED_SOURCES_REPORTER: false TEXT_REPORTER: true EMAIL_REPORTER: false VALIDATE_ALL_CODEBASE: true +YAML_V8R_FILTER_REGEX_EXCLUDE: (.jsonlintrc.yml|advanced-issue-labeler.yml) diff --git a/.reuse/dep5 b/.reuse/dep5 index 5fa7cd5..209f626 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -7,7 +7,7 @@ Files: cla_*.txt czicompress/CMakeSettings.json CODE_OF_CONDUCT.md CONTRIBUTING. Copyright: 2023 Carl Zeiss Microscopy GmbH License: MIT -Files: .github/* .gitignore .gitattributes czicompress/.editorconfig czicompress/.runsettings czicompress/CPPLINT.cfg czicompress/.clang-format +Files: .github/* .gitignore .gitattributes .vscode/* czicompress/.editorconfig czicompress/.runsettings czicompress/CPPLINT.cfg czicompress/.clang-format Copyright: 2023 Carl Zeiss Microscopy GmbH License: CC0-1.0 diff --git a/.v8rrc.yaml b/.v8rrc.yaml new file mode 100644 index 0000000..cd8eee6 --- /dev/null +++ b/.v8rrc.yaml @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: 2023 Carl Zeiss Microscopy GmbH +# +# SPDX-License-Identifier: MIT +--- +# - A custom schema catalog. +# This catalog will be searched ahead of any custom catalogs passed using +# --catalogs or SchemaStore.org +# The format of this is subtly different to the format of a catalog +# passed via --catalogs (which matches the SchemaStore.org format) +customCatalog: + schemas: + - name: GitHub Issue Template configuration # The name of the schema (required) + + # A Minimatch glob expression for matching up file names with a schema (required) + fileMatch: ["**/.github/ISSUE_TEMPLATE/config.yml"] + + # A URL or local file path for the schema location (required) + # Unlike the SchemaStore.org format, which has a `url` key, + # custom catalogs defined in v8r config files have a `location` key + # which can refer to either a URL or local file. + # Relative paths are interpreted as relative to the config file location. + location: https://json.schemastore.org/github-issue-config.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..36bd334 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,25 @@ +{ + "yaml.schemas": { + "https://raw.githubusercontent.com/megalinter/megalinter/main/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json": [ + ".mega-linter.yml" + ], + "https://json.schemastore.org/github-issue-config.json": [ + ".github/ISSUE_TEMPLATE/config.yml" + ], + "https://json.schemastore.org/github-issue-forms.json": [ + ".github/ISSUE_TEMPLATE/bug_report.yml" + ], + "https://json.schemastore.org/github-discussion.json": [ + ".github/DISCUSSION_TEMPLATE/*.yml" + ], + "https://json.schemastore.org/github-workflow.json": [ + ".github/workflows/*.yml" + ], + "https://json.schemastore.org/codecov.json": [ + ".github/codecov.yml" + ], + "https://json.schemastore.org/dependabot-2.0.json": [ + ".github/dependabot.yml" + ] + } +} \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 8bc3392..5a00e31 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -62,7 +62,7 @@ representative at an online or offline event. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -github.microscopy@zeiss.com. +. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the @@ -118,7 +118,7 @@ the community. This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at -https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. +. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). @@ -126,5 +126,5 @@ enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see the FAQ at -https://www.contributor-covenant.org/faq. Translations are available at -https://www.contributor-covenant.org/translations. +. Translations are available at +. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1380aea..a1a8728 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,7 +24,7 @@ If you find yourself wishing for a feature or improvement that doesn't exist in We are always happy to receive code contributions from your side. For all contributions, please respect the following guidelines: -- Make sure to either sign the [Individual](./cla_individual.txt) or the [Corporate](./cla_corporate.txt) Contributor License Agreement (CLA) and send it to github.microscopy@zeiss.com. +- Make sure to either sign the [Individual](./cla_individual.txt) or the [Corporate](./cla_corporate.txt) Contributor License Agreement (CLA) and send it to . - Always associate a PR with either an [issue](#other-issues) or a [feature](#suggesting-a-feature). - Each PR should implement ONE feature or bugfix. If you want to add or fix more than one thing, submit more than one PR. - Do not commit changes to files that are irrelevant to your feature or bugfix. @@ -32,4 +32,4 @@ For all contributions, please respect the following guidelines: - Be aware that the PR review process is not immediate, and is generally proportional to the size of the PR. # Attribution -This template was inspired by https://github.com/nayafia/contributing-template. +This template was inspired by . diff --git a/czicompress/CMakeSettings.json b/czicompress/CMakeSettings.json index 8c3449a..11d1dad 100644 --- a/czicompress/CMakeSettings.json +++ b/czicompress/CMakeSettings.json @@ -4,7 +4,7 @@ "name": "x64-Debug", "generator": "Ninja", "configurationType": "Debug", - "inheritEnvironments": [ "msvc_x64_x64" ], + "inheritEnvironments": ["msvc_x64_x64"], "buildRoot": "${projectDir}\\out\\build\\${name}", "installRoot": "${projectDir}\\out\\install\\${name}", "enableMicrosoftCodeAnalysis": true, @@ -21,8 +21,8 @@ "cmakeCommandArgs": "", "buildCommandArgs": "", "ctestCommandArgs": "", - "inheritEnvironments": [ "msvc_x64_x64" ], + "inheritEnvironments": ["msvc_x64_x64"], "variables": [] } ] -} \ No newline at end of file +} diff --git a/czicompress/README.md b/czicompress/README.md index 9e50aac..578998e 100644 --- a/czicompress/README.md +++ b/czicompress/README.md @@ -17,17 +17,17 @@ The tool is based on [libczi](https://github.com/ZEISS/libczi.git). - [Download](#download) - [Usage](#usage) - - [Examples](#examples) - - [Single file](#single-file) - - [Multiple files (bash shell)](#multiple-files-bash-shell) - - [Multiple files (Powershell)](#multiple-files-powershell) + - [Examples](#examples) + - [Single file](#single-file) + - [Multiple files (bash shell)](#multiple-files-bash-shell) + - [Multiple files (Powershell)](#multiple-files-powershell) - [Build and Test](#build-and-test) - - [Pre-requisites](#pre-requisites) - - [Build in Visual Studio](#build-in-visual-studio) - - [Build in command line](#build-in-command-line) - - [Quick build](#quick-build) - - [Build with preferred compiler](#build-with-preferred-compiler) - - [Tests](#tests) + - [Pre-requisites](#pre-requisites) + - [Build in Visual Studio](#build-in-visual-studio) + - [Build in command line](#build-in-command-line) + - [Quick build](#quick-build) + - [Build with preferred compiler](#build-with-preferred-compiler) + - [Tests](#tests) - [Known issues](#known-issues) - [Guidelines](#guidelines) - [Versioning](#versioning) @@ -41,7 +41,7 @@ Click on the topmost successful run and download the binaries for your platform: * czicompress-windows-64-msvc-package-on-Release for Windows * czicompress-ubuntu-package-off-Release for Linux -Clicking on these artifacts will download a ZIP file with the executable. The executable is a stand-alone binary. You can put it anywhere you like. +Clicking on these artifacts will download a ZIP file with the executable. The executable is a stand-alone binary. You can put it anywhere you like. ## Usage @@ -139,7 +139,7 @@ fi exit $status ~~~ -* Then run +* Then run ~~~sh find -type f -name '*.czi' -not -iname '*.zstd.czi' -exec bash czicompress.sh '{}' \; ~~~ @@ -182,13 +182,13 @@ $files | ForEach-Object { $outFileName = "$($_.DirectoryName)\$($_.BaseName)$outputSuffix$($_.Extension)" Write-Host "$($_) -> $($outFileName)" if ((Test-Path -Path $outFileName)) { - Write-Host "Output file already exists... Removing" - Remove-Item $outFileName + Write-Host "Output file already exists... Removing" + Remove-Item $outFileName } if ((Test-Path -Path $outFileName)) { - Write-Host "Unable to remove file" - # This will act as a continue because this code is executed as a script block and not like a classic for-each loop - return + Write-Host "Unable to remove file" + # This will act as a continue because this code is executed as a script block and not like a classic for-each loop + return } # The backticks here are to escape the double quotes which exist in case we have spaces in file path. @@ -212,7 +212,7 @@ Build either with Visual Studio or with CMake in command line. The `CZICompress` source codes are implemented using C++17 standard and can be compiled on Windows or Linux and with multiple compilers. You can compile codes by using IDE like Microsoft Visual Studio (MSVS), Visual Studio Code (VSCode) or any other IDE that works with `CMake`. Make sure that on your machine you have one of these tools: | | Windows | Linux | -| ---------- | ------------------- | ------------- | +|------------|---------------------|---------------| | Build tool | CMake | CMake | | Compilers | MSVC | GNU, LLVM | | IDE | MSVS, VSCode, CLion | VSCode, CLion | diff --git a/czicompress/app/CZIcompress.cpp b/czicompress/app/CZIcompress.cpp index 43f72dd..70e4ed0 100644 --- a/czicompress/app/CZIcompress.cpp +++ b/czicompress/app/CZIcompress.cpp @@ -94,8 +94,8 @@ int main(int argc, char** argv) reader->Open(stream, &open_options); // Create an "output-stream-object" - const auto output_stream = - libCZI::CreateOutputStreamForFile(utils::utf8::WidenUtf8(command_line_options.GetOutputFileName()).c_str(), command_line_options.GetOverwriteExistingFile()); + const auto output_stream = libCZI::CreateOutputStreamForFile(utils::utf8::WidenUtf8(command_line_options.GetOutputFileName()).c_str(), + command_line_options.GetOverwriteExistingFile()); // create (and configure) the "CZI-writer"-object libCZI::CZIWriterOptions czi_writer_options; diff --git a/czicompress/capi/capi.cpp b/czicompress/capi/capi.cpp index ad311c5..bd1bbd0 100644 --- a/czicompress/capi/capi.cpp +++ b/czicompress/capi/capi.cpp @@ -122,14 +122,14 @@ class FileProcessor final } }; -void* CreateFileProcessor(Command command, CompressionStrategy strategy, int compression_level) +void *CreateFileProcessor(Command command, CompressionStrategy strategy, int compression_level) { return new FileProcessor(command, strategy, compression_level); } void DestroyFileProcessor(void *file_processor) { - auto* processor = static_cast(file_processor); + auto *processor = static_cast(file_processor); delete processor; } @@ -181,7 +181,7 @@ int ProcessFile(void *file_processor, const char *const input_path, const char * if (!error_message_length) throw std::invalid_argument("Error message length pointer is null."); if (!progress) throw std::invalid_argument("Progress function pointer is null"); - auto *proc = static_cast(file_processor); + auto *proc = static_cast(file_processor); proc->ProcessFile(input_path, output_path, progress); error_message = nullptr; return EXIT_SUCCESS; diff --git a/czicompress/capi/capi.h b/czicompress/capi/capi.h index f240957..b556b37 100644 --- a/czicompress/capi/capi.h +++ b/czicompress/capi/capi.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include @@ -11,10 +12,9 @@ #include "capi_export.h" #include "include/command.h" #include "include/compressionstrategy.h" -#include // input_path is only guaranteed to exist during the duration of this call and should be copied if retained -typedef bool (*ProgressReport)(int32_t progress_percent); // NOLINT(readability/casting) +typedef bool (*ProgressReport)(int32_t progress_percent); // NOLINT(readability/casting) /** * Processes a single file with the specified file processor. @@ -68,10 +68,10 @@ extern "C" CAPI_EXPORT void GetLibVersion(int32_t* major, int32_t* minor, int32_ * least the number given with the first call) and call again. * * @param buffer Pointer to a buffer (which size is stated with size). - * @param size Pointer to an uint64 which on input contains the size of the buffer, and on output (with return value false) - * the required size of the buffer. + * @param size Pointer to an uint64 which on input contains the size of the buffer, and on output (with return value false) + * the required size of the buffer. * - * @returns True if the buffer size was sufficient (and in this case the text is copied to the buffer); false otherwise (and in + * @returns True if the buffer size was sufficient (and in this case the text is copied to the buffer); false otherwise (and in * this case the required size is written to *size). */ extern "C" CAPI_EXPORT bool GetLibVersionString(char* buffer, uint64_t* size); diff --git a/czicompress/lib/include/commandlineoptions.h b/czicompress/lib/include/commandlineoptions.h index b238b82..723e861 100644 --- a/czicompress/lib/include/commandlineoptions.h +++ b/czicompress/lib/include/commandlineoptions.h @@ -31,6 +31,7 @@ class CommandLineOptions libCZI::Utils::CompressionOption compression_option_; bool overwrite_existing_file_{false}; bool ignore_duplicate_subblocks_{true}; + public: /// Values that represent the result of the "Parse"-operation. enum class ParseResult diff --git a/czicompress/lib/src/actionwithsubblockstatistics.h b/czicompress/lib/src/actionwithsubblockstatistics.h index ce098dc..82151b4 100644 --- a/czicompress/lib/src/actionwithsubblockstatistics.h +++ b/czicompress/lib/src/actionwithsubblockstatistics.h @@ -51,9 +51,6 @@ class ActionWithSubBlockStatistics /// \returns Total count of subblocks processed. std::uint64_t GetTotalCountOfSubblocksProcessed() const { - return - this->count_subblocks_copied_verbatim_ + - this->count_subblocks_compressed_ + - this->count_subblocks_decompressed_; + return this->count_subblocks_copied_verbatim_ + this->count_subblocks_compressed_ + this->count_subblocks_decompressed_; } }; diff --git a/czicompress/lib/src/commandlineoptions.cpp b/czicompress/lib/src/commandlineoptions.cpp index 07e9169..b72d968 100644 --- a/czicompress/lib/src/commandlineoptions.cpp +++ b/czicompress/lib/src/commandlineoptions.cpp @@ -150,12 +150,7 @@ CommandLineOptions::ParseResult CommandLineOptions::Parse(int argc, const char* // specify the string-to-enum-mapping for a boolean option std::map map_string_to_boolean{ - {"0", false}, - {"false", false}, - {"no", false}, - {"1", true}, - {"true", true}, - {"yes", true}, + {"0", false}, {"false", false}, {"no", false}, {"1", true}, {"true", true}, {"yes", true}, }; // specify the string-to-enum-mapping for "command" diff --git a/czicompress/lib/src/copyczi.cpp b/czicompress/lib/src/copyczi.cpp index c3853ac..123b9c3 100644 --- a/czicompress/lib/src/copyczi.cpp +++ b/czicompress/lib/src/copyczi.cpp @@ -378,7 +378,9 @@ std::shared_ptr CopyCziAndCompress::ModifyMetadata( auto metadata_src = metadata_segment->CreateMetaFromMetadataSegment(); const auto metadata_builder = libCZI::CreateMetadataBuilderFromXml(metadata_src->GetXml()); - metadata_builder->GetRootNode()->GetOrCreateChildNode("Metadata/Information/Image/CurrentCompressionParameters")->SetValue("Lossless: True"); + metadata_builder->GetRootNode() + ->GetOrCreateChildNode("Metadata/Information/Image/CurrentCompressionParameters") + ->SetValue("Lossless: True"); return metadata_builder; } @@ -388,14 +390,13 @@ std::shared_ptr CopyCziAndCompress::ModifyMetadata( //----------------------------------------------------------------------------- -CopyCziAndDecompress::ActionWithSubBlock CopyCziAndDecompress::DecideWhatToDoWithSubBlock( - const std::shared_ptr&) +CopyCziAndDecompress::ActionWithSubBlock CopyCziAndDecompress::DecideWhatToDoWithSubBlock(const std::shared_ptr&) { return ActionWithSubBlock::kDecompress; } std::shared_ptr CopyCziAndDecompress::ModifyMetadata( - const std::shared_ptr& metadata_segment) + const std::shared_ptr& metadata_segment) { // well... if we at least decompressed half of the subblocks, then we feel entitled to set the // documents metadata (which states the "prevalant compression") - in this case, we set the diff --git a/czicompress/lib/src/copyczi.h b/czicompress/lib/src/copyczi.h index 80355a4..81cb5c9 100644 --- a/czicompress/lib/src/copyczi.h +++ b/czicompress/lib/src/copyczi.h @@ -48,7 +48,7 @@ class CopyCziBase protected: /// Gets the statistics object. - /// + /// /// \returns The statistics object. const ActionWithSubBlockStatistics& GetStatistics() const; @@ -82,7 +82,7 @@ class CopyCziBase virtual std::tuple> CompressSubBlock( const std::shared_ptr& subblock); - /// This method is called when the metadata-segment is being process. It allows to + /// This method is called when the metadata-segment is being process. It allows to /// alter the XML and do modifications. /// If no modification is needed (and the data from the source metadata-segment) is to be /// copied verbatim, then this method can return a nullptr. @@ -94,8 +94,7 @@ class CopyCziBase /// /// \returns A std::shared_ptr<libCZI::ICziMetadataBuilder> containing the /// metadata to be written to the destination document. - virtual std::shared_ptr ModifyMetadata( - const std::shared_ptr& metadata_segment); + virtual std::shared_ptr ModifyMetadata(const std::shared_ptr& metadata_segment); private: /// This object is used to keep a statistics about the operations done with the subblocks. diff --git a/czicompress/lib/src/operation.cpp b/czicompress/lib/src/operation.cpp index 5b4806b..9fcb8d7 100644 --- a/czicompress/lib/src/operation.cpp +++ b/czicompress/lib/src/operation.cpp @@ -20,10 +20,7 @@ void Operation::DoOperation(const std::function& prog std::function progress_report_function; if (progress) { - progress_report_function = [progress](const ProgressInfo& info) -> bool - { - return progress(info); - }; + progress_report_function = [progress](const ProgressInfo& info) -> bool { return progress(info); }; } const auto operation = this->CreateCopyClass(progress_report_function); diff --git a/czicompress/lib/src/utils/utf8/platforms/windows/utf8converter.cpp b/czicompress/lib/src/utils/utf8/platforms/windows/utf8converter.cpp index 810333e..9d92540 100644 --- a/czicompress/lib/src/utils/utf8/platforms/windows/utf8converter.cpp +++ b/czicompress/lib/src/utils/utf8/platforms/windows/utf8converter.cpp @@ -8,7 +8,6 @@ #include - namespace utils::utf8 { std::wstring WidenUtf8(const std::string &str) diff --git a/czicompress/tests/test_copyoperation.cpp b/czicompress/tests/test_copyoperation.cpp index 1818ea7..b5f8f0d 100644 --- a/czicompress/tests/test_copyoperation.cpp +++ b/czicompress/tests/test_copyoperation.cpp @@ -25,8 +25,7 @@ static int CheckSizeAndCastToInt(const uint32_t size) static void CheckOriginalCompressionMetadata(std::shared_ptr metadata) { - auto original_compression_method = - metadata->GetChildNodeReadonly("ImageDocument/Metadata/Information/Image/OriginalCompressionMethod"); + auto original_compression_method = metadata->GetChildNodeReadonly("ImageDocument/Metadata/Information/Image/OriginalCompressionMethod"); std::wstring original_compression_method_string; bool metadata_node_found = original_compression_method->TryGetValue(&original_compression_method_string); REQUIRE(metadata_node_found == true); @@ -58,7 +57,7 @@ static tuple, size_t> CreateCziWithFourSubblockInMosaicArrangem auto outStream = make_shared(0); auto spWriterInfo = make_shared(libCZI::GUID{0x1234567, 0x89ab, 0xcdef, {1, 2, 3, 4, 5, 6, 7, 8}}, // NOLINT - libCZI::CDimBounds{{libCZI::DimensionIndex::C, 0, 1}}, // set a bounds for C + libCZI::CDimBounds{{libCZI::DimensionIndex::C, 0, 1}}, // set a bounds for C 0, 3); // set a bounds M : 0<=m<=0 writer->Create(outStream, spWriterInfo); @@ -143,9 +142,7 @@ static tuple, size_t> CreateCziWithFourSubblockInMosaicArrangem const libCZI::PrepareMetadataInfo prepare_metadata_info; auto metaDataBuilder = writer->GetPreparedMetadata(prepare_metadata_info); - metaDataBuilder->GetRootNode() - ->GetOrCreateChildNode("Metadata/Information/Image/OriginalCompressionMethod") - ->SetValue("JpegXr"); + metaDataBuilder->GetRootNode()->GetOrCreateChildNode("Metadata/Information/Image/OriginalCompressionMethod")->SetValue("JpegXr"); metaDataBuilder->GetRootNode() ->GetOrCreateChildNode("Metadata/Information/Image/OriginalCompressionParameters") ->SetValue("Lossless: False, Quality: 77"); @@ -283,7 +280,6 @@ TEST_CASE("copyczi.2: run compression on simple synthetic document changes compr CheckOriginalCompressionMetadata(metadata); } - TEST_CASE("copyczi.3: run decompression on simple synthetically compressed document changes compression method in metadata.", "[copyczi]") { // arrange @@ -362,7 +358,7 @@ TEST_CASE("copyczi.3: run decompression on simple synthetically compressed docum bool metadata_node_found = compression_parameters->TryGetValue(&compression_parameters_string); // in case of uncompressed, the metadata is empty, i.e. , so getting its value fails. - REQUIRE(metadata_node_found == false); + REQUIRE(metadata_node_found == false); CheckOriginalCompressionMetadata(metadata); } diff --git a/czishrink/.vscode/launch.json b/czishrink/.vscode/launch.json index 9842bcd..7618f38 100644 --- a/czishrink/.vscode/launch.json +++ b/czishrink/.vscode/launch.json @@ -1,26 +1,26 @@ { - "version": "0.2.0", - "configurations": [ - { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md - "name": ".NET Core Launch (console)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/netczicompress.Desktop/bin/x64/Debug/net8.0/CziShrink", - "args": [], - "cwd": "${workspaceFolder}/netczicompress.Desktop", - // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console - "console": "internalConsole", - "stopAtEntry": false - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach" - } - ] -} \ No newline at end of file + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/netczicompress.Desktop/bin/x64/Debug/net8.0/CziShrink", + "args": [], + "cwd": "${workspaceFolder}/netczicompress.Desktop", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} diff --git a/czishrink/.vscode/settings.json b/czishrink/.vscode/settings.json index d09b546..8447bfc 100644 --- a/czishrink/.vscode/settings.json +++ b/czishrink/.vscode/settings.json @@ -1,3 +1,3 @@ { - "dotnet.defaultSolution": "netczicompress.sln" -} \ No newline at end of file + "dotnet.defaultSolution": "netczicompress.sln" +} diff --git a/czishrink/.vscode/tasks.json b/czishrink/.vscode/tasks.json index 2b17345..047341f 100644 --- a/czishrink/.vscode/tasks.json +++ b/czishrink/.vscode/tasks.json @@ -1,70 +1,67 @@ { - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "command": "dotnet", - "type": "process", - "args": [ - "build", - "${workspaceFolder}/netczicompress.sln", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "publish", - "command": "dotnet", - "type": "process", - "args": [ - "publish", - "${workspaceFolder}/netczicompress.Desktop/netczicompress.Desktop.csproj", - "-c", "Release", - "--use-current-runtime", "true", - "--self-contained", - "-p:PublishSingleFile=true", - "-p:PublishReadyToRun=true", - "-p:PublishReadyToRunShowWarnings=true" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "Watch (Tests)", - "command": "dotnet", - "type": "process", - "args": [ - "watch", - "test", - "--project", - "netczicompressTests" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "Test with Coverage", - "command": "dotnet", - "type": "process", - "args": [ - "test", - "/p:CollectCoverage=true", - "/p:CoverletOutputFormat=lcov%2ccobertura", - "/p:CoverletOutput=${workspaceFolder}/coverage/", - "/p:ExcludeByAttribute=GeneratedCodeAttribute%2cObsoleteAttribute", - "/p:ExcludeByFile=**/*.axaml%2c**/*.g.cs", - "/p:Exclude=[netczicompress]netczicompress.Views.*" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "Generate coverage report", - "command": "reportgenerator", - "type": "shell", - "args": [ - "-reports:${workspaceFolder}/coverage/coverage.info", - "-targetdir:${workspaceFolder}/coverage/covstats" - ], - "problemMatcher": [] - } - ] + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/netczicompress.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/netczicompress.Desktop/netczicompress.Desktop.csproj", + "-c", + "Release", + "--use-current-runtime", + "true", + "--self-contained", + "-p:PublishSingleFile=true", + "-p:PublishReadyToRun=true", + "-p:PublishReadyToRunShowWarnings=true" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "Watch (Tests)", + "command": "dotnet", + "type": "process", + "args": ["watch", "test", "--project", "netczicompressTests"], + "problemMatcher": "$msCompile" + }, + { + "label": "Test with Coverage", + "command": "dotnet", + "type": "process", + "args": [ + "test", + "/p:CollectCoverage=true", + "/p:CoverletOutputFormat=lcov%2ccobertura", + "/p:CoverletOutput=${workspaceFolder}/coverage/", + "/p:ExcludeByAttribute=GeneratedCodeAttribute%2cObsoleteAttribute", + "/p:ExcludeByFile=**/*.axaml%2c**/*.g.cs", + "/p:Exclude=[netczicompress]netczicompress.Views.*" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "Generate coverage report", + "command": "reportgenerator", + "type": "shell", + "args": [ + "-reports:${workspaceFolder}/coverage/coverage.info", + "-targetdir:${workspaceFolder}/coverage/covstats" + ], + "problemMatcher": [] + } + ] } diff --git a/czishrink/Directory.Build.props b/czishrink/Directory.Build.props index 34a37d9..775fa1c 100644 --- a/czishrink/Directory.Build.props +++ b/czishrink/Directory.Build.props @@ -17,6 +17,6 @@ false - 1.2.0 + 1.2.1 diff --git a/czishrink/README.md b/czishrink/README.md index 848307a..5867b0d 100644 --- a/czishrink/README.md +++ b/czishrink/README.md @@ -3,34 +3,34 @@ An open source and cross-platform GUI for [CziCompress](https://github.com/ZEISS ## Table of contents - - [Overview](#overview) - - [System Requirements](#system-requirements) - - [Theme Support](#theme-support) - - [I/O](#io) - - [Parameters](#parameters) - - [Operations](#operations) - - [Progress Update](#progress-update) - - [Compression Statistics](#compression-statistics) - - [Sharing](#sharing) - - [Errors](#errors) - - [Logs](#logs) - - [FAQ](#faq) - - [Known Issues](#known-issues) - - [Potential Future Enhancements](#potential-future-enhancements) - - [Contributing](#contributing) +- [Overview](#overview) + - [System Requirements](#system-requirements) + - [Theme Support](#theme-support) + - [I/O](#io) + - [Parameters](#parameters) + - [Operations](#operations) + - [Progress Update](#progress-update) + - [Compression Statistics](#compression-statistics) + - [Sharing](#sharing) + - [Errors](#errors) +- [Logs](#logs) +- [FAQ](#faq) +- [Known Issues](#known-issues) +- [Potential Future Enhancements](#potential-future-enhancements) +- [Contributing](#contributing) ## Overview ## System Requirements ### Windows - - Windows 10 or later +- Windows 10 or later ### Linux - - Supported OS: - - Debian 9 (Stretch) and higher - - Ubuntu 16.04 and higher - - X11 - - Clipboad functionality requires xclip to be installed +- Supported OS: + - Debian 9 (Stretch) and higher + - Ubuntu 16.04 and higher +- X11 +- Clipboad functionality requires xclip to be installed ## Theme Support Dark and a light themes are set automatically based on your OS settings. @@ -47,13 +47,13 @@ The intent of the tool is to be a bulk-compression utility. ### Operations -| Operation | Description | -|-----------|-------------| -| Compress uncompressed data |Compresses only uncompressed subblocks and copies others.| -| Compress uncompressed and Zstd-compressed data|Compresses subblocks that were originally uncompressed or compressed with zstd. | -| Compress all data |Compresses all subblocks regardless of current compression method (if possible). | -| Decompress all data |Decompresses all possible subblocks. | -| Dry Run |Finds all CZI files in the input folder but does not create any output CZI files. Like the other operations, it creates a CSV report in the output folder.| +| Operation | Description | +|------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Compress uncompressed data | Compresses only uncompressed subblocks and copies others. | +| Compress uncompressed and Zstd-compressed data | Compresses subblocks that were originally uncompressed or compressed with zstd. | +| Compress all data | Compresses all subblocks regardless of current compression method (if possible). | +| Decompress all data | Decompresses all possible subblocks. | +| Dry Run | Finds all CZI files in the input folder but does not create any output CZI files. Like the other operations, it creates a CSV report in the output folder. | ## Progress Update CZI Shrink scans the input folder for CZI files. @@ -97,10 +97,10 @@ the actual entries written. In some cases you may see no log output until the operation has completed if a reasonably constrained input directory is chosen. ### Format -| InputFile | SizeInput | SizeOutput | SizeRatio | SizeDelta | TimeToProcess | Status | ErrorMessage| -| ----------|-----------|------------|-----------|-----------|---------------|--------|-------------| -| Sample_file.czi | 696480 | 564992 |0.811210659| 131488 | 00:00:00.0672709 |SUCCESS|| -| Sample_file2.czi| 1107888032 | 0 | 0 | -1 | |ERROR | Illegal data detected at offset 235352768 -> Invalid SubBlock-magic | +| InputFile | SizeInput | SizeOutput | SizeRatio | SizeDelta | TimeToProcess | Status | ErrorMessage | +|------------------|------------|------------|-------------|-----------|------------------|---------|---------------------------------------------------------------------| +| Sample_file.czi | 696480 | 564992 | 0.811210659 | 131488 | 00:00:00.0672709 | SUCCESS | | +| Sample_file2.czi | 1107888032 | 0 | 0 | -1 | | ERROR | Illegal data detected at offset 235352768 -> Invalid SubBlock-magic | ## FAQ - Is the compression lossy? - The tool uses [Zstandard](https://github.com/facebook/zstd) which is a fast and lossless compression algorithm. @@ -128,10 +128,10 @@ There is no guarantee that any items on this list will be added, rather it is ju ### Notes for Contributors * Test changes at least on Linux and Windows. -* Note that the app will change appearance when the system theme is changed (Windows: Settings -> Personalization -> Colors -> Choose your colors: Light/Dark/Custom). Make sure that GUI changes look good both in the Light and in the Dark Theme. See https://docs.avaloniaui.net/docs/next/guides/styles-and-resources/how-to-use-theme-variants +* Note that the app will change appearance when the system theme is changed (Windows: Settings -> Personalization -> Colors -> Choose your colors: Light/Dark/Custom). Make sure that GUI changes look good both in the Light and in the Dark Theme. See ## How to upgrade libczicompressc automatically -1. Create a 'classic' personal access token at https://github.com/settings/tokens, authorize it for the ZEISS organization via the "Configure SSO" button, and store it in a GITHUB_TOKEN environment variable. +1. Create a 'classic' personal access token at , authorize it for the ZEISS organization via the "Configure SSO" button, and store it in a GITHUB_TOKEN environment variable. 2. Open a Powershell terminal and run [./upgrade-libczicompressc.ps1](./upgrade-libczicompressc.ps1). Run `get-help ./upgrade-libczicompressc.ps1` for more info. ## How to upgrade libczicompressc manually @@ -139,7 +139,7 @@ There is no guarantee that any items on this list will be added, rather it is ju 1. Put the binaries into [libczicompressc/runtimes/linux-x64/native](libczicompressc/runtimes/linux-x64/native) and [libczicompressc/runtimes/win-x64/native](libczicompressc/runtimes/win-x64/native) 1. Update the nuspec file [libczicompressc/libczicompressc.nuspec](libczicompressc/libczicompressc.nuspec): * `package/metadata/version` must be the 'ProductVersion' of libczicompressc.dll (explorer: Properties/Details) - * `package/metadata/repository[@commit]` must be the git commit from which the binaries were built + * `package/metadata/repository[@commit]` must be the git commit from which the binaries were built 1. [Install nuget if necessary](https://learn.microsoft.com/en-us/nuget/install-nuget-client-tools#cli-tools). 1. Open a shell in [libczicompressc](libczicompressc), and run `path/to/nuget pack libczicompressc.nuspec` 1. Move the resulting nupkg into [packages_local](packages_local) and delete the old package from there. diff --git a/czishrink/global.json b/czishrink/global.json index 28b588c..92f8156 100644 --- a/czishrink/global.json +++ b/czishrink/global.json @@ -1,7 +1,7 @@ { - "sdk": { - "version": "8.0.204", - "allowPrerelease": false, - "rollForward": "latestFeature" - } + "sdk": { + "version": "8.0.303", + "allowPrerelease": false, + "rollForward": "latestFeature" } +} diff --git a/czishrink/icon-source/convert-to-ico.sh b/czishrink/icon-source/convert-to-ico.sh index 2955790..f353297 100644 --- a/czishrink/icon-source/convert-to-ico.sh +++ b/czishrink/icon-source/convert-to-ico.sh @@ -1,2 +1,2 @@ #!/bin/bash -magick mogrify -path . -format ico -density 600 -define icon:auto-resize=256,128,64,48,40,32,24,16 -background none netczicompress.svg \ No newline at end of file +magick mogrify -path . -format ico -density 600 -define icon:auto-resize=256,128,64,48,40,32,24,16 -background none netczicompress.svg diff --git a/czishrink/netczicompress/packages.lock.json b/czishrink/netczicompress/packages.lock.json index ad14d4f..f330a82 100644 --- a/czishrink/netczicompress/packages.lock.json +++ b/czishrink/netczicompress/packages.lock.json @@ -86,9 +86,9 @@ }, "Microsoft.DotNet.ILCompiler": { "type": "Direct", - "requested": "[8.0.4, )", - "resolved": "8.0.4", - "contentHash": "bVK6XD5E/BpkPmdrx99ZkloZZX3nOvTAcW+W6jW4cs8elWlLFAc9BXHk2esxSVHMiaCLiLdIJAyhUfhV50TW+Q==" + "requested": "[8.0.7, )", + "resolved": "8.0.7", + "contentHash": "5Vkl5384rfKZmK7rVm8pjuMk2Cweaqd+rPwL86bddhInHdBg3ClO9H0cqwd7kXf+F8/aXuZxKAnl6izzaWkfUw==" }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Direct", @@ -101,9 +101,9 @@ }, "Microsoft.NET.ILLink.Tasks": { "type": "Direct", - "requested": "[8.0.4, )", - "resolved": "8.0.4", - "contentHash": "PZb5nfQ+U19nhnmnR9T1jw+LTmozhuG2eeuzuW5A7DqxD/UXW2ucjmNJqnqOuh8rdPzM3MQXoF8AfFCedJdCUw==" + "requested": "[8.0.7, )", + "resolved": "8.0.7", + "contentHash": "iI52ptEKby2ymQ6B7h4TWbFmm85T4VvLgc/HvS45Yr3lgi4IIFbQtjON3bQbX/Vc94jXNSLvrDOp5Kh7SJyFYQ==" }, "Projektanker.Icons.Avalonia.FontAwesome": { "type": "Direct", diff --git a/czishrink/stylecop.json b/czishrink/stylecop.json index 11eedfa..bc0a78e 100644 --- a/czishrink/stylecop.json +++ b/czishrink/stylecop.json @@ -3,10 +3,7 @@ "settings": { "namingRules": { - "allowedNamespaceComponents": [ - "netczicompress", - "netczicompressTests" - ] + "allowedNamespaceComponents": ["netczicompress", "netczicompressTests"] } } -} \ No newline at end of file +} diff --git a/czishrink/upgrade-libczicompressc.ps1 b/czishrink/upgrade-libczicompressc.ps1 index b77394b..85c29ac 100644 --- a/czishrink/upgrade-libczicompressc.ps1 +++ b/czishrink/upgrade-libczicompressc.ps1 @@ -20,7 +20,7 @@ If you specify a -DownloadFolder the script will reuse data downloaded to that f .EXAMPLE -PS> ./upgrade-libczicompressc.ps1 -NewCziShrinkVersion 2.3.0 -DownloadFolder "$env:TEMP/libczicompress/cache" -NoPullRequest +PS> ./upgrade-libczicompressc.ps1 -NewCziShrinkVersion 2.3.0 -DownloadFolder "$env:TEMP/libczicompress/cache" -NoPR .PARAMETER NewCziShrinkVersion @@ -58,27 +58,27 @@ Overwrites an existing upgrade branch. This can be useful if a previous run of t #> param( - [Parameter(Mandatory=$true)] - [string]$NewCziShrinkVersion, + [Parameter(Mandatory = $true)] + [string]$NewCziShrinkVersion, - [Parameter(Mandatory=$false)] - [AllowNull()] - [string]$DownloadFolder = $null, + [Parameter(Mandatory = $false)] + [AllowNull()] + [string]$DownloadFolder = $null, - [Parameter(Mandatory=$false)] - [string]$NugetExePath = $null, + [Parameter(Mandatory = $false)] + [string]$NugetExePath = $null, - [Parameter(Mandatory=$false)] - [string]$GithubToken = $env:GITHUB_TOKEN, + [Parameter(Mandatory = $false)] + [string]$GithubToken = $env:GITHUB_TOKEN, - [Parameter(Mandatory=$false)] - [switch]$NoPR, + [Parameter(Mandatory = $false)] + [switch]$NoPR, - [Parameter(Mandatory=$false)] - [switch]$NoCache, + [Parameter(Mandatory = $false)] + [switch]$NoCache, - [Parameter(Mandatory=$false)] - [switch]$OverwriteExistingBranch + [Parameter(Mandatory = $false)] + [switch]$OverwriteExistingBranch ) $CreatePullRequest = !$NoPR @@ -96,22 +96,22 @@ $CziCompress = "ZEISS/czicompress" ########################################################## if ($null -eq $GithubToken) { - throw "You must set the GITHUB_TOKEN environment variable to a personal access token of yours: https://github.com/settings/tokens. See also: https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating-with-saml-single-sign-on/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on" + throw "You must set the GITHUB_TOKEN environment variable to a personal access token of yours: https://github.com/settings/tokens. See also: https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating-with-saml-single-sign-on/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on" } $GithubApiHeaders = @{ - 'Accept' = 'application/vnd.github+json' - 'X-GitHub-Api-Version' = '2022-11-28' - 'Authorization' = "Bearer $GithubToken" + 'Accept' = 'application/vnd.github+json' + 'X-GitHub-Api-Version' = '2022-11-28' + 'Authorization' = "Bearer $GithubToken" } if (!$DownloadFolder) { - $DownloadFolder = "$env:Temp/libczicompressc/$(Get-Date -Format FileDate)" + $DownloadFolder = "$env:Temp/libczicompressc/$(Get-Date -Format FileDate)" } Write-Output "INFO: Using DownloadFolder $DownloadFolder" if (!(Test-Path $DownloadFolder)) { - mkdir $DownloadFolder + mkdir $DownloadFolder } # We'll use the following properties @@ -120,17 +120,18 @@ if (!(Test-Path $DownloadFolder)) { $LatestRunJson = "$DownloadFolder/LatestRunOfCMakeBuild.json" if ($UseCache -and (Test-Path -Path $LatestRunJson)) { - Write-Output "INFO: Using previously downloaded build info from $LatestRunJson." - $LatestRunOfCMakeBuild = Get-Content $LatestRunJson | ConvertFrom-Json -} else { - # Get latest run - Write-Output "INFO: Getting build info from github.com/$CziCompress." - $ActionRunsUri = "https://api.github.com/repos/$CziCompress/actions/runs?branch=main&status=success&per_page=10" - $ServerResponse = Invoke-WebRequest -Uri $ActionRunsUri -Headers $GithubApiHeaders | ConvertFrom-Json - $RunsOfCmakeBuild = $ServerResponse.workflow_runs | Where-Object Name -eq 'CMake Build (czicompress)' - - $LatestRunOfCMakeBuild = $RunsOfCmakeBuild | Sort-Object -Property 'run_number' | Select-Object -Last 1 - $LatestRunOfCMakeBuild | ConvertTo-Json | Set-Content -Path $LatestRunJson + Write-Output "INFO: Using previously downloaded build info from $LatestRunJson." + $LatestRunOfCMakeBuild = Get-Content $LatestRunJson | ConvertFrom-Json +} +else { + # Get latest run + Write-Output "INFO: Getting build info from github.com/$CziCompress." + $ActionRunsUri = "https://api.github.com/repos/$CziCompress/actions/runs?branch=main&status=success&per_page=10" + $ServerResponse = Invoke-WebRequest -Uri $ActionRunsUri -Headers $GithubApiHeaders | ConvertFrom-Json + $RunsOfCmakeBuild = $ServerResponse.workflow_runs | Where-Object Name -EQ 'CMake Build (czicompress)' + + $LatestRunOfCMakeBuild = $RunsOfCmakeBuild | Sort-Object -Property 'run_number' | Select-Object -Last 1 + $LatestRunOfCMakeBuild | ConvertTo-Json | Set-Content -Path $LatestRunJson } $LinuxArtifactZip = "$DownloadFolder/linux.zip" @@ -138,35 +139,34 @@ $WindowsArtifactZip = "$DownloadFolder/win.zip" $DownloadLinux = $NoCache -or !(Test-Path $LinuxArtifactZip) $DownloadWindows = $NoCache -or !(Test-Path $WindowsArtifactZip) -if ($DownloadWindows -or $DownloadLinux) -{ - # Download the artifacts - Write-Output "INFO: Downloading artifacts from $($LatestRunOfCMakeBuild.artifacts_url)" - $ServerResponse = Invoke-WebRequest -Uri $LatestRunOfCMakeBuild.artifacts_url -Headers $GithubApiHeaders | ConvertFrom-Json - - $LinuxArtifact = $ServerResponse.artifacts | Where-Object name -eq "czicompress-ubuntu-package-off-Release" - $WindowsArtifact = $ServerResponse.artifacts | Where-Object name -eq "czicompress-windows-64-msvc-package-on-Release" - - if ($ServerResponse.total_count -eq 0) { - throw "No artifacts found." - } - - try { - if ($DownloadLinux) - { - Invoke-WebRequest -Uri $LinuxArtifact.archive_download_url -Headers $GithubApiHeaders -OutFile $LinuxArtifactZip - } - - if ($DownloadWindows) - { - Invoke-WebRequest -Uri $WindowsArtifact.archive_download_url -Headers $GithubApiHeaders -OutFile $WindowsArtifactZip - } - } catch { - Write-Output "ERROR: unable to download artifacts." - throw - } -} else { - Write-Output "INFO: Using previously download artifact ZIP files in $DownloadFolder" +if ($DownloadWindows -or $DownloadLinux) { + # Download the artifacts + Write-Output "INFO: Downloading artifacts from $($LatestRunOfCMakeBuild.artifacts_url)" + $ServerResponse = Invoke-WebRequest -Uri $LatestRunOfCMakeBuild.artifacts_url -Headers $GithubApiHeaders | ConvertFrom-Json + + $LinuxArtifact = $ServerResponse.artifacts | Where-Object name -EQ "czicompress-ubuntu-package-off-Release" + $WindowsArtifact = $ServerResponse.artifacts | Where-Object name -EQ "czicompress-windows-64-msvc-package-on-Release" + + if ($ServerResponse.total_count -eq 0) { + throw "No artifacts found." + } + + try { + if ($DownloadLinux) { + Invoke-WebRequest -Uri $LinuxArtifact.archive_download_url -Headers $GithubApiHeaders -OutFile $LinuxArtifactZip + } + + if ($DownloadWindows) { + Invoke-WebRequest -Uri $WindowsArtifact.archive_download_url -Headers $GithubApiHeaders -OutFile $WindowsArtifactZip + } + } + catch { + Write-Output "ERROR: unable to download artifacts." + throw + } +} +else { + Write-Output "INFO: Using previously download artifact ZIP files in $DownloadFolder" } # Extract libczicompressc binaries @@ -186,63 +186,64 @@ $BranchName = "feature/upgrade-libczicompressc-$NewLibVersion_" Write-Output "INFO: The new library version is $NewLibVersion => Create branch $BranchName and switch to it." if (![string]::IsNullOrEmpty($PSScriptRoot)) { - Set-Location "$PSScriptRoot/libczicompressc" -} else { - $current_dir_name = Get-Location | Split-Path -Leaf - if ("czishrink" -eq $current_dir_name) - { - Set-Location "libczicompressc" - } elseif ("libczicompress" -ne $current_dir_name) { - throw "Please CD to the /czishrink directory of a czicompress clone." - } + Set-Location "$PSScriptRoot/libczicompressc" +} +else { + $current_dir_name = Get-Location | Split-Path -Leaf + if ("czishrink" -eq $current_dir_name) { + Set-Location "libczicompressc" + } + elseif ("libczicompress" -ne $current_dir_name) { + throw "Please CD to the /czishrink directory of a czicompress clone." + } } # Stash any local changes $GitStatus = git status --porcelain -if($LASTEXITCODE -ne 0) { - throw "git status failed" +if ($LASTEXITCODE -ne 0) { + throw "git status failed" } if (![string]::IsNullOrEmpty($GitStatus)) { - Write-Output "INFO: Stashing local changes" - git stash --include-untracked - if($LASTEXITCODE -ne 0) { - throw "git stash failed" - } + Write-Output "INFO: Stashing local changes" + git stash --include-untracked + if ($LASTEXITCODE -ne 0) { + throw "git stash failed" + } } # Switch to main and pull git switch main -if($LASTEXITCODE -ne 0) { - throw "git switch failed" +if ($LASTEXITCODE -ne 0) { + throw "git switch failed" } git pull -if($LASTEXITCODE -ne 0) { - throw "git pull failed" +if ($LASTEXITCODE -ne 0) { + throw "git pull failed" } # Create a new branch $gitSwitchCreateFlag = "-c" if ($OverwriteExistingBranch) { - $gitSwitchCreateFlag = "-C" + $gitSwitchCreateFlag = "-C" } git switch $gitSwitchCreateFlag $BranchName -if($LASTEXITCODE -ne 0) { - throw "Failed to create branch $BranchName. Please delete the branch if it exists." +if ($LASTEXITCODE -ne 0) { + throw "Failed to create branch $BranchName. Please delete the branch if it exists." } # Put the binaries into the nuget folder structure Write-Output "INFO: Creating the new nuget package..." -$libname="libczicompressc" -$LinuxRuntime="runtimes\linux-x64\native\$libname.so" -$WindowsRuntime="runtimes\win-x64\native\$libname.dll" +$libname = "libczicompressc" +$LinuxRuntime = "runtimes\linux-x64\native\$libname.so" +$WindowsRuntime = "runtimes\win-x64\native\$libname.dll" Copy-Item -Path "$DownloadFolder/$libname.so" -Destination $LinuxRuntime Copy-Item -Path "$DownloadFolder/$libname.dll" -Destination $WindowsRuntime # Modify the nuspec -$nuspec=Get-Item "libczicompressc.nuspec" +$nuspec = Get-Item "libczicompressc.nuspec" $xml = [xml](Get-Content -Path $nuspec.FullName) $xml.package.metadata.version = $NewLibVersion $xml.package.metadata.repository.commit = $LatestRunOfCMakeBuild.head_sha @@ -250,34 +251,36 @@ $xml.Save($nuspec.FullName) # Download nuget.exe if necessary and run nuget pack if (!$NugetExePath) { - try { - $NugetExePath = (Get-Command "nuget.exe").Source - } catch { - $NugetExePath = "$DownloadFolder/nuget.exe" - } + try { + $NugetExePath = (Get-Command "nuget.exe").Source + } + catch { + $NugetExePath = "$DownloadFolder/nuget.exe" + } } if (!(Test-Path -Path $NugetExePath)) { - Write-Output "INFO: Downloading nuget.exe to $NugetExePath" - Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile $NugetExePath -} else { - Write-Output "INFO: Using nuget.exe at $NugetExePath" + Write-Output "INFO: Downloading nuget.exe to $NugetExePath" + Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile $NugetExePath +} +else { + Write-Output "INFO: Using nuget.exe at $NugetExePath" } & $NugetExePath pack "libczicompressc.nuspec" -if($LASTEXITCODE -ne 0) { - throw "nuget failed" +if ($LASTEXITCODE -ne 0) { + throw "nuget failed" } # Revert changes to so/dll git checkout -- $LinuxRuntime -if($LASTEXITCODE -ne 0) { - throw "git checkout failed" +if ($LASTEXITCODE -ne 0) { + throw "git checkout failed" } git checkout -- $WindowsRuntime -if($LASTEXITCODE -ne 0) { - throw "git checkout failed" +if ($LASTEXITCODE -ne 0) { + throw "git checkout failed" } # Exchange the nupkg and update version in Directory.Packages.props @@ -299,8 +302,8 @@ $xml.Save($file.FullName) # Update PInvokeFileProcessor.cs Write-Output "INFO: Updating PInvokeFileProcessor.cs" $SourceCode = Get-Content -Path netczicompress/Models/PInvokeFileProcessor.cs -$NewVersionTuple="($($NewFileVersion.Major), $($NewFileVersion.Minor))" -$AlteredSourceCode = $SourceCode -replace '^( *\(int Major, int Minor\) expected = ).*?;$',('$1' + $NewVersionTuple + ";") +$NewVersionTuple = "($($NewFileVersion.Major), $($NewFileVersion.Minor))" +$AlteredSourceCode = $SourceCode -replace '^( *\(int Major, int Minor\) expected = ).*?;$', ('$1' + $NewVersionTuple + ";") Set-Content -Path netczicompress/Models/PInvokeFileProcessor.cs -Value $AlteredSourceCode # Set CziShrink VersionPrefix @@ -316,19 +319,19 @@ $xml.Save($file.FullName) Write-Output "INFO: Committing all changes" $CommitMessage = "Upgrade $libname to $NewLibVersion" git add . -if($LASTEXITCODE -ne 0) { - throw "git add failed" +if ($LASTEXITCODE -ne 0) { + throw "git add failed" } git commit -m $CommitMessage -if($LASTEXITCODE -ne 0) { - throw "git commit failed" +if ($LASTEXITCODE -ne 0) { + throw "git commit failed" } # Run tests Write-Output "INFO: Run tests" dotnet test -if($LASTEXITCODE -ne 0) { - throw "dotnet test failed" +if ($LASTEXITCODE -ne 0) { + throw "dotnet test failed" } # Git Push @@ -336,33 +339,33 @@ Write-Output "INFO: Push changes" $gitForceFlag = "" if ($OverwriteExistingBranch) { - $gitForceFlag = "--force" + $gitForceFlag = "--force" } git push $gitForceFlag --set-upstream origin $BranchName -if($LASTEXITCODE -ne 0) { - throw "git push failed" +if ($LASTEXITCODE -ne 0) { + throw "git push failed" } # Create a pull request if ($CreatePullRequest) { - $remote = git config --get remote.origin.url - if($LASTEXITCODE -ne 0) { - throw "git config failed" - } - - $CziShrinkRepo = $remote.Replace("https://github.com/", "") -replace "\.git$", "" - - Write-Output "INFO: Create a Pull Request" - $postParams = @{ - 'title'=$CommitMessage - 'body'="Automatic upgrade of $libname" - 'head'=$BranchName - 'base'='main' - } | ConvertTo-Json - - $ServerResponse = Invoke-WebRequest -Headers $GithubApiHeaders -Uri https://api.github.com/repos/$CziShrinkRepo/pulls -Method POST -Body $postParams - $PullRequestUrl = ($ServerResponse | ConvertFrom-Json).html_url - Write-Output "Opened a PR at $PullRequestUrl" - Start-Process $PullRequestUrl + $remote = git config --get remote.origin.url + if ($LASTEXITCODE -ne 0) { + throw "git config failed" + } + + $CziShrinkRepo = $remote.Replace("https://github.com/", "") -replace "\.git$", "" + + Write-Output "INFO: Create a Pull Request" + $postParams = @{ + 'title' =$CommitMessage + 'body' ="Automatic upgrade of $libname" + 'head' =$BranchName + 'base' ='main' + } | ConvertTo-Json + + $ServerResponse = Invoke-WebRequest -Headers $GithubApiHeaders -Uri https://api.github.com/repos/$CziShrinkRepo/pulls -Method POST -Body $postParams + $PullRequestUrl = ($ServerResponse | ConvertFrom-Json).html_url + Write-Output "Opened a PR at $PullRequestUrl" + Start-Process $PullRequestUrl }