Guide for building Photo Size Reducer as standalone executables for macOS and Windows.
- Python 3.8+
- pip
- PyInstaller (
pip install pyinstaller)
# Run the build script
./build_macos.sh
# The app will be in: dist/Photo Size Reducer.app# After building the .app, create a DMG
hdiutil create -volname "Photo Size Reducer" \
-srcfolder "dist/Photo Size Reducer.app" \
-ov -format UDZO \
PhotoSizeReducer-macOS.dmgpyinstaller --clean \
--onefile \
--windowed \
--name "Photo Size Reducer" \
--osx-bundle-identifier "com.nsozturk.photosizereducer" \
photo_reducer.py# Run the build script
build_windows.bat
# The exe will be in: dist\PhotoSizeReducer.exepyinstaller --clean ^
--onefile ^
--windowed ^
--name "PhotoSizeReducer" ^
photo_reducer.py- Create or download a 1024x1024 PNG icon
- Convert to .icns:
mkdir icon.iconset sips -z 16 16 icon.png --out icon.iconset/icon_16x16.png sips -z 32 32 icon.png --out icon.iconset/icon_16x16@2x.png sips -z 32 32 icon.png --out icon.iconset/icon_32x32.png sips -z 64 64 icon.png --out icon.iconset/icon_32x32@2x.png sips -z 128 128 icon.png --out icon.iconset/icon_128x128.png sips -z 256 256 icon.png --out icon.iconset/icon_128x128@2x.png sips -z 256 256 icon.png --out icon.iconset/icon_256x256.png sips -z 512 512 icon.png --out icon.iconset/icon_256x256@2x.png sips -z 512 512 icon.png --out icon.iconset/icon_512x512.png sips -z 1024 1024 icon.png --out icon.iconset/icon_512x512@2x.png iconutil -c icns icon.iconset
- Create or download a 256x256 PNG icon
- Convert to .ico using an online tool or software
- Save as
icon.icoin the project root
Build on each platform:
- On macOS: Run
./build_macos.shto create the .app - On Windows: Run
build_windows.batto create the .exe
macOS:
# Create DMG (recommended)
hdiutil create -volname "Photo Size Reducer" \
-srcfolder "dist/Photo Size Reducer.app" \
-ov -format UDZO \
PhotoSizeReducer-v1.0.0-macOS.dmg
# OR create ZIP
cd dist
zip -r ../PhotoSizeReducer-v1.0.0-macOS.zip "Photo Size Reducer.app"
cd ..Windows:
# Create ZIP
cd dist
powershell Compress-Archive PhotoSizeReducer.exe ..\PhotoSizeReducer-v1.0.0-Windows.zip
cd ..- Go to your repository on GitHub
- Click "Releases" → "Create a new release"
- Tag version:
v1.0.0 - Release title:
Photo Size Reducer v1.0.0 - Description:
## What's New - Initial release - Drag & drop support - Batch processing - Live preview - Compression and resize options - Support for JPEG, PNG, WebP ## Downloads - **macOS**: Download the .dmg file - **Windows**: Download the .zip file and extract ## Installation **macOS**: Open the DMG and drag the app to Applications folder **Windows**: Extract the ZIP and run PhotoSizeReducer.exe
- Upload the built files:
PhotoSizeReducer-v1.0.0-macOS.dmg(or .zip)PhotoSizeReducer-v1.0.0-Windows.zip
- Click "Publish release"
Create .github/workflows/build.yml for automated builds on every release:
name: Build Executables
on:
release:
types: [created]
jobs:
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- run: pip install -r requirements.txt pyinstaller
- run: ./build_macos.sh
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dist/Photo Size Reducer.app
asset_name: PhotoSizeReducer-macOS.app
asset_content_type: application/zip
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- run: pip install -r requirements.txt pyinstaller
- run: build_windows.bat
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dist/PhotoSizeReducer.exe
asset_name: PhotoSizeReducer-Windows.exe
asset_content_type: application/octet-streamRemove the quarantine attribute:
xattr -cr "Photo Size Reducer.app"Some antivirus software may flag PyInstaller executables. This is a known issue. Users can:
- Add an exception for the file
- Download and run from source instead
If the built app crashes due to missing modules:
# Add hidden imports to the build command
pyinstaller --hidden-import=PIL._imagingtk ...To reduce executable size:
# Use UPX compression (install UPX first)
pyinstaller --upx-dir=/usr/local/bin ...
# Exclude unnecessary modules
pyinstaller --exclude-module matplotlib ...# Sign the app
codesign --deep --force --sign "Developer ID Application: Your Name" "dist/Photo Size Reducer.app"
# Verify
codesign --verify --deep --strict --verbose=2 "dist/Photo Size Reducer.app"Use a code signing certificate from a trusted CA.
Author: Enes Ozturk GitHub: @nsozturk