[BY TIMOTHY BOGDALA]

Creating Thumbnails For Justified Gallery With Bash

Published: February 25, 2014

Having just rebuilt my website from the ground up using Google’s Go, I’m now using a whole new set of tools to get things done. Previously I based my blog on Wordpress and I used NextGEN Gallery for my gallery needs. Now that I’m going light, I’m now using Jusitified Gallery combined with Magnific-popup.

For Justified to be able to do it’s thing and size the images to fit the page nicely, it needs a set of thumbnails of different max sizes. I wrote a quick bash script to generate these with GraphicsMagick’s convert utility.

#!/bin/bash

if [[ -d $1 ]]; then
    echo "$1 is a directory. pass in a file instead."
elif [[ -f $1 ]]; then
    ORIGFILE=$(echo $1 | sed 's/\.[^.]*$//')
    echo "Making thumbs for $ORIGFILE ..."
    
    gm convert -size 800x800 ${ORIGFILE}.jpg -resize 800x800 +profile "*" ${ORIGFILE}_c.jpg
    gm convert -size 640x640 ${ORIGFILE}.jpg -resize 640x640 +profile "*" ${ORIGFILE}_z.jpg
    gm convert -size 320x320 ${ORIGFILE}.jpg -resize 320x320 +profile "*" ${ORIGFILE}_n.jpg
    gm convert -size 240x240 ${ORIGFILE}.jpg -resize 240x240 +profile "*" ${ORIGFILE}_m.jpg
    gm convert -size 100x100 ${ORIGFILE}.jpg -resize 100x100 +profile "*" ${ORIGFILE}_t.jpg
else
    echo "Usage: $0 <filename>"
fi

The -resize flag keeps the aspect ratio intact, so that is the maximum allowable dimension for the image. The +profile flag should strip all of the extra data not needed.

To use it, run the script and pass it the name of the original image file. I opted not to use the 500px and 1024px thumbnails, so in my html I had to configure Justified with these options

$("#gallery").justifiedGallery({
    'sizeRangeSuffixes' : {
        'lt100':'_t', 
        'lt240':'_m', 
        'lt320':'_n', 
        'lt500':'_z', 
        'lt640':'_z', 
        'lt800':'_c',
        'lt1024':'_c'
    });

PThreads Win32 in Visual Studio 2012

Published: February 2, 2014

One popular option for portable multi-threading is using the POSIX threads  (pthreads) library. On Unix-like platforms like Linux this can be installed easily through a package manager. On Mac OS X you can use something like Homebrew to install it.

On Windows the situation is a little less clear. Most people appear to use the Win32 port found here. When you get the latest package, you’ll find that the project files are for a very old version of Visual Studio. The upgrade option gave me errors. Using git to grab the latest which had VS2012 solutions also did not compile correctly.

The solution was to actually RTFM found at ftp://sourceware.org/pub/pthreads-win32/dll-latest/README and use the command line tools to build. Open the Developer Command Prompt from the start menu, cd to the pthreads.2 source directory found in a package (like  ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip), and use one of the following commands:

nmake clean VCE (to build the MSVC dll with C++ exception handling)
nmake clean VSE (to build the MSVC dll with structured exception handling)
nmake clean VC (to build the MSVC dll with C cleanup code)
nmake clean VCE-inlined (to build the MSVC inlined dll with C++ exception handling)
nmake clean VSE-inlined (to build the MSVC inlined dll with structured exception handling)
nmake clean VC-inlined (to build the MSVC inlined dll with C cleanup code)
nmake clean VC-static (to build the MSVC static lib with C cleanup code)
nmake clean VCE-debug (to build the debug MSVC dll with C++ exception handling)
nmake clean VSE-debug (to build the debug MSVC dll with structured exception handling)
nmake clean VC-debug (to build the debug MSVC dll with C cleanup code)
nmake clean VCE-inlined-debug (to build the debug MSVC inlined dll with C++ exception handling)
nmake clean VSE-inlined-debug (to build the debug MSVC inlined dll with structured exception handling)
nmake clean VC-inlined-debug (to build the debug MSVC inlined dll with C cleanup code)
nmake clean VC-static-debug (to build the debug MSVC static lib with C cleanup code)

So a command like this will build the release version that doesn’t use exceptions:

nmake clean VC

After building the release version you can use VC-debug to build the debug copy of the DLL. Copy the .lib and the .dll files to a directory in your project, set the library and include paths and you’re good to go!

scheme wrappers for a 3d game engine

Published: January 10, 2013

Just made a commit to my game engine PortableGLUE that includes a sample of a 3d model viewer using the fledgling Gambit-C scheme bindings. I wrote a blog post about it over there.

A simple model viewer example written in scheme.

This is something that I’ve wanted to accomplish for a long time. If I had more spare time, I’d also start working on Haskell bindings. Sadly, I’m going to have to refocus my efforts on the software I’m trying to publish.

<- OLDER ENTRIES .|. NEWER ENTRIES ->