Saturday, September 24, 2011

How to Quickly Rotate Several Image Files from Upside Down to Rightside Up in OSX


Not exactly the PHP-related post I expected to write next... Many people, Mac users included, won't need this post. That's okay, because it isn't for you.  It's for Mac newbies, a description which I apply to myself.

I'm using an extended keyboard, with the numeric keypad and inverted-T arrow keys.  I'll have to look at a regular keyboard and see what the equivalent keystrokes would be.

Someone scanned 40-something pages of a document and emailed the resulting jpeg image files to me.  They were all upside down.  Here's what I did to get them right-side up, fairly quickly - though still a manual process - on the Mac under OSX.


  1. Open a Finder window showing all the files in a list view. Get into list view by clicking the second icon from the left immediately above the area in which the files appear.
  2. Select all of the image files by clicking on the file at the top of the list, pressing the shift key and, holding it down, press the down arrow key until all filenames are highlighted.
  3. Command-O to open all of them at once in the Preview application.
  4. Hold down the Command key with your right thumb.
  5. With your left hand, press the "R" key twice, to rotate the image right, until it is vertical. Do NOT release the Command key with your right thumb.
  6. Press the "S" key with your left hand to save the image.
  7. Release the command key under your right thumb, and press the down arrow key.
  8. Repeat steps 4 through 7 until you've finished with all the images.


If this happens to you a lot, you could record this process and play it on another set of files using the built-in Automator Application.  That's for another day, though.

If you find this useful, or if you have suggestions for improvements to this process, let me know.

Thursday, March 31, 2011

Ideas of March, or Thank you, Mr. Shiflett.

We do need more blogging.  Tweets are fine for their intended purpose, but there is only so much idea one can squeeze into so little space.

I like blogs because of what I learn from them; they encourage me to stay current, they expose me to new thoughts and they help me stay connected with the community.

I like blogs precisely because they aren't real-time. They are the result of observation and reflection.  I get to read someone's more fully-developed thoughts, communicated in full sentences, with examples, and even paragraphs!  Blogging forces one to crystallize one's thoughts, and teaches us how to communicate more effectively.  True written communication is not dead.  Blogs make me think; I not only like that, I need it.

I like being able to go back to a blog post I've bookmarked as a reference, finding again something I needed once, and need again from time to time. In addition, I get to see how the concept develops over time, as commentors contribute their thoughts and opinions on the subject.

Blogs also inspire me to contribute some of what I may have learned along the way.  This is where I've fallen down, terribly, often believing that I really didn't have much to say that would be of use to others.

I see otherwise now.  I've been teaching novice programmers PHP and Zend Framework with Zend Technologies since autumn 2008.  I get asked a lot of questions about programming, code design, object-oriented development, and testing.  Most of my colleagues are advanced developers, and they often blog about advanced techniques, and although those techniques help make a developer's life easier, some of the people I encounter daily aren't quite ready to take advantage of particularly advanced development practices.

I pledge to blog more often, and help flatten out the learning curve for the newbies.  We were all newbies, once, and if we're committed to lifelong learning, and to keeping our skills current, we remain newbies, in at least one area, all the time.

See you briefly on Twitter with a #ideasofmarch tweet.

Zend Framework Autoloading - Finding Your Library Classes

Attention Zend Framework beginners.  Since today is the final day for me to get around to contributing - in some small way - to The Ideas of March, which encourages people to blog more often, I offer up the following.

If you find yourself using require_once statements in your Zend Framework applications in order for ZF to find your library classes, in spite of using Zend_Application - which you know establishes autoloading by default - then there is one simple thing you need to add to your application's config file, typically configs/application.ini, to fix the problem.  End your frustration, and read on.

Assuming a directory structure something like this (my "vendor prefix" of EAI stands for Everetts Associates, Inc.):
application/
data/
docs/
library/
        EAI/
            Mail.php
public/
scripts/
temp/
tests/

and a class named EAI_Mail in the Mail.php file, and assuming your library is on your include_path, all that is needed is a line like this in application.ini:

autoloaderNamespaces[] = "EAI_"

Zend Framework's autoloader is already configured to match class prefixes Zend_ and ZendX_.  What you're doing by adding the above line to the application's config file is register your library prefix/namespace with the autoloader.  The include_path was not your problem, the problem was that ZF wasn't acknowledging your class prefix.

Now you can strip out those require_once statements for a bit of a performance boost.

Happy coding.