Skip to content

[pull] master from libvips:master#53

Merged
pull[bot] merged 2 commits intoadmariner:masterfrom
libvips:master
Jun 2, 2025
Merged

[pull] master from libvips:master#53
pull[bot] merged 2 commits intoadmariner:masterfrom
libvips:master

Conversation

@pull
Copy link
Copy Markdown

@pull pull bot commented Jun 2, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

Summary by Sourcery

Introduce a buffer-based loader for PPM images and unify foreign build function implementations by returning parent class build results directly.

New Features:

  • Add support for loading PPM images from memory buffers via vips_ppmload_buffer and VImage::ppmload_buffer

Enhancements:

  • Streamline foreign build methods by directly delegating to parent class implementations across image formats

Documentation:

  • Document the new ppmload_buffer operation in function-list.md and update C++ headers

Tests:

  • Update PPM load tests to use the new buffer-based loading interface

@pull pull bot added the ⤵️ pull label Jun 2, 2025
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Jun 2, 2025

Reviewer's Guide

This PR introduces a buffer-based PPM loader and refactors all foreign load/save classes to streamline their build methods by delegating directly to parent class build, along with updating C++ bindings, docs, and tests to support the new API.

Sequence Diagram for vips_ppmload_buffer Operation

sequenceDiagram
    actor ClientApp as "Client Application"
    participant C_API as "vips_ppmload_buffer()"
    participant CoreOp as "ppmload_buffer Operation Core"
    participant BufferLoader as "VipsForeignLoadPpmBuffer"
    participant ParentBuild as "VipsForeignLoadPpm.build()"
    participant VipsSourceLib as "VipsSource Library"

    ClientApp->>C_API: Call vips_ppmload_buffer(buffer_ptr, len, &out_image)
    C_API->>C_API: Create VipsBlob from buffer_ptr, len
    C_API->>CoreOp: vips_call_split("ppmload_buffer", blob, &out_image)
    CoreOp->>BufferLoader: vips_foreign_load_ppm_buffer_build(self)
    activate BufferLoader
    BufferLoader->>VipsSourceLib: vips_source_new_from_memory(blob_data, blob_length)
    VipsSourceLib-->>BufferLoader: new VipsSource
    BufferLoader->>ParentBuild: Call parent_class->build(self)
    activate ParentBuild
    ParentBuild-->>BufferLoader: build_result (image data read via VipsSource)
    deactivate ParentBuild
    BufferLoader-->>CoreOp: build_result
    deactivate BufferLoader
    CoreOp-->>C_API: result (image loaded)
    C_API->>C_API: vips_area_unref(VipsBlob)
    C_API-->>ClientApp: Return 0 (success) or -1 (error)
Loading

Class Diagram for New PPM Buffer Loading Functionality

classDiagram
    direction TB
    class VipsForeignLoadPpm {
        <<Base Class for PPM Loading>>
        # VipsSource* source
        # build(VipsObject* object) int
    }

    class VipsForeignLoadPpmBuffer {
        + VipsBlob* blob
        + vips_foreign_load_ppm_buffer_build(VipsObject* object) int
        + vips_foreign_load_ppm_is_a_buffer(const void* buf, size_t len) gboolean
        + vips_foreign_load_ppm_buffer_class_init(VipsForeignLoadPpmBufferClass* class) void
        + vips_foreign_load_ppm_buffer_init(VipsForeignLoadPpmBuffer* buffer) void
    }
    VipsForeignLoadPpm <|-- VipsForeignLoadPpmBuffer

    class VipsBlob {
      + void* data
      + size_t length
    }
    VipsForeignLoadPpmBuffer *-- "1" VipsBlob : "loads_from"

    class PublicAPI {
        <<API Entry Points>>
        + vips_ppmload_buffer(void* buf, size_t len, VipsImage** out, ...) int
        + VImage VImage::ppmload_buffer(VipsBlob* buffer, VOption* options)
    }
    PublicAPI ..> VipsForeignLoadPpmBuffer : invokes
Loading

File-Level Changes

Change Details Files
Add buffer-based PPM loader
  • Define VipsForeignLoadPpmBuffer type and build method
  • Implement vips_ppmload_buffer and buffer detection
  • Register new buffer operation in foreign init
libvips/foreign/ppmload.c
libvips/foreign/foreign.c
libvips/include/vips/foreign.h
Extend C++ API and documentation for ppmload_buffer
  • Add ppmload_buffer method to VImage8.h
  • Implement VImage::ppmload_buffer in vips-operators.cpp
  • Update function-list.md and ChangeLog entries
cplusplus/include/vips/VImage8.h
cplusplus/vips-operators.cpp
doc/function-list.md
ChangeLog
Refactor build() methods across foreign modules
  • Replace manual if-error-return/return 0 with direct return of parent_class->build
  • Apply to both load and save classes for all supported formats
libvips/foreign/heifload.c
libvips/foreign/jp2kload.c
libvips/foreign/jpegload.c
libvips/foreign/webpload.c
libvips/foreign/jxlload.c
libvips/foreign/nsgifload.c
libvips/foreign/tiffload.c
libvips/foreign/fitsload.c
libvips/foreign/matrixload.c
libvips/foreign/niftiload.c
libvips/foreign/pngload.c
libvips/foreign/spngload.c
libvips/foreign/csvload.c
libvips/foreign/radload.c
libvips/foreign/dzsave.c
libvips/foreign/heifsave.c
libvips/foreign/jp2ksave.c
libvips/foreign/tiffsave.c
libvips/foreign/vipsload.c
libvips/foreign/vipssave.c
libvips/foreign/webpsave.c
libvips/foreign/jxlsave.c
libvips/foreign/openslideload.c
libvips/foreign/pngsave.c
libvips/foreign/spngsave.c
libvips/foreign/magick6load.c
libvips/foreign/matrixsave.c
libvips/foreign/pdfiumload.c
libvips/foreign/popplerload.c
Update test suite for new buffer loader
  • Remove old ppmload_source test case
  • Use Image.new_from_buffer for PPM memory input
test/test-suite/test_foreign.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@pull pull bot merged commit 67eb11b into admariner:master Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant