[HowTo] Automation – Photo resizing script

  • Prerequisites:
    • Mac Portshttps://www.macports.org/
      • Apple’s Command Line Developer Tools
      • type in the following command to get Apple’s Command Line Developer Tools installed:
xcode-select --install
  • If you get the following message about xcode-select command requiring command line developer tools, go ahead and install
  • Apple’s Xcode Developer Tools
xcodebuild -license
sudo port -v selfupdate
  • Now Mac Ports has been installed on your Mac
  • Go ahead and close your terminals and open a new terminal window
  • ImageMagick:
sudo port install perl5.34
sudo port install imagemagick
sudo port install p5.34-perlmagick
% sudo port install perl5.34
---> Computing dependencies for perl5.34
The following dependencies will be installed:
db48
gdbm
gettext-runtime
libiconv
ncurses
readline
Continue? [Y/n]: Y
.....
% sudo port install imagemagick
---> Computing dependencies for ImageMagick
The following dependencies will be installed:
aom
bash
brotli
bzip2
cairo
coreutils
dav1d
djvulibre
expat
fftw-3
fontconfig
freetype
gdk-pixbuf2
ghostscript
giflib
glib2
gmp
gobject-introspection
icu
imath
jasper
jbig2dec
jbigkit
kvazaar
lcms2
lerc
libde265
libdeflate
libedit
libelf
libffi
libgcc
libgcc14
libheif
libidn
libjpeg-turbo
libpaper
libpixman
libpng
libraw
libtool
libxml2
lz4
m4
mpdecimal
openexr
openh264
openjpeg
openssl
openssl3
pcre2
perl5
pkgconfig
py313-mako
py313-markdown
py313-markupsafe
py313-setuptools
python313
python3_select
python3_select-313
python_select
python_select-313
shared-mime-info
sqlite3
svt-av1
tiff
urw-fonts
webp
x265
xorg-libX11
xorg-libXau
xorg-libXdmcp
xorg-libXext
xorg-libXt
xorg-libice
xorg-libsm
xorg-libxcb
xorg-xcb-proto
xorg-xcb-util
xorg-xorgproto
xrender
xz
zlib
zstd
Continue? [Y/n]: Y
....
---> Some of the ports you installed have notes:
coreutils has the following notes:
The tools provided by GNU coreutils are prefixed with the character 'g' by
default to distinguish them from the BSD commands.
For example, cp becomes gcp and ls becomes gls.

If you want to use the GNU tools by default, add this directory to the front
of your PATH environment variable:
/opt/local/libexec/gnubin/
libheif has the following notes:
Support for rav1e now disabled by default; enable via +rav1e
libidn has the following notes:
GNU libidn2 is the successor of GNU libidn. It comes with IDNA 2008 and TR46
implementations and also provides a compatibility layer for GNU libidn.
python313 has the following notes:
To make this the default Python or Python 3 (i.e., the version run by the
'python' or 'python3' commands), run one or both of:

sudo port select --set python python313
sudo port select --set python3 python313
shared-mime-info has the following notes:
A startup item has been generated that will start shared-mime-info with
launchd, and will be enabled automatically on activation. Execute the
following command to manually _disable_ it:

sudo port unload shared-mime-info
  • Depends on which version of Python 3 gets installed/available, you may want to set the default version of Python by running the ‘select -set’ commands at the bottom of the install
sudo port install p5.34-perlmagick
sudo port install p5.34-image-exiftool
% sudo port install p5.34-image-exiftool
---> Computing dependencies for p5.34-image-exiftool
---> Fetching archive for p5.34-image-exiftool
---> Attempting to fetch p5.34-image-exiftool-13.300.0_0.darwin_any.noarch.tbz2 from https://packages.macports.org/p5.34-image-exiftool
---> Attempting to fetch p5.34-image-exiftool-13.300.0_0.darwin_any.noarch.tbz2.rmd160 from https://packages.macports.org/p5.34-image-exiftool
---> Installing p5.34-image-exiftool @13.300.0_0
---> Activating p5.34-image-exiftool @13.300.0_0
---> Cleaning p5.34-image-exiftool
---> Scanning binaries for linking errors
---> No broken files found.
---> No broken ports found.
sudo port install wget
% sudo port install wget
---> Computing dependencies for wget
The following dependencies will be installed:
curl-ca-bundle
gnutls
gsettings-desktop-schemas
libidn2
libproxy
libpsl
libtasn1
libunistring
libxslt
nettle
p11-kit
Continue? [Y/n]: Y
% cd ~/Downloads
% wget https://www.sentex.ca/~mwandel/jhead/os-x/jhead
--2025-05-26 15:24:31-- https://www.sentex.ca/~mwandel/jhead/os-x/jhead
Resolving www.sentex.ca (www.sentex.ca)... 64.7.148.55
Connecting to www.sentex.ca (www.sentex.ca)|64.7.148.55|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 72696 (71K)
Saving to: ‘jhead’

jhead 100%[===================>] 70.99K 291KB/s in 0.2s

2025-05-26 15:24:32 (291 KB/s) - ‘jhead’ saved [72696/72696]
% sudo cp ~/Downloads/jhead /opt/local/bin/
% sudo chmod +x /opt/local/bin/jhead
  • close all Terminal windows and restart a new one to test:
% cd ~/Pictures
% % ./scripts/raw2jpeg.pl -h
Unknown option: h
-F- Unknown option encountered.
-F- Availabel options : tn, bw, op, cc, SV, AV, SSP, title, desc, src, desc, move & debug
-F- -src : Location for Source imgs(jpeg)
-F- -dest : Location for Destination
-F- -SV : Generate SimpleView Web contents.
-F- -AV : Generate ActiveView Web contents.
-F- -SSP : Generate SlideShowPro Web contents.
-F- -3W : Triple Width 1800x600
-F- -title : Web Title for SV/AV/SSP.
-F- -desc : Web Description for SV/AV/SSP.
-F- -tn : Generate Thumbnail size.
-F- -bw : Generate Grayscale images(800x).
-F- -pr : Generate Polaroid images(800x).
-F- -op : Generate OilPaint images(800x).
-F- -cc : Generate Charcoal images(800x).
-F- -bdr : Generate Bordered/framed images(800x).
  • Sample runs:
  • Let’s assume that the photos are arranged in ~/Pictures folder with <date>_<title> and scripts are also in ~/Pictures folder as above
% cd ~/Pictures
% % ./scripts/raw2jpeg.pl -SSP -AV -SV -bw -src 20250525_Friday-Party/uncompressed -dest 20250525_Friday-Party -title 20250525_Friday-Party
  • (Here, you can use auto-completion by pressing <tab> key after 20250525…)

[Mac/OSX] iTunes/Mail Broken Korean Fix

Yet another better/easier method:

App Language Chooser

 

This should set the default language to Korean on iTunes only:

defaults write -app iTunes AppleLanguages "(ko)"

 

On OSX with English as the default language, Korean letters will be broken on the iTunes and Mail and here is how to fix that:

defaults write $(mdls -name kMDItemCFBundleIdentifier -raw /Applications/iTunes.app) AppleLanguages "(ko, en)"
defaults write $(mdls -name kMDItemCFBundleIdentifier -raw /Applications/Mail.app) AppleLanguages "(ko, en)"

How to show hidden files on OS X

Time to time, I want to see hidden files on OS X via Finder and here is what I find on the internet to make that happen:

To make it show:

defaults write com.apple.finder AppleShowAllFiles -boolean true
killall Finder

Back to default:

defaults delete com.apple.finder AppleShowAllFiles
killall Finder

Using Apple Bluetooth Keyboard on PCs

I got a few Apple Bluetooth Wireless Keyboard as gifts.  I admit it, they are nice….  I mean, they look great and the feel of the typing is also good… but my main laptop is not a Mac, it is a PC…. So I tried to use them with Windows systems…. what a pain!!!!!  I need “Del” key and “Insert” key…..  Type say that “Fn” key is my friend but they are wrong…. “AppleWirelessKeyboard” is my friend!!! http://uxsoft.cz/projects/awk Apple Bluetooth Keyboard

OSX – Perl CPAN Initialization

In order to install perl modules via CPAN, CPAN needs to be configured on OS X via the following command:

% sudo CPAN

within the cpan shell:

cpan> o conf prerequisites_policy follow
cpan> o conf make /usr/bin/make
cpan> o conf commit

> sudo port selfupdate
> sudo CPAN
cpan> upgrade CPAN
cpan> install Bundle::CPAN
cpan> upgrade
cpan> install YAML
cpan> install Text::xSV

http://beerpla.net/2007/10/12/cpan-the-perl-module-manager/

 

 

MacPorts – MustHave

Web Site: http://www.macports.org

OS X is an UNIX OS.  The Aqua GUI is nice an all but in order to get the full potential of OS X, you should know how to work with the Terminal(xterm) and scripts.  Other free *NIXes have developed a nice package system and it is MacPorts that does package managements on OS X.

Requirement:
You need Apple Xcode Development Tools.  Get it from AppStore(Link):
AppleStore-Xcode

It is free!!!  After it is installed, you need to accept Xcode EULA by either running xcode or entering the following command in the Terminal:

% xcodebuild -license

Go to Applications then double click on the Xcode so it gets installed on the system.

Xcode-Welcome

Now the Command Line Tools needs to be installed.  Go to Xcode->Preferences->Downloads:

Xcode-Pref-Downloads

Click on the “Install” button next the the Command Line Tools.

 

Now, MacPorts can be installed via .pkg/.dmg and the links are:
Mountain Lion: https://distfiles.macports.org/MacPorts/MacPorts-2.1.2-10.8-MountainLion.pkg
Lion: https://distfiles.macports.org/MacPorts/MacPorts-2.1.2-10.7-Lion.pkg
Snow Leopard: https://distfiles.macports.org/MacPorts/MacPorts-2.1.2-10.6-SnowLeopard.pkg
Leopard: https://distfiles.macports.org/MacPorts/MacPorts-2.1.2-10.5-Leopard.dmg

After downloading the .pkg/.dmg, simply double-click on it to get it installed.

Self update: in a Terminal type the following:

% sudo port -v selfupdate