Author: Drew (page 1 of 3)

Image Processing with GIMP Batch Mode on the Command Line

BAM! Another reason I love Linux and free and open source software. 

My phone becomes an invaluable tool when I begin working on a project, namely for its camera. I have an elaborate system set up where I snap photos, they save to my phone as well as upload to my cloud when I’m connected to WiFi. Once my task is done for the project and the files have automatically found their way to my server, I sort and catalogue the files into specific project folders. Sometimes, these folders full of photos need to make their way to this website.

On my LG, the camera is spectacular, so I don’t hesitate to use it to its full potential. Each photo can be upwards of 10 MB though, which doesn’t make for fast web browsing, especially if one is simply browsing on their tablet or phone. If someone’s browsing on their desktop, chances are their monitor is running 1920 x 1080 resolution, so the native 5312 x 2988 resolution my LG produces actually serves against me.

I use GIMP for all my simple manipulation of photos and images. It’s easy to open up a file and scale the resolution… but it becomes very, very time consuming and mind-numbing when it comes to manipulating a hundred or so photos. And that’s where the little known Batch Mode that’s built into it helps me big time in taking care of what should be a simple task. I just want to take a bunch of photos and make them all 1080p!

Here’s how I went about doing it.

Firstly, I visited GIMP’s webpage which does a basic job of introducing the capabilities and where to find the information one needs to use it.

Then I perused their example of processing several files, admiring what looked to be some LISP functions and formatting I’m familiar with from my old AutoCAD LISP programming days.

I had no interest in applying an Unsharp Mask filter to the photos, as shown in the example, but I was interested in the “gimp-image-scale” procedure found in the Procedure Browser found under the Help menu. All I had to do was figure out how to use the parts of the example I was interested in, do away with what I don’t want, and insert what I do want.

To cut to the chase though, here’s the script that will need to be saved to your ~/.gimp-2.8/scripts directory (being mindful of the version number, of course):

(define (batch-resize-to-1080 pattern)
 (let* ((filelist (cadr (file-glob pattern 1))))
   (while (not (null? filelist))
          (let* ((filename (car filelist))
                 (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
                 (drawable (car (gimp-image-get-active-layer image))))
            (gimp-image-scale image 1920 1080)
            (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
            (gimp-image-delete image))
           (set! filelist (cdr filelist)))))

Copy it, paste it into a text file, name it whatever you want. Just ensure it’s in GIMP’s script directory and it has the .scm file extension. Then in your terminal, navigate to the directory where you have copied your photos to manipulate (this script will overwrite your original files), and type out the following command:

gimp -i -b '(batch-resize-to-1080 "*.jpg")' -b '(gimp-quit 0)'

I’m not going to dig into how to interpret LISP (Lost In Silly Parenthesis), but I’ll try to dumb things down in a way that would allow the initiating scripter to take this example or GIMP’s example and understand what they can tweak and what they can’t tweak.

If it’s not immediately clear, it needs to be pointed out that all the 10 lines of code are called by that 1 line of code using “batch-resize-to-1080”. In the 10 lines of code, we’re essentially defining our own command that we can use within GIMP. So name this whatever you’d like, but just ensure it matches between the script and the command.

A big difference between this example and GIMP’s example, is the number of parameters/variables/arguments required to run the custom script. If you look back at GIMP’s example, you’ll see you have to type out the name of the custom script and then you have to specify a file extension, and a series of numbers. If it’s unclear why these need to be typed in, be sure to review “plug-in-unsharp-mask” in the Procedure Browser. These parameters are required to be entered on the command line so that this procedure can be used. But because I’m not interested in using this procedure, and I’m interested in using “gimp-image-scale” instead, I can leave out the “radius”, “amount”, and “threshold” parameters. 

The little difference between this example and GIMP’s example, is the one line in the rest of the script that gets replaced. Instead of:

(plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable radius amount threshold)

I simply want:

(gimp-image-scale image 1920 1080)

Now, if you wanted the ability to define the pixel width and height at the command line, you’d want to add the variable names here on this line as well as back up in that first line of the script where you define the procedure name and its parameters. For my purposes though, I know this is the resolution I want and I likely won’t have to change it, and I like the idea of typing less to run the script.

And that’s essentially it; just know the example may look intimidating with all the parenthesis and indents and such, but when it comes down to making a script of your own, know what little you have to change.

In my case, it was less than I thought I’d actually have to change. I wanted to batch convert all the images to 1920 x 1080 resolution, but given the fact that some photos are taken in portrait and others in landscape, I thought I’d have to gather this information within each file and enumerate the width and height based on its orientation. I’m glad I tested early! GIMP actually manages this automatically and no further scripting effort was required on my part.

To sum it up… figure out the name of the procedure(s) you want to use automatically across multiple files, determine the parameters those procedures require using the Procedure Browser, identify the little differences I noted above and modify them to suit your needs.

If all’s good, you’ll see “batch command executed successfully” in the terminal.

The Inside of Chiappa Firearms’ Double Badger

It becomes clear to me that I am an outlier when I look at used cars and start popping air filter boxes open in front of bystanding owners. The look on their silent faces usually says, “What are you doing?!”, “Don’t break it!”, and “Interesting, I’ve actually never looked in there before…” all at once.

I realize in that kind of moment that I have no problem venturing into the mechanics of something where many fear to tread. Or maybe it’s just that I’ve always been good with puzzles, which naturally, has prompted me to take things apart so that I have the pleasure of putting the pieces back together in the right place. Sometimes it gets me in trouble. Sometimes I can’t put things back together as easily as I took them apart. But no doubt, it always leaves me wondering if I can’t put my hands on something I’m interested in. Like, “lay awake” wondering…

Usually, this wonder can be quenched by reading a service manual, owner’s manual or an enthusiast’s forum to ply me with photos of the internal design and construction of something. With cars, it’s easy… but with firearms it’s difficult. By looking at the pieces that make up the assembly, I am able to gauge an understanding of quality. And for a couple years now, I’ve been laying awake wondering about the build quality of Chiappa Firearms’ Double Badger.

The first thing that pops up when you search online for a firearm by name is the manufacturer’s website, quickly followed by reviews. And consistently, I found article after article that fell short of my expectations. Reviewers love to repeat everything that’s said on the manufacturer’s website and what was told to them at the store. We’re lucky to find authors who at the very least take the firearms outside or to the range and punch a variety of rounds through the barrel. But my itch had yet to be scratched. Breaking the action open and looking down the barrels still leaves much to be desired for someone mechanically inclined.

So with a price tag worth gambling, I realized waiting around for another year wasn’t going to offer up any further insight into the Double Badger. I was only going to sleep contently when left to my own devices. I purchased the .410 and .22 WMR (Magnum) model and set out to determine its true value, by actually taking it apart, and put it out there for others to benefit from before I get to carried away with bashing all gun reviews in general.

But first, compliments to the ladies and gentlemen at Rocky Mountain Bushcraft, offering up the most detailed experience of the Double Badger in the real world across multiple articles. Aside from their work, I consistently found article after article that fell short of my expectations of a review. If it wasn’t for their long term update posted about 2 years after their initial impression, I would have remained on the fence and refrained from purchasing a Double Badger to call my own. Their articles accurately displayed the firearm and its features, no doubt put it to use and weighed their conclusion in the context of a specific use for the firearm, which goes beyond the commonly accepted review.

Please consider this not a review, but a visual insight into the design and build quality of the firearm. I put the Badger to use at the range, but believe enough people have done the same thing and don’t care much to repeat what’s been said. I was able to make what I believe are some important findings with a simple yet partial disassembly, which I feel is lacking in the world of reviewing. I don’t wish to become a reviewer, but do wish to see more disassembly in reviews as it offers up much more to say when speaking about cost and quality of a firearm. Hopefully that becomes clear to readers and reviewers alike.

20180228_140352

Picture 1 of 81

The .22 Winchester Magnum Rimfire cartridge and .410 bore 76mm (3") shotshell suited for Chiappa Firearms' Double Badger.

 

 

Recapitulation

This Double Badger does not exhibit quality out of the box. Neither was it actually ready to use out of the box; yours will likely require a basic disassembly to clean and lubricate. If you are looking to have a Double Badger which stands the test of time, expect to spend the time and money to correct for the mistakes Chiappa Firearms may make, and/or address some design flaws that the average consumer is blindly putting up with but will surely leave you with a deteriorating and unsafe firearm.

On the other hand, Chiappa’s done a fine balancing job of putting a beautiful, functional and inexpensive folding combination firearm in our hands, all things considered. Everything I’ve managed to negatively pick apart is manageable, and it’s up to you to determine whether these things reflect the cost. Nothing in my experience using or disassembling the Double Badger will prevent me from continuing to use it, and I hope to keep it indefinitely, so I will be putting the extra time and money into it. I speak from a desire to take things apart and fix them though.

What I Learned, Shooting at a Bird

I grew up fortunate enough to spend my summers out in the sticks. Up in the interior of British Columbia, it’s not hard to find rural areas where neighbours are kilometers apart. And somewhere around the age of 11, my father had myself and a friend sit down on a picnic bench and shoot past our outhouse up into the mountainside. I remember having him teach us the basics of gun safety and the rules one abides by while holding a firearm. More vividly though, I remember making a pop can dance on the dirt.

The year following that first target practice, my father passed away, but I continued taking the rifle out back in the same manner I would have if he were alive. That first summer without him, I remember setting up targets and shooting them alone on a clear, sunny afternoon. The only thing that took my attention off of the target happened to be a small bird, which stopped on a branch to my left to check me out and see what was making all the noise.

As it sat there on the branch, and I on the picnic bench; both of our necks craned, I got it in my mind that I was going to shoot it.

I had never shot a bird before, or anything other than paper and cans, in fact. I loaded a single .22 Long Rifle cartridge into the Cooey and was about to dismiss a rule that my father had laid down; I was about to point a firearm at something I was not prepared to destroy.

I understood that it wasn’t a target. It was a bird. But perhaps the fact that it was equidistant from the cans, to me, to the bird, it was easier to consider it a target. It was possible; I could shoot the cans within that distance, therefore I could shoot the bird within that distance. And it was dismissible; father may have laid down a rule, but he wasn’t around to enforce it. There’s no doubt I understood the value of a bird’s life at this time. We grew up with a number of pet birds in the house, one of which ended up being a part of the family for 15 years. They had names, we fed them, took care of them; loved them. But for some reason, none of that meaning transferred onto this wild, nameless bird in the forest, near my self holding a firearm.

I clasped the bolt forward and down, cocked the hammer back, took aim and fired. The bird, having no idea what was going on, startled at the report of the .22, jumped up from the branch, flashed its white belly toward me, found purchase in the air and darted away, up into the trees.

I ejected the empty brass, rested the Cooey on the picnic bench and felt my body flush with adrenaline. I ran up the hill until I was standing under the branch the bird was perched on. I fell to my knees, frantically running my shaking hands across the dirt, looking for feathers or blood or any sign that I shot the bird.  There were no feathers, there was no blood, and no dead bird in sight. I was hoping to find relief in discovering it was not dead, but fear and shame overwhelmed me. I knew I did something wrong; something I should not have done.

My eyes welled with tears and I found myself back in the cabin sobbing with my mother asking, “What’s wrong? What happened? Are you okay?” I couldn’t stomach to share what happened and instead hid behind what could only be seen as grief during that time. If I said anything, I probably told my mom how I missed my dad in that moment when I should have been telling her the truth: I broke a rule, mindlessly, with no good reason, and almost took a life in the process. I now understand that if I did in fact take that curious bird’s life, there would likely be a young bird out there much like me, trying to figure out how to navigate its world without guidance.

This is me writing these unspoken words, now two decades after the fact, so of course I’m arranging this in both a way that makes sense to me now and no doubt in the form of a story… but I’ve come to realize how important this experience is to me, especially as I work toward my first hunt.

Shooting at this bird is something I did without intention, and certainly wasn’t hunting – it would have been poaching. I didn’t consider the consequence of my action due to my lack of experience; this was a poor decision and a close call for me. I had the benefit of walking away from the experience, understanding what I did wrong and how to correct my decision-making so that my actions align with my intentions in the future. It may not seem like it was such high stakes at the time, but it certainly was for the bird. And what matters more are the real risks if I were to take this action now as an outdoorsman… Poor decisions made in the forest lead to squandering of our precious natural resources and likely restricted privileges for the community. 

I truly know how easy it is to make a poor decision, and I understand the difference between a hunter and someone who takes a life for some absent or confused reason. While my first answer to why I am choosing to hunt would be to provide food for me and those around me, I know a part of me also needs to relive that moment in nature where I may make the right decisions for the right reasons.

A Custom Soft Sauna

I’ve completed a prototype of a project that’s been on the go for a few months now. Essentially, it started with how many of my projects start; I looked at something that someone else was doing or has done and naively thought to myself, “I could do that…”

The idea of creating a semi-portable near infrared sauna out of canvas and wood is not a new or original idea; at least one company in the states offers up this idea commercially. The soft saunas I saw out there didn’t exactly meet all the requirements I think would be best suited for my lady and I though, so I took to outlining what would. I wanted something that was made out of natural and accessible materials, something that was large enough for my lady and I to use at the same time, remained semi-portable and that didn’t cost upwards of $4,000 CAD. 

The end result was something I could piece together for $700, discounting my time and energy designing and fabricating. And it’s got me thinking how much cheaper it could be if I came up with a simpler design and were sourcing the materials at higher quantities from their origin of manufacture… even with my time and energy.

I’m logging this project as something worth revisiting and toying with again in the near future. I really look forward to making another one.

20170924_131602

Picture 1 of 68

Working with some scrap waxed canvas, I exercised some free form stitching without measurement or any real plan. Before stepping into any sort of design or patternmaking, I took some 1" diameter wood dowels to determine how well I could interface the fabric and the wood.

The Making of the Character Series Shotgun Case

First things first, I began with measuring out the shotgun. In this case, I'm working with a 12 gauge Fox Savage Model B with a 30" barrel.

Picture 1 of 142

 

Mistakes Made and Lessons Learned:

  • Wool liner should have binding tape; no raw edges, at least around zipper opening
  • Zipper rivet missing; afraid of punch tool not being strong enough to punch through canvas and binding
  • Divider rivets should have been initially punched only on one side of the canvas
  • Leather stitching attaching canvas should have been brought closer to outside edge
  • Rivets should have been punched at each end of outside leather stitch
  • Reverse stitching should have been shorter so that they are hidden behind the binding tape
  • Binding tape needs cleaning up at zipper start
  • Binding tape needs more clearance from zipper teeth
  • Finishing stitch on binding tape needs to be closer to the binding tape edge to prevent wavering
  • Leather to be thinner on D-ring anchors, as it sticks out a little too much along spine
  • Four rivets should be used on each D-ring anchors
  • Stitching on leather required more consistent speed control; varied too much on one side

Successes:

  • Never stitched binding tape so uniformly, especially by hand
  • Hatch stitching looks incredibly straight, most likely due to time spent laying masking tape guides
  • Taking the time to grease the thread and needle for the leatherwork truly paid off
  • Time spent, using materials in stock, given market price payment made, allowed for a quality prototype to be made, sold and used for advertising; the sale of a next unit balances my total expenses on the first prototype and the next unit, bringing me up to par
Older posts

© 2018 Drew Merryman

Theme by Anders NorenUp ↑