2 functions that provide convenient and efficient ways to resize images to a square with custom backgrounds and convert images to the ICO format
Project description
2 functions that provide convenient and efficient ways to resize images to a square with custom backgrounds and convert images to the ICO format
pip install pic2square2icon
Tested against Windows 10 / Python 3.10 / Anaconda
The functions resize_with_background and pic2ico can be used by developers or individuals who work with image processing or need to manipulate images for various purposes. Here are some potential use cases for each function:
resize_with_background:
-
Graphic designers who want to resize an image to a specific size (square) while maintaining its aspect ratio and adding a background
-
Web developers who need to generate thumbnail images with a consistent size and background for their websites.
-
Content creators who want to resize and add a background to their images for social media posts (instagram or facebook timeline) or presentations.
pic2ico:
- Software developers who need to convert image files to the ICO (icon) format for use in applications or software interfaces.
- Designers who want to create custom icons from their existing image assets.
- System administrators or IT professionals who need to generate ICO files for use as desktop icons or shortcuts.
from pic2square2icon import resize_with_background, pic2ico
import cv2
test = 1
fg = r"C:\testim\fg.png"
bg = r"C:\testim\bg.png"
target_size = 512
resized_image = resize_with_background(fg, target_size, bg)
pic2ico(src=resized_image, dst=rf"C:\testim\{test}.ico")
resized_image.save(rf"C:\testim\{test}.png")
test = 2
fg = r"C:\testim\fg.png"
bg = "orange"
target_size = 512
resized_image = resize_with_background(fg, target_size, bg)
pic2ico(src=resized_image, dst=rf"C:\testim\{test}.ico")
resized_image.save(rf"C:\testim\{test}.png")
test = 3
fg = r"C:\testim\fg.png"
bg = (255, 255, 0)
target_size = 512
resized_image = resize_with_background(fg, target_size, bg)
pic2ico(src=resized_image, dst=rf"C:\testim\{test}.ico")
resized_image.save(rf"C:\testim\{test}.png")
test = 4
fg = r"C:\testim\bg.png"
bg = cv2.imread(r"C:\testim\fg.png")
target_size = 512
resized_image = resize_with_background(fg, target_size, bg)
pic2ico(src=resized_image, dst=rf"C:\testim\{test}.ico")
resized_image.save(rf"C:\testim\{test}.png")
g.png
g.png
1.png
2.png
3.png
4.png
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pic2square2icon-0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2997d7fd5ac4ef0c4c0fbd1c79c5b9d99ae4778d51d6735766366c70457d35b4 |
|
MD5 | 7b0439f47876a5a3a7887857269a1170 |
|
BLAKE2b-256 | b5a0194a69ce8f31e0d4136880fd66c48434c995d94f13d066a81b419766efd6 |