Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filesize check for the cover JPG #741

Merged
merged 1 commit into from
Aug 15, 2024
Merged
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
5 changes: 2 additions & 3 deletions se/se_epub_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,9 +1200,8 @@ def _lint_image_checks(self, filename: Path) -> list:
if image.size != (se.COVER_WIDTH, se.COVER_HEIGHT):
messages.append(LintMessage("f-017", f"[path][link=file://{self.path / 'images/cover.jpg'}]cover.jpg[/][/] must be exactly {se.COVER_WIDTH} × {se.COVER_HEIGHT}.", se.MESSAGE_TYPE_ERROR, filename))

# Run some tests on distributable images in ./src/epub/images/
# Once we reach Python 3.9 we can use path.is_relative_to() instead of this string comparison
if str(filename).startswith(str(self.content_path / "images")):
# Run some tests on distributable images in ./src/epub/images/ and the cover
if filename.is_relative_to(self.content_path / "images") or (self.path / "images" / "cover.jpg" == filename):
if os.path.getsize(filename) > 1500000: # 1.5MB
messages.append(LintMessage("f-016", "Image more than 1.5MB in size.", se.MESSAGE_TYPE_ERROR, filename))

Expand Down
Loading