squarepix 0.1.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Your Name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,46 @@
1
+ Metadata-Version: 2.4
2
+ Name: squarepix
3
+ Version: 0.1.0
4
+ Summary: Bulk center-crop and resize images to a square in one command.
5
+ Author-email: Your Name <you@example.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/yourusername/squarepix
8
+ Keywords: image,crop,resize,square,batch,pillow
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: Pillow>=9.0.0
17
+ Dynamic: license-file
18
+
19
+ # squarepix
20
+
21
+ Bulk center-crop images to a square and resize them — from the command line or from Python.
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ pip install squarepix
27
+ ```
28
+
29
+ ## Usage (command line)
30
+
31
+ ```bash
32
+ squarepix "D:\InputImages" "D:\OutputImages"
33
+ squarepix "D:\InputImages" "D:\OutputImages" --size 512 512
34
+ ```
35
+
36
+ ## Usage (Python)
37
+
38
+ ```python
39
+ from squarepix import process_folder
40
+
41
+ process_folder("D:/InputImages", "D:/OutputImages", output_size=(640, 640))
42
+ ```
43
+
44
+ ## Supported formats
45
+
46
+ `.jpg .jpeg .png .bmp .tif .tiff .webp`
@@ -0,0 +1,28 @@
1
+ # squarepix
2
+
3
+ Bulk center-crop images to a square and resize them — from the command line or from Python.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install squarepix
9
+ ```
10
+
11
+ ## Usage (command line)
12
+
13
+ ```bash
14
+ squarepix "D:\InputImages" "D:\OutputImages"
15
+ squarepix "D:\InputImages" "D:\OutputImages" --size 512 512
16
+ ```
17
+
18
+ ## Usage (Python)
19
+
20
+ ```python
21
+ from squarepix import process_folder
22
+
23
+ process_folder("D:/InputImages", "D:/OutputImages", output_size=(640, 640))
24
+ ```
25
+
26
+ ## Supported formats
27
+
28
+ `.jpg .jpeg .png .bmp .tif .tiff .webp`
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "squarepix"
7
+ version = "0.1.0"
8
+ description = "Bulk center-crop and resize images to a square in one command."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Your Name", email = "you@example.com" }
14
+ ]
15
+ keywords = ["image", "crop", "resize", "square", "batch", "pillow"]
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Topic :: Multimedia :: Graphics :: Graphics Conversion",
21
+ ]
22
+ dependencies = [
23
+ "Pillow>=9.0.0"
24
+ ]
25
+
26
+ [project.scripts]
27
+ squarepix = "squarepix.cli:main"
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/yourusername/squarepix"
31
+
32
+ [tool.setuptools.packages.find]
33
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,6 @@
1
+ """squarepix: bulk center-crop and resize images to square dimensions."""
2
+
3
+ from .core import process_folder
4
+
5
+ __version__ = "0.1.0"
6
+ __all__ = ["process_folder"]
@@ -0,0 +1,41 @@
1
+ """Command-line interface for squarepix."""
2
+
3
+ import argparse
4
+ import sys
5
+
6
+ from .core import process_folder
7
+
8
+
9
+ def main():
10
+ parser = argparse.ArgumentParser(
11
+ prog="squarepix",
12
+ description="Center-crop images to a square and resize them in bulk.",
13
+ )
14
+ parser.add_argument("input_folder", help="Folder containing source images")
15
+ parser.add_argument("output_folder", help="Folder to save processed images")
16
+ parser.add_argument(
17
+ "--size",
18
+ type=int,
19
+ nargs=2,
20
+ metavar=("WIDTH", "HEIGHT"),
21
+ default=(640, 640),
22
+ help="Output size as WIDTH HEIGHT (default: 640 640)",
23
+ )
24
+
25
+ args = parser.parse_args()
26
+
27
+ if not os_path_isdir(args.input_folder):
28
+ print(f"Error: input folder not found: {args.input_folder}", file=sys.stderr)
29
+ sys.exit(1)
30
+
31
+ count = process_folder(args.input_folder, args.output_folder, tuple(args.size))
32
+ print(f"Done! {count} image(s) processed and saved to {args.output_folder}")
33
+
34
+
35
+ def os_path_isdir(path):
36
+ import os
37
+ return os.path.isdir(path)
38
+
39
+
40
+ if __name__ == "__main__":
41
+ main()
@@ -0,0 +1,53 @@
1
+ """Core logic for center-cropping images to a square and resizing them."""
2
+
3
+ import os
4
+ from PIL import Image
5
+
6
+ EXTENSIONS = (".jpg", ".jpeg", ".png", ".bmp", ".tif", ".tiff", ".webp")
7
+
8
+
9
+ def process_folder(input_folder: str, output_folder: str, output_size=(640, 640)):
10
+ """Center-crop every supported image in input_folder to a square, resize
11
+ it to output_size, and save it into output_folder.
12
+
13
+ Args:
14
+ input_folder: Path to the folder containing source images.
15
+ output_folder: Path to the folder where processed images are saved.
16
+ output_size: Tuple (width, height) for the final resized image.
17
+
18
+ Returns:
19
+ The number of images processed.
20
+ """
21
+ os.makedirs(output_folder, exist_ok=True)
22
+ count = 0
23
+
24
+ for filename in os.listdir(input_folder):
25
+ if not filename.lower().endswith(EXTENSIONS):
26
+ continue
27
+
28
+ img_path = os.path.join(input_folder, filename)
29
+ with Image.open(img_path) as img:
30
+ width, height = img.size
31
+
32
+ # -------- Center Crop to Square --------
33
+ if height > width:
34
+ excess = height - width
35
+ top = excess // 2
36
+ bottom = top + width
37
+ img = img.crop((0, top, width, bottom))
38
+ elif width > height:
39
+ excess = width - height
40
+ left = excess // 2
41
+ right = left + height
42
+ img = img.crop((left, 0, right, height))
43
+ # If already square, no cropping needed
44
+
45
+ # -------- Resize --------
46
+ img = img.resize(output_size, Image.Resampling.LANCZOS)
47
+
48
+ # -------- Save --------
49
+ save_path = os.path.join(output_folder, filename)
50
+ img.save(save_path)
51
+ count += 1
52
+
53
+ return count
@@ -0,0 +1,46 @@
1
+ Metadata-Version: 2.4
2
+ Name: squarepix
3
+ Version: 0.1.0
4
+ Summary: Bulk center-crop and resize images to a square in one command.
5
+ Author-email: Your Name <you@example.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/yourusername/squarepix
8
+ Keywords: image,crop,resize,square,batch,pillow
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: Pillow>=9.0.0
17
+ Dynamic: license-file
18
+
19
+ # squarepix
20
+
21
+ Bulk center-crop images to a square and resize them — from the command line or from Python.
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ pip install squarepix
27
+ ```
28
+
29
+ ## Usage (command line)
30
+
31
+ ```bash
32
+ squarepix "D:\InputImages" "D:\OutputImages"
33
+ squarepix "D:\InputImages" "D:\OutputImages" --size 512 512
34
+ ```
35
+
36
+ ## Usage (Python)
37
+
38
+ ```python
39
+ from squarepix import process_folder
40
+
41
+ process_folder("D:/InputImages", "D:/OutputImages", output_size=(640, 640))
42
+ ```
43
+
44
+ ## Supported formats
45
+
46
+ `.jpg .jpeg .png .bmp .tif .tiff .webp`
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/squarepix/__init__.py
5
+ src/squarepix/cli.py
6
+ src/squarepix/core.py
7
+ src/squarepix.egg-info/PKG-INFO
8
+ src/squarepix.egg-info/SOURCES.txt
9
+ src/squarepix.egg-info/dependency_links.txt
10
+ src/squarepix.egg-info/entry_points.txt
11
+ src/squarepix.egg-info/requires.txt
12
+ src/squarepix.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ squarepix = squarepix.cli:main
@@ -0,0 +1 @@
1
+ Pillow>=9.0.0
@@ -0,0 +1 @@
1
+ squarepix