Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

2013-07-14

How To Programmatically Batch Resize A Folder Of Images

(This post gives a walkthrough on how to automatically resize a bunch of pictures at once. I provide four different ways to do the resizing, in order of least optimal to most optimal IMO. There may be more ways for programmatically resizing, but I'll most likely be using the fourth method below all of the time.)

1. ImageMagick
2. IrfanView
    2.1. Benefits
    2.2. Limitations
    2.3. Walkthrough
3. Photoshop's Automate Batch
    3.1. Benefits
    3.2. Limitations
    3.3. Walkthrough
4. Photoshop's Scripts Image Processor
    4.1. Benefits
    4.2. Limitations
    4.3. Walkthrough

--

1. ImageMagick: Allows you to run image processing in a Windows command windows. So, you must be comfortable creating BAT (batch) files. I did not use this method, but here's the documentation for batch resizing this way: http://www.imagemagick.org/Usage/windows/

FOR %a in (*.jpg) DO convert %a -resize 50% small_%a
ImageMagick Example

2. IrfanView: When I tried this method, I got the feeling this tool was very old, but it still seems to be regularly updated. Also, IrfanView has many image manipulation features available for it. Many of them seem useful, but this time I was only interested in the resize feature.
2.1. Benefits: Very lightweight program at 2MB.
2.2. Limitations: When I tried to batch resize, each of the images lost their alpha transparencies, and the backgrounds all turned black.
2.3. Walkthrough: Drag a selection of images into the screen, then in the menu bar, choose Image-->Resize/Resample
IrfanView: Program when opened

IrfanView: Menu bar --> Image --> Resize/Resample

3. Photoshop's Scripts Image Processor:
3.1. Benefits: Quick to being resizing without having to setup anything else.
3.2. Limitations: Only resizes to JPG, PSD, or TIFF files. There was no option to save as PNG, which is what I needed.
3.2. Walkthrough: Menu bar --> File --> Scripts --> Image Processor. Then the window that pops up allows you to choose the folder of images you want to manipulate and where to save them.
Photoshop's Scripts Image Processor

4. Photoshop's Automate Batch: Basically, with this method, you change one image whatever way you want to, then record those steps, then you are able to perform all of those steps for a folder of images.
4.1. Benefits: Very versatile! The recorded actions you create will always be available in the future, and easy to manipulate for future projects.
4.2. Limitations: Just requires a little more setup before starting the batch image process.
4.3. Walkthrough:
Step 1. Open Action Window.
Photoshop: Open Action Window

Step 2. Create New Action. Before you can record some actions, you must have an image open. It doesn't matter if it is just a new blank image, or one you would eventually edit anyways. One other useful feature is the ability to stop and record actions at any time.
Photoshop: Create New Action
Photoshop: Saved New Action. List of available actions.

Step 3. Open Batch Window.
Photoshop: Open Batch Window

Step 4. Setup and Start Batch Command. In the first section (Play), choose the action you would like to perform to all your images that you will choose in the second section (Source). In the third section (Destination), you can either replace all of the images or save the manipulated images in a new folder. After all that, choose the "OK" button located at the top right.
Photoshop: Setup Batch Command

Feel free to post any questions or comments about programmatically resizing many images.
~ Simply Advanced ~



2012-12-18

How to Create a Hotkey to Double Click Using AutoHotkey

Just created a hotkey to double-click so that I don't have to use the mouse! It is very much worth it and will speed up coding. There are other areas that I will be more productive in also. Just can't think of them right now.

I used an awesome program called AutoHotkey to achieve this and many other create keyboarding shortcuts/hotkeys/scripts. The following code basically says, "if ctrl is pressed twice consecutively in less than 500ms, then click two times at the caret position."


Ctrl::
    If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 500) {
MouseGetPos X,Y
Send {Click  %A_CaretX%,%A_CaretY% 2} ; Moves the cursor
MouseMove (X),(Y) ; Moves back the cursor
    }
Return



  • Instead of using "%A_CaretX%,%A_CaretY%", it is possible to hardcode an x and y value to click on.
  • If you remove the line starting with MouseMove, then the cursor will move to the position the caret is at.


Let me know if this helps. =]

Disclaimer: I have not done an extensive test on all programs to see if this works. But, I know that it works in Notepad++, Eclipse, Notepad, and MS Word 2010. While typing this, the hotkey seems to return (aka double click) the top-left corner.

~ Simply Advanced ~