Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bindings/kotlin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=io.clroot.slimg
version=0.4.0
version=0.5.0
kotlin.code.style=official
4 changes: 2 additions & 2 deletions bindings/kotlin/src/test/kotlin/io/clroot/slimg/SlimgTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ class SlimgTest {
}

@Test
fun `formatCanEncode returns false only for JXL`() {
fun `formatCanEncode returns true for all formats`() {
assertTrue(formatCanEncode(Format.JPEG))
assertTrue(formatCanEncode(Format.PNG))
assertTrue(formatCanEncode(Format.WEB_P))
assertTrue(formatCanEncode(Format.AVIF))
assertFalse(formatCanEncode(Format.JXL))
assertTrue(formatCanEncode(Format.JXL))
assertTrue(formatCanEncode(Format.QOI))
}
Comment on lines +51 to 58

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

이 테스트는 모든 Format 열거형 멤버를 순회하도록 리팩터링하여 향후 새로운 포맷이 추가될 때 테스트가 자동으로 확장되도록 할 수 있습니다. 이렇게 하면 유지보수성이 향상됩니다.

    fun `formatCanEncode returns true for all formats`() {
        for (format in Format.values()) {
            assertTrue(formatCanEncode(format), "Encoding should be supported for $format")
        }
    }


Expand Down
2 changes: 1 addition & 1 deletion bindings/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "slimg"
version = "0.4.0"
version = "0.5.0"
requires-python = ">=3.9"
description = "Fast image optimization library powered by Rust"
readme = "README.md"
Expand Down
7 changes: 4 additions & 3 deletions bindings/python/tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ def test_format_enum_accepted(self, sample_image):
result = slimg.convert(sample_image, format=slimg.Format.PNG, quality=80)
assert result.format == slimg.Format.PNG

def test_jxl_encode_raises(self, sample_image):
with pytest.raises(slimg.SlimgError):
slimg.convert(sample_image, format="jxl", quality=80)
def test_to_jxl(self, sample_image):
result = slimg.convert(sample_image, format="jxl", quality=80)
assert result.format == slimg.Format.JXL
assert len(result.data) > 0
Comment on lines +50 to +53

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

다른 포맷의 테스트와 일관성을 유지하고 테스트를 더 견고하게 만들기 위해 JXL 매직 바이트를 확인하는 단언문(assertion)을 추가하는 것이 좋습니다. JXL은 두 가지 시그니처(bare codestream 또는 container)를 가질 수 있습니다.

    def test_to_jxl(self, sample_image):
        result = slimg.convert(sample_image, format="jxl", quality=80)
        assert result.format == slimg.Format.JXL
        assert len(result.data) > 0
        # JXL can have a bare codestream (FF 0A) or be in a container (JXL ).
        is_bare = result.data[:2] == b'\xff\x0a'
        is_container = len(result.data) >= 8 and result.data[:4] == b'\x00\x00\x00\x0c' and result.data[4:8] == b'JXL '
        assert is_bare or is_container, "JXL magic bytes not found"


def test_full_pipeline_crop_extend(self, sample_image_100):
result = slimg.convert(
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def test_png_can_encode(self):
def test_webp_can_encode(self):
assert slimg.Format.WEBP.can_encode is True

def test_jxl_cannot_encode(self):
assert slimg.Format.JXL.can_encode is False
def test_jxl_can_encode(self):
assert slimg.Format.JXL.can_encode is True
Comment on lines +35 to +36

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

이 테스트 클래스는 현재 모든 포맷을 다루고 있지 않으며(AVIF, QOI 누락), 각 포맷에 대한 테스트가 중복됩니다. pytest.mark.parametrize를 사용하여 모든 포맷을 한 번에 테스트하도록 리팩터링하면 더 간결하고 유지보수하기 좋은 코드가 될 것입니다. 예를 들어, 다음과 같이 작성할 수 있습니다:

import pytest
import slimg

@pytest.mark.parametrize("format_enum", list(slimg.Format))
def test_all_formats_can_encode(format_enum):
    assert format_enum.can_encode is True

이렇게 하면 TestFormatCanEncode 클래스 전체를 대체할 수 있습니다.



class TestFormatFromPath:
Expand Down
4 changes: 2 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "slimg"
version = "0.4.0"
version = "0.5.0"
edition = "2024"
license = "MIT"
description = "Image optimization CLI — convert, compress, and resize images using MozJPEG, OxiPNG, WebP, AVIF, and QOI"
Expand All @@ -11,7 +11,7 @@ keywords = ["image", "optimization", "cli", "compression", "webp"]
categories = ["multimedia::images", "command-line-utilities"]

[dependencies]
slimg-core = { version = "0.4.0", path = "../crates/slimg-core" }
slimg-core = { version = "0.5.0", path = "../crates/slimg-core" }
clap = { version = "4.5", features = ["derive"] }
clap_complete = "4.5"
anyhow = "1"
Expand Down
1 change: 1 addition & 0 deletions crates/libjxl-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fn main() {
#[cfg(feature = "vendored")]
fn build_vendored() {
let dst = cmake::Config::new("libjxl")
.profile("Release")
.define("BUILD_TESTING", "OFF")
.define("BUILD_SHARED_LIBS", "OFF")
.define("JPEGXL_ENABLE_TOOLS", "OFF")
Expand Down
2 changes: 1 addition & 1 deletion crates/slimg-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "slimg-core"
version = "0.4.0"
version = "0.5.0"
edition = "2024"
license = "MIT"
description = "Image optimization library — encode, decode, convert, resize with MozJPEG, OxiPNG, WebP, AVIF, and QOI"
Expand Down
2 changes: 1 addition & 1 deletion crates/slimg-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "slimg-ffi"
version = "0.4.0"
version = "0.5.0"
edition = "2024"
license = "MIT"
description = "UniFFI bindings for slimg-core image optimization library"
Expand Down
Loading