Resizing optimized animated GIFs in Photoshop

In a previous post I had some trouble getting Photoshop to save animated GIFs using “combined” frames. This stemmed from wanting to resize some existing GIFs I had made using gifcam. Gifcam can optimize the GIF by making the parts of the images that don’t change transparent and then relying on the combine method for the animation. For whatever reason Photoshop wasn’t automatically using the do not dispose setting for the animation. This means that the partially transparent frames would be shown by themselves and any transparent area would show through to the background. It has sort of a ghosting affect, it looks like this:
gif_non_dispose

Even after figuring out the dispose feature, I ran into another issue. The resampling that Photoshop does during resizing breaks the existing optimization done by Gifcam. Just a tiny change in the edge of the transparent areas used for compression can do this:
resize_no_dispose

Normally you want that kind of resampling as it leads to a nicer looking image. To preserve the optimization we want to use a “rougher” resampling algorithm. If you switch the resampling algorithm to Nearest Neighbor you’ll get a much nicer looking animation:
animation_nearest_neighbor

In the Save For Web dialog the resampling algorithm is labeled as “Quality”.
resampling_quality

You can see the difference if you stack two transparent frames on top of each other. Notice the weird square edge lines that aren’t in the upper (nearest neighbor) image.
resize_compression_compare

You can mess around with this to get some cool glitch effects though.
damaged-cyborg-head_glitch

Saving an animated GIF in Photoshop with “combine” instead of “replace” frames

The GIF format can use two methods to display the frames in an animation. The “replace” method simply replaces the current frame with the next one. The “combine” method merges the next frame onto the current one, so transparent areas will show through. This article has a good explanation of the difference (although it’s for GIMP). I wanted to save a GIF from Photoshop with the combine method, but could not figure out where that setting was.

After some thorough googling I stumbled on this article which explains how to do it. In Photoshop it’s called “dispose” or “do not dispose”. To get to it you need to open the timeline window (Window – Timeline). Then right clicking on any frame brings up a context menu where you can choose between the two methods.

photoshop_timeline_dispose

Installing custom Plex plugins on a Drobo 5N

I recently wanted to install a 3rd party plugin on Plex on my Drobo 5N. I couldn’t find any documentation on how to do this complete process so I thought I’d document it here.

Currently there’s no official plugin for watching twitch.tv via Plex. There is 3rd party plugin someone created available on github, https://github.com/pejoo/Twitch.tv-Plex-Plugin. The instructions say to put this in the Plex Media Server’s plugins folder, but how do we access that when it’s on the Drobo? Here’s the steps I followed to install a custom plugin, specifically the twitch.tv plugin.

First we need to access the drobo apps share which is hidden by default. To find it you need to connect directly to the Drobo file share with the IP address. You can do this on windows with \\ or on Mac with smb://. For more info see this article: http://support.drobo.com/app/answers/detail/a_id/464

Now download the twitch.tv plugin from github: https://github.com/pejoo/Twitch.tv-Plex-Plugin

Extract the zip file and copy the Twitch.tv.bundle folder to DroboApps\plex\Library\Plex Media Server\Plug-ins

You should now see the Twitch.tv channel in Plex.

You may have to install a fix if the Twitch.tv plugin isn’t working, see https://github.com/pencil/Fix-Twitch.tv-Plex-Plugin

Note that you cannot view Twitch.tv streams in the Plex web player due to cross domain issues. You will get the error “Cannot load M3U8: crossdomain access denied”. See https://github.com/pejoo/Twitch.tv-Plex-Plugin/issues/9 for more details.

Bug in CakePHP Containable Behavior, Related Records not Being Returned When Parent Contains a Single Field

I just stumbled on a bug in CakePHP that prevents related child records from being returned when only selecting a single field from the parent. It looks something like this:

$this->Model->find('all', array(
  'contain' => array(
    'Parent' => array(
      'fields' => array('id', 'type'),
      'Child' => array(
        'fields' => array('id', 'type')
      )
    )
  )
);
// Returns as expected
//array(
//  'Model' => array(...),
//  'Parent' => array(
//    'id' => '',
//    'type' => '',
//    'Child' => array(
//      array(
//        'id' => '',
//        'type' => ''
//      ),
//      ...
//    )
//  )
//)

Now if we modify the contain for Parent to only return one field we lose all Child records:

$this->Model->find('all', array(
  'contain' => array(
    'Parent' => array(
      'fields' => array('id'),
      'Child' => array(
        'fields' => array('id', 'type')
      )
    )
  )
);
// Returns no Child records
//array(
//  'Model' => array(...),
//  'Parent' => array(
//    'id' => '',
//    'type' => '',
//  )
//)

This is due to a bug in Model/DataSource/DboSource.php in the _mergeAssociation method. On line 1401 it checks count($merge[0][$association]) > 1 before it will merge the records. Since Parent only has one field, ‘id’, it does not do the merge. This has been corrected in CakePHP 2.4.2 to !empty() instead of count() > 1.

This has been fixed in the CakePHP master branch with this commit: https://github.com/cakephp/cakephp/commit/940a51b5faa0b88fa5334764c19f93fe8364ef30

Logitech mouse freezing USB when switching applications in mac os x

I was having a mysterious problem with my USB inputs freezing on my mac after upgrading to Mavericks. The problem happened intermittently and would freeze all USB inputs for about 10 seconds. The rest of the computer would perform normally. After some troubleshooting I finally traced this down to the Logitech Control Center and application specific configuration for my mouse. It would freeze when switching to the application I had custom settings for, most consistently when using the cmd+tab shortcut. Removing the custom settings would no longer cause USB to stop working when switching to the application.

After some searching I was able to find a post on the Logitech forums about this issue. Other people are having the same issue and it looks like they need to update their drivers for Mavericks. I tried installing the latest version of Control Center (3.8) and the problem still exists.

As an alternative to Control Center you can use USB Overdrive which allows for application specific configuration. Or you can simply remove your application specific settings until Logitech releases a fix for Control Center.

Magento – Link to page through WYSIWYG editor

For Magento 1.4.1.1.

It’s not obvious how to link to a page through the WYSIWYG editor. There doesn’t appear to be any valid documentation on it in the Magento website either. Thankfully I found this post: http://screencastworld.com/2010/03/magento/magento_tips_tricks_and_hacks/magento-tips-tricks-and-hacks-4-how-to-link-pages-using-store-url-short-code

Basically {{store url=”page-slug”}} will be replaced by Magento as if you called $this->getUrl(“page-slug”). It’s easiest to just swap to HTML edit mode and insert that code into the href manually.

Loading app models inside a plugin controller in CakePHP

I recently ran into a problem while writing a plugin in CakePHP. I wanted to do some authentication with one of the models in my app. I added this in the beforeFilter of my AppController. In there I was using $this->loadModel to load the model on the fly. This works fine inside the app. However, as soon as you move to a plugin things break down. It will try to load the model inside your plugin. Since that model doesn’t exist in the plugin, it will fail. You can specify a plugin in the loadModel call, like ‘Plugin.Model’, but you can’t specify no plugin. The way to get it to load correctly is the $uses variable. That will load the correct model when initializing the controller. Then you can use it as normal with $this->Model. This has the side effect of always loading the model on every controller. In my case that was perfectly fine since its used for auth on all actions. I can’t see any viable way to use loadModel to load a model outside of your plugin.