Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

--max-size or --scale ignores --fix-size, outputs images with width/height not multiple of 4 #50

@Nathan8489

Description

@Nathan8489

Describe the bug
When using --max-size or --scale together with --fix-size, the output image width or height is not aligned to a multiple of 4 as expected.

To Reproduce
Steps to reproduce the behavior:

  1. Add --fix-size or -fs to arguments.
  2. Add --max-size 10 to arguments.
  3. Use any PNG file as input.
  4. Run the command. The generated DDS file will have a width or height not divisible by 4 (e.g. 10x10).

Expected behavior
The output image should have both width and height as multiples of 4.
This is required for BC compression formats and should be ensured by --fix-size.

System (please complete the following information):
Not relevant.

Additional context
fix_size is only used in filter_decode_png.cpp and not applied in filter_scale_image.cpp.

if (_fix_size && (first.width() % 4 != 0 || first.height() % 4 != 0)) [[unlikely]] {
result = fix_image_size(*result, _mipmaps);
const auto& new_first = result->get_image(0UL);
file_data.width = new_first.width();
file_data.height = new_first.height();
}

auto width = (input_image.width() * _scale) / 100U;
auto height = (input_image.height() * _scale) / 100U;
if (_max_size > 0U && (width > _max_size || height > _max_size)) {
if (width > height) {
const double ratio = static_cast<double>(_max_size) / static_cast<double>(width);
width = _max_size;
height = static_cast<std::size_t>(static_cast<double>(height) * ratio);
} else {
const double ratio = static_cast<double>(_max_size) / static_cast<double>(height);
height = _max_size;
width = static_cast<std::size_t>(static_cast<double>(width) * ratio);
}
}
if (width == 0 || height == 0) {
_updates.emplace(report_type::pipeline_error,
fmt::format("Could not scale {:s} from ({:d}, {:d}) to ({:d}, {:d}).", _paths[img->file_index()].first.string(),
input_image.width(), input_image.height(), width, height));
return nullptr;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions