Author Topic: The Contraption 26: Border Creator  (Read 6433 times)

Francois

  • Self-Coat
  • *****
  • Posts: 15,764
The Contraption 26: Border Creator
« on: September 25, 2020, 09:25:00 PM »
This is a project that was prompted by the one and only Damion Rice!
He wanted to add a white border to a ton of photos before sending them off to print. But only problem he had, he only has access to Photoshop Elements. That might not seem like much of an issue but Elements lacks the possibility to create action scripts. When you have to modify 50 to 100 images at a time, lets just say it ain't the best solution. So I made him a small action script to do the job. But I wasn't happy with what I had done. It's not that the script didn't work but the fact that I know how slow Photoshop is at running scripts. I wanted something faster, leaner, meaner.

So, I set out do do something I like: create a script that does one thing and one thing only at breakneck speed.
So, I settled on using a tried and true app for the image manipulation engine: ImageMagick.
ImageMagick  is an image manipulation program that is run from the command prompt. No interface, just commands you type in. This might seem like a bad thing at first sight, but when you want to script an operation, it's perfect!

So, I set out coding the script.
I first went through previous programs that I have been improving on for years in order to find some good building blocks. I also decided to jump at the opportunity to improve on some other scripts.

I needed to find a way to make the script work with both dropped folders and dropped files, something that isn't obvious. I also needed to avoid permanently modifying the original files. In the end I opted to copy the files to a temporary folder, modify them there and then move them to a new folder in the same directory as the original. A bit convoluted but a better solution... though I really could have speeded it up by copying the files directly to a new folder and working on them there... maybe for some other update.

The script also resizes the images to fit a 6 inch side in either portrait or landscape. It also lets you select the border width and it's color.

So, here is the link to the first version of this thing (version 0.1)
https://drive.google.com/file/d/183mn4Pc1NgRyov7KBBnWuLX1iKQv964a/view?usp=sharing

If you can think of ways to improve on it, let me know.
Francois

Film is the vinyl record of photography.

Adam Doe

  • Self-Coat
  • *****
  • Posts: 913
    • My Flickr Stream
Re: The Contraption 26: Border Creator
« Reply #1 on: September 26, 2020, 04:53:06 PM »
Is it an executable or does it need a runtime?

Francois

  • Self-Coat
  • *****
  • Posts: 15,764
Re: The Contraption 26: Border Creator
« Reply #2 on: September 26, 2020, 09:42:32 PM »
It's a script, so in a way it's executable but not really an executable in the way you think of (it's not a binary).
It's just a series of commands that call an external executable to do all the dirty work.
It uses ImageMagick (https://imagemagick.org/) which is an open source application that's been around for so long I can't remember. It actually started in the Linux/Unix world but can now be installed on anything.

If you download the script, you can open it directly in notepad (something you can't do with a regular binary executable) and see how it works.
I've included plenty of rem comments explaining stuff. The language used is pretty easy to follow and well documented.

I just do some clever scripting to get the final result.
I've worked a bit at beautifying the whole thing...
Francois

Film is the vinyl record of photography.

Francois

  • Self-Coat
  • *****
  • Posts: 15,764
Re: The Contraption 26: Border Creator
« Reply #3 on: September 26, 2020, 10:47:36 PM »
Francois

Film is the vinyl record of photography.

This-is-damion

  • Global Moderator
  • Self-Coat
  • *****
  • Posts: 1,349
    • Damion Rice
Re: The Contraption 26: Border Creator
« Reply #4 on: September 27, 2020, 02:02:03 PM »
how does it work though?   I open it and nothing happens....  can you pretend im a thicko  (not too far a stretch....) and explain in laymans terms how i use it?


Francois

  • Self-Coat
  • *****
  • Posts: 15,764
Re: The Contraption 26: Border Creator
« Reply #5 on: September 27, 2020, 02:57:45 PM »
You first install imagemagick. Then you just drag and drop either files or folders on the script icon.
That's it.

The script will ask you two questions and then copy the files to the temp folder, modify them there, and them move them to a new subfolder before cleaning the temp folder it created.

I've not extensively tested the script but it appears to work fine.
Francois

Film is the vinyl record of photography.

Bryan

  • Self-Coat
  • *****
  • Posts: 3,335
    • Flickr
Re: The Contraption 26: Border Creator
« Reply #6 on: September 27, 2020, 06:00:48 PM »
I use Gimp to edit my photos, I just discovered that it has a fairly simple batch editor similar to what you are doing with this.  I need to learn how to use it for tasks like flipping the image and invert.  It may help speed things up a little but the real time consuming tasks still need to be done manually. 

Francois

  • Self-Coat
  • *****
  • Posts: 15,764
Re: The Contraption 26: Border Creator
« Reply #7 on: September 27, 2020, 06:53:54 PM »
That's pretty much why I try and automate stuff.
But also it keeps things very consistent.

I believe that Gimp requires you to program in Python.
On the script I did, 99.9% of the script is just for handling the files and the GUI. The ImageMagick conversion script is just a single line...

Photoshop is nice when working with one image, but for batch jobs it can be unpredictable.

I just tested my script against another folder and it worked just as good. Completely non destructive.

Also, one of the big advantages of ImageMagick, being a command line app, is that there is no load time. It gets called and starts to work on the images pretty much instantly.
« Last Edit: September 27, 2020, 09:39:49 PM by Francois »
Francois

Film is the vinyl record of photography.

Francois

  • Self-Coat
  • *****
  • Posts: 15,764
Re: The Contraption 26: Border Creator
« Reply #8 on: September 28, 2020, 06:18:45 PM »
BIG UPDATE

I figured out that people who didn't have ImageMagick pre-installed had a problem with my detection routine, so I re-wrote it so that it would be a lot simpler and robust.
Now the script verifies the registry for ImageMagick instead of querying the program itself which caused a crash of the script if it wasn't there.

I also designed the script to run on Windows 10 and up. So if anybody uses an older version of the OS, please let me know so I can apply the proper corrections.
It can run on good old XP but I need to strip-put some of the custom coloring I put on it.

Here's the link https://drive.google.com/file/d/183mn4Pc1NgRyov7KBBnWuLX1iKQv964a/view?usp=sharing
Francois

Film is the vinyl record of photography.

This-is-damion

  • Global Moderator
  • Self-Coat
  • *****
  • Posts: 1,349
    • Damion Rice
Re: The Contraption 26: Border Creator
« Reply #9 on: September 29, 2020, 09:40:39 PM »
I can happily confirm this is genius!  saved me a load of time.


Thanks!!

Francois

  • Self-Coat
  • *****
  • Posts: 15,764
Re: The Contraption 26: Border Creator
« Reply #10 on: September 29, 2020, 10:42:19 PM »
I'm really happy to see you got it working!

I also hope you liked the chunky graphics :)

I usually don't mind spending 4 or 5 hours hacking at something if I know it's going to save me countless hours in the long run  8)
Francois

Film is the vinyl record of photography.