Skip to content

Conversation

veloman-yunkan
Copy link
Collaborator

@veloman-yunkan veloman-yunkan commented Jun 13, 2025

Fixes #937

Copy link

codecov bot commented Jun 13, 2025

Codecov Report

❌ Patch coverage is 50.56180% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.92%. Comparing base (abf8d4a) to head (7e8bb1a).

Files with missing lines Patch % Lines
src/archive.cpp 41.93% 5 Missing and 13 partials ⚠️
src/tools.cpp 53.84% 1 Missing and 17 partials ⚠️
include/zim/illustration.h 55.55% 0 Missing and 4 partials ⚠️
src/writer/creator.cpp 60.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #997      +/-   ##
==========================================
- Coverage   58.15%   57.92%   -0.24%     
==========================================
  Files         100      101       +1     
  Lines        5325     5407      +82     
  Branches     2179     2219      +40     
==========================================
+ Hits         3097     3132      +35     
- Misses        778      801      +23     
- Partials     1450     1474      +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@veloman-yunkan veloman-yunkan force-pushed the illustration_api_enhancement branch 2 times, most recently from 9f3a61d to d5d3bfb Compare June 15, 2025 13:29
@veloman-yunkan veloman-yunkan marked this pull request as ready for review June 15, 2025 13:30
Copy link
Member

@rgaudin rgaudin left a comment

Choose a reason for hiding this comment

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

Thank you @veloman-yunkan ; implementation LGTM ; I have some general questions though:

  • getIllustrationSizes has not changed. It's a separate discussion but what's the decision on this? @kelson42 ?
  • I thought we'd get a public method to add/read with just the width, height and scale but we have to use a new type. That's OK.
  • I find Archive::getIllustrations() confusing. We're only getting Illustration Info, not actual illustrations. Maybe that's in line with the rest of the libzim code base though?

Copy link

@benoit74 benoit74 left a comment

Choose a reason for hiding this comment

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

Besides rgaudin point, this looks good to me

@veloman-yunkan
Copy link
Collaborator Author

  • getIllustrationSizes has not changed. It's a separate discussion but what's the decision on this? @kelson42 ?

Aren't we going to deprecate the old API?

  • I thought we'd get a public method to add/read with just the width, height and scale but we have to use a new type. That's OK.

I will add wrappers. Let me see how to do it best.

  • I find Archive::getIllustrations() confusing. We're only getting Illustration Info, not actual illustrations. Maybe that's in line with the rest of the libzim code base though?

That's a valid point, but I found Archive::getIllustrationInfos() a little too verbose in a typed language. In this context IllustrationInfo's act like handles to illustration data (that should be obtained via Archive::getIllustrationItem()). Suppose that getIllustrations() returns pointers to the illustration objects. Should it be named getIllustrationPtrs() then? That's the logic behind the name for that method that I ended up with.

@rgaudin
Copy link
Member

rgaudin commented Jun 16, 2025

  • getIllustrationSizes has not changed. It's a separate discussion but what's the decision on this? @kelson42 ?

Aren't we going to deprecate the old API?

Indeed, it's even in the ticket. Is the deprecation doc and warning to be in a separate PR?

  • I find Archive::getIllustrations() confusing. We're only getting Illustration Info, not actual illustrations. Maybe that's in line with the rest of the libzim code base though?

That's a valid point, but I found Archive::getIllustrationInfos() a little too verbose in a typed language. In this context IllustrationInfo's act like handles to illustration data (that should be obtained via Archive::getIllustrationItem()). Suppose that getIllustrations() returns pointers to the illustration objects. Should it be named getIllustrationPtrs() then? That's the logic behind the name for that method that I ended up with.

You are mistaking Type suffixes (which is a terrible practice) with semantic/meaningful naming. I'm just signaling that from my POV it's confusing to request illustrations and receive a struct of illustration metadata. Nothing serious though and I strongly believe that API coherence is more important than individual precision

@veloman-yunkan
Copy link
Collaborator Author

@rgaudin I've renamed getIllustrations() to getIllustrationInfos() and deprecated getIllustrationSizes().

  • I thought we'd get a public method to add/read with just the width, height and scale but we have to use a new type. That's OK.

I will add wrappers. Let me see how to do it best.

I didn't add any wrappers. Instead I provided an overload of getIllustrationInfos() that allows to obtain a list of illustrations with the specified dimensions.

Copy link
Collaborator Author

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

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

Fixup commits will need to be eliminated before the PR is merged

Copy link
Member

@rgaudin rgaudin left a comment

Choose a reason for hiding this comment

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

API LGTM ; thank you and sorry for the delay.

@veloman-yunkan
Copy link
Collaborator Author

@kelson42 Please don't merge until I get rid of the fixup commits.

@veloman-yunkan veloman-yunkan force-pushed the illustration_api_enhancement branch from 5a91b26 to 3a1b99e Compare August 1, 2025 11:17
@veloman-yunkan
Copy link
Collaborator Author

veloman-yunkan commented Aug 1, 2025

The PR has been rebased.

CI failures on Linux are because since kiwix/kiwix-build#834 was merged dependencies are built on jammy, while libzim CI keeps running on focal. Should be fixed by #1002.

The failures on macOS have nothing to do with these changes. One of the failures is because of the following error:

meson.build:55:17: ERROR: Dependency "xapian-core" not found, tried pkgconfig, framework and cmake

The other three failures say:

meson.build:1:0: ERROR: Unknown compiler(s): [['/Applications/Xcode_16.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang']]
The following exception(s) were encountered:
Running /Applications/Xcode_16.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --version gave "[Errno 2] No such file or directory: '/Applications/Xcode_16.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang'"

The new unit test was copied and adapted from the
Tools.parseIllustrationPathToSize unit-test.
There was an extra character in the format string of the sscanf.
Parsing of the illustration metadata item name now supports attributes
too.

Also, an illustration metadata item name is now considered invalid if it
doesn't match the string generated from the result of the parsing (which
can be, for example, due to leading zeros in width and/or height values,
leading and/or trailing zeros in the scale value, wrong order of
attributes, etc).
@veloman-yunkan veloman-yunkan force-pushed the illustration_api_enhancement branch from 3a1b99e to 7e8bb1a Compare August 1, 2025 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Illustrations scale (dpr), height and width
3 participants