nt25 0.1.8__tar.gz → 0.1.9__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.
@@ -12,6 +12,7 @@ uv.lock
12
12
 
13
13
  # package
14
14
  *.spec
15
+ scripts/pub.sh
15
16
 
16
17
  # dataset
17
18
  ds/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nt25
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: Neo's Tools of Python
5
5
  Requires-Python: >=3.10
6
6
  Requires-Dist: exif>=1.6.1
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nt25"
3
- version = "0.1.8"
3
+ version = "0.1.9"
4
4
  description = "Neo's Tools of Python"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -40,10 +40,15 @@ def optimizeFile(file, q=80, mw=MAX_WIDTH):
40
40
 
41
41
  img = pi.open(file)
42
42
  w, h = img.size
43
- scale = mw / max(w, h)
44
- w = int(scale * w)
45
- h = int(scale * h)
46
- img.resize((w, h)).save(ofile, quality=q, optimize=True, progression=True)
43
+ m = max(w, h)
44
+
45
+ if m > mw:
46
+ scale = mw / m
47
+ w = int(scale * w)
48
+ h = int(scale * h)
49
+ img = img.resize((w, h))
50
+
51
+ img.save(ofile, quality=q, optimize=True, progression=True)
47
52
 
48
53
  if os.path.getsize(ofile) < os.path.getsize(file) * 0.8:
49
54
  less = True
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes