castletool 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: castletool
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Interactive Castle deck editor for injecting images/GIFs and MIDI into Castle blueprint JSON files.
5
5
  Author-email: Your Name <your.email@example.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -192,10 +192,11 @@ def find_blueprints(card: Path) -> list[Path]:
192
192
 
193
193
  def load_image_frames(path: Path, size: int):
194
194
  img = Image.open(path)
195
+ resample = Image.NEAREST if size > max(img.size) else Image.LANCZOS
195
196
 
196
197
  # Normal image
197
198
  if not getattr(img, "is_animated", False):
198
- frame = img.convert("RGBA").resize((size, size), Image.LANCZOS)
199
+ frame = img.convert("RGBA").resize((size, size), resample)
199
200
  buf = io.BytesIO()
200
201
  frame.save(buf, format="PNG")
201
202
  return [buf.getvalue()], 1.0
@@ -206,7 +207,7 @@ def load_image_frames(path: Path, size: int):
206
207
 
207
208
  try:
208
209
  while True:
209
- frame = img.convert("RGBA").resize((size, size), Image.LANCZOS)
210
+ frame = img.convert("RGBA").resize((size, size), resample)
210
211
  buf = io.BytesIO()
211
212
  frame.save(buf, format="PNG")
212
213
  frames.append(buf.getvalue())
@@ -258,10 +259,13 @@ def extract_mp4_frames(path: Path, size: int, every_n: int = 1) -> tuple[list[by
258
259
 
259
260
  effective_fps = fps / every_n
260
261
 
262
+ src_size = probe_video_size(path)
263
+ scale_flags = "neighbor" if size > src_size else "bicubic"
264
+
261
265
  # Extract frames as PNG via pipe
262
266
  result = subprocess.run(
263
267
  ["ffmpeg", "-i", str(path),
264
- "-vf", f"select='not(mod(n\\,{every_n}))',scale={size}:{size}:force_original_aspect_ratio=decrease,pad={size}:{size}:(ow-iw)/2:(oh-ih)/2",
268
+ "-vf", f"select='not(mod(n\\,{every_n}))',scale={size}:{size}:force_original_aspect_ratio=decrease:flags={scale_flags},pad={size}:{size}:(ow-iw)/2:(oh-ih)/2",
265
269
  "-vsync", "vfr",
266
270
  "-f", "image2pipe", "-vcodec", "png", "-"],
267
271
  capture_output=True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: castletool
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Interactive Castle deck editor for injecting images/GIFs and MIDI into Castle blueprint JSON files.
5
5
  Author-email: Your Name <your.email@example.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "castletool"
7
- version = "0.2.0"
7
+ version = "0.2.2"
8
8
  description = "Interactive Castle deck editor for injecting images/GIFs and MIDI into Castle blueprint JSON files."
9
9
  authors = [
10
10
  { name = "Your Name", email = "your.email@example.com" }
File without changes
File without changes
File without changes