Skip to content

Commit d90d300

Browse files
committed
provide simple features
1 parent 2fdb0dd commit d90d300

File tree

16 files changed

+1016
-24
lines changed

16 files changed

+1016
-24
lines changed

.DS_Store

2 KB
Binary file not shown.

.github/workflows/build.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build wxPython
2+
on:
3+
push:
4+
paths-ignore:
5+
- 'docs/**'
6+
workflow_dispatch:
7+
release:
8+
types: [published]
9+
jobs:
10+
build:
11+
name: Build wxPython
12+
runs-on: macos-15
13+
if: github.repository_owner == 'pyquick'
14+
permissions:
15+
contents: write
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Install Dependencies
19+
run: |
20+
chmod +x build.command
21+
pip3.13 install -r requirements.txt
22+
- name: Set up Python 3.13
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.13'
26+
- name: Build Apps
27+
run: |
28+
./build.command
29+
- name: Create (Pre-)Release on Push
30+
if: github.event_name == 'push'
31+
uses: softprops/action-gh-release@v2
32+
with:
33+
tag_name: 0.90
34+
name: 1.0Pre
35+
body: ${{ github.event.head_commit.message }}
36+
prerelease: true
37+
files: |
38+
./dist/AutoPkg-Assets.pkg
39+
./dist/OCLP-R.pkg
40+
./dist/OCLP-R-Uninstaller.pkg
41+
42+

README.md

Lines changed: 89 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This script converts PNG images to ICNS format, which is used for macOS icons.
44

55
## Requirements
66

7-
- Python 3
7+
- Python 3.11, 3.12, or 3.13 (recommended)
88
- PIL (Pillow) library
99

1010
Install Pillow with:
@@ -14,33 +14,114 @@ pip install Pillow
1414

1515
## Usage
1616

17+
### Command Line Version
18+
1719
Basic usage:
1820
```
19-
python3 convert.py input.png output.icns
21+
python3 support/convert.py input.png output.icns
2022
```
2123

2224
Advanced usage with size options:
2325
```
24-
python3 convert.py input.png output.icns --min-size 16 --max-size 512
26+
python3 support/convert.py input.png output.icns --min-size 16 --max-size 512
27+
```
28+
29+
### GUI Version
30+
31+
For a graphical interface, run:
32+
```
33+
python3 gui_converter.py
34+
```
35+
36+
## Building a Standalone Application
37+
38+
To compile the application into a macOS .app bundle, run:
39+
```
40+
./build.command
41+
```
42+
43+
This will create a standalone application in the `dist` folder using Nuitka with Python 3.13.
44+
45+
**Note:** The build script is specifically designed to work with Python 3.13 to avoid compatibility issues.
46+
47+
### Requirements for Building
48+
49+
- Python 3.13
50+
- Nuitka
51+
- Pillow
52+
53+
Install build requirements:
54+
```
55+
python3.13 -m pip install Pillow nuitka
56+
```
57+
58+
The build script will automatically:
59+
1. Download ccache to avoid SSL certificate issues
60+
2. Use Python 3.13 for compilation
61+
3. Create a standalone .app bundle
62+
63+
## Alternative: Simple Launcher Script
64+
65+
If you cannot build the application with Nuitka, you can use the provided launcher script:
66+
```
67+
./PNG_to_ICNS_Converter.command
2568
```
2669

27-
### Options
70+
This script will run the application directly with Python without requiring compilation.
71+
72+
## Options
2873

2974
- `--min-size`: Minimum icon size (default: 16)
30-
- `--max-size`: Maximum icon size (default: original image size)
75+
- `--max-size`: Maximum icon size (default: auto-detected from image)
3176

3277
## Features
3378

3479
- Automatically generates multiple icon sizes from the original image
3580
- Supports retina (2x) versions for common sizes
3681
- Crops non-square images to square format
37-
- Generates icons from 16x16 up to the original image size (or specified max size)
82+
- Automatically detects image size and uses it as maximum icon size
83+
- GUI interface for easier use with image preview
84+
- Progress indication during conversion
85+
- Automatic opening of the result in Preview app
3886

3987
## Example
4088

4189
To convert a 256x256 PNG image to ICNS with default settings:
4290
```
43-
python3 convert.py icon.png icon.icns
91+
python3 support/convert.py icon.png icon.icns
92+
```
93+
94+
This will generate icons in sizes: 16x16, 32x32, 64x64, 128x128, and 256x256, including retina versions where appropriate.
95+
96+
To use the GUI version:
97+
```
98+
python3 gui_converter.py
99+
```
100+
101+
The GUI provides a user-friendly interface with:
102+
- File browsing for input and output files
103+
- Preview of the source image
104+
- Image information display (dimensions)
105+
- Customizable minimum and maximum icon sizes
106+
- Auto-detect maximum size button
107+
- Progress indication during conversion
108+
- Status bar showing current operation
109+
110+
When using the GUI, the maximum icon size is automatically set to match the smaller dimension of the source image when you select an input file.
111+
112+
To build a standalone macOS application, run:
44113
```
114+
./build.command
115+
```
116+
117+
This will create a .app bundle in the dist folder that can be run without requiring Python to be installed.
45118

46-
This will generate icons in sizes: 16x16, 32x32, 64x64, 128x128, and 256x256, including retina versions where appropriate.
119+
If you encounter issues with the build process, you can use the simple launcher script instead:
120+
```
121+
./PNG_to_ICNS_Converter.command
122+
```
123+
124+
Or run directly with Python 3.13:
125+
```
126+
python3.13 gui_converter.py
127+
```
7.67 KB
Binary file not shown.

build.command

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
#!/bin/bash
2+
3+
# Build script for PNG to ICNS Converter
4+
# Uses Nuitka to compile the Python application into a macOS .app bundle
5+
6+
# Get the directory where this script is located
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
PROJECT_DIR="$SCRIPT_DIR"
9+
10+
echo "Building PNG to ICNS Converter..."
11+
echo "Project directory: $PROJECT_DIR"
12+
13+
# Check if required files exist
14+
if [ ! -f "$PROJECT_DIR/gui_converter.py" ]; then
15+
echo "Error: gui_converter.py not found in project directory"
16+
exit 1
17+
fi
18+
19+
if [ ! -d "$PROJECT_DIR/support" ]; then
20+
echo "Error: support directory not found in project directory"
21+
exit 1
22+
fi
23+
24+
# Create build directory
25+
BUILD_DIR="$PROJECT_DIR/build"
26+
DIST_DIR="$PROJECT_DIR/dist"
27+
28+
echo "Creating build directories..."
29+
mkdir -p "$BUILD_DIR"
30+
mkdir -p "$DIST_DIR"
31+
32+
# Manually download ccache to avoid SSL issues
33+
echo "Setting up ccache..."
34+
CCACHE_DIR="/Users/$USER/Library/Caches/Nuitka/downloads/ccache/v4.2.1"
35+
CCACHE_ZIP="$CCACHE_DIR/ccache-4.2.1.zip"
36+
37+
if [ ! -f "$CCACHE_ZIP" ]; then
38+
echo "Downloading ccache to avoid SSL issues..."
39+
mkdir -p "$CCACHE_DIR"
40+
41+
# Try to download with curl, ignoring SSL errors
42+
curl -k -L "https://nuitka.net/ccache/v4.2.1/ccache-4.2.1.zip" -o "$CCACHE_ZIP"
43+
44+
if [ ! -f "$CCACHE_ZIP" ]; then
45+
echo "Failed to download ccache. Continuing without it..."
46+
else
47+
echo "Downloaded ccache successfully."
48+
fi
49+
else
50+
echo "ccache already downloaded."
51+
fi
52+
53+
# Install required dependencies if not already installed
54+
echo "Checking and installing dependencies..."
55+
python3.13 -m pip install Pillow nuitka
56+
57+
# Try to determine Python version
58+
PYTHON_VERSION=$(python3.13 --version | cut -d' ' -f2 | cut -d'.' -f1,2)
59+
PYTHON_FULL_VERSION=$(python3.13 --version | cut -d' ' -f2)
60+
echo "Using Python version: $PYTHON_FULL_VERSION"
61+
62+
# Build the application using Nuitka with Python 3.13
63+
echo "Compiling with Nuitka using Python 3.13..."
64+
65+
# Different approach for different Python versions
66+
BUILD_SUCCESS=0
67+
68+
# Try the recommended approach first
69+
echo "Trying recommended build approach..."
70+
python3.13 -m nuitka \
71+
--standalone \
72+
--macos-create-app-bundle \
73+
--macos-app-icon="$PROJECT_DIR/support/Success.icns" \
74+
--include-data-dir="$PROJECT_DIR/support=support" \
75+
--enable-plugin=tk-inter \
76+
--output-dir="$DIST_DIR" \
77+
--remove-output \
78+
"$PROJECT_DIR/gui_converter.py" && BUILD_SUCCESS=1
79+
80+
# If that fails, try alternative approaches
81+
if [ $BUILD_SUCCESS -eq 0 ]; then
82+
echo "First approach failed. Trying alternative build approach..."
83+
84+
# Try without --remove-output
85+
python3.13 -m nuitka \
86+
--standalone \
87+
--macos-create-app-bundle \
88+
--macos-app-icon="$PROJECT_DIR/support/Success.icns" \
89+
--include-data-dir="$PROJECT_DIR/support=support" \
90+
--enable-plugin=tk-inter \
91+
--output-dir="$DIST_DIR" \
92+
"$PROJECT_DIR/gui_converter.py" && BUILD_SUCCESS=1
93+
fi
94+
95+
if [ $BUILD_SUCCESS -eq 0 ]; then
96+
echo "Second approach failed. Trying minimal build approach..."
97+
98+
# Try minimal approach
99+
python3.13 -m nuitka \
100+
--standalone \
101+
--macos-create-app-bundle \
102+
--include-data-dir="$PROJECT_DIR/support=support" \
103+
--enable-plugin=tk-inter \
104+
--output-dir="$DIST_DIR" \
105+
"$PROJECT_DIR/gui_converter.py" && BUILD_SUCCESS=1
106+
fi
107+
108+
if [ $BUILD_SUCCESS -eq 0 ]; then
109+
echo "All Nuitka approaches failed. Creating a simple application bundle instead..."
110+
111+
# Create a simple app bundle structure
112+
APP_DIR="$DIST_DIR/PNG to ICNS Converter.app"
113+
CONTENTS_DIR="$APP_DIR/Contents"
114+
MACOS_DIR="$CONTENTS_DIR/MacOS"
115+
RESOURCES_DIR="$CONTENTS_DIR/Resources"
116+
117+
echo "Creating simple app bundle structure..."
118+
mkdir -p "$MACOS_DIR"
119+
mkdir -p "$RESOURCES_DIR"
120+
121+
# Copy required files
122+
echo "Copying application files..."
123+
cp -r "$PROJECT_DIR/support" "$RESOURCES_DIR/"
124+
cp "$PROJECT_DIR/gui_converter.py" "$RESOURCES_DIR/"
125+
126+
# Create a simple launcher script
127+
LAUNCHER_SCRIPT="$MACOS_DIR/png_to_icns_converter"
128+
echo "#!/bin/bash" > "$LAUNCHER_SCRIPT"
129+
echo "cd \"\$(dirname \"\$0\")/../Resources\" || exit 1" >> "$LAUNCHER_SCRIPT"
130+
echo "python3.13 gui_converter.py" >> "$LAUNCHER_SCRIPT"
131+
chmod +x "$LAUNCHER_SCRIPT"
132+
133+
# Create Info.plist
134+
cat > "$CONTENTS_DIR/Info.plist" << EOF
135+
<?xml version="1.0" encoding="UTF-8"?>
136+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
137+
<plist version="1.0">
138+
<dict>
139+
<key>CFBundleExecutable</key>
140+
<string>png_to_icns_converter</string>
141+
<key>CFBundleIdentifier</key>
142+
<string>com.png.icns.converter</string>
143+
<key>CFBundleName</key>
144+
<string>PNG to ICNS Converter</string>
145+
<key>CFBundleIconFile</key>
146+
<string>Success.icns</string>
147+
<key>CFBundleInfoDictionaryVersion</key>
148+
<string>6.0</string>
149+
<key>CFBundlePackageType</key>
150+
<string>APPL</string>
151+
<key>CFBundleShortVersionString</key>
152+
<string>1.0</string>
153+
<key>CFBundleVersion</key>
154+
<string>1.0</string>
155+
<key>LSMinimumSystemVersion</key>
156+
<string>10.13.0</string>
157+
</dict>
158+
</plist>
159+
EOF
160+
161+
# Copy the icon
162+
if [ -f "$PROJECT_DIR/support/Success.icns" ]; then
163+
cp "$PROJECT_DIR/support/Success.icns" "$RESOURCES_DIR/"
164+
fi
165+
166+
BUILD_SUCCESS=1
167+
echo "Simple app bundle created at: $APP_DIR"
168+
fi
169+
170+
# Check if build was successful
171+
if [ $BUILD_SUCCESS -eq 1 ]; then
172+
if ls "$DIST_DIR"/*.app 1> /dev/null 2>&1; then
173+
APP_NAME=$(ls "$DIST_DIR"/*.app | head -n 1)
174+
echo "Build successful!"
175+
echo "Application created at: $APP_NAME"
176+
177+
# Show app bundle information
178+
echo "Application information:"
179+
ls -lh "$APP_NAME"
180+
181+
echo ""
182+
echo "To run the application, double-click on the app in Finder"
183+
echo "or run the following command in terminal:"
184+
echo "open '$APP_NAME'"
185+
else
186+
echo "Build process completed."
187+
echo "You can run the application using the launcher script:"
188+
echo "./PNG_to_ICNS_Converter.command"
189+
fi
190+
else
191+
echo "Build failed with all approaches!"
192+
echo "Recommendations:"
193+
echo "1. Run the application directly with Python 3.13:"
194+
echo " python3.13 gui_converter.py"
195+
echo "2. Use the simple launcher script:"
196+
echo " ./PNG_to_ICNS_Converter.command"
197+
exit 1
198+
fi

0 commit comments

Comments
 (0)