Jump to content

Picture Resize


 Share

Recommended Posts

I have been given a task of finding away to have a user right click on a directory and from a pull down it will give them an option to resize all photos. This I can add in the registry. My problem is how do I use AuotIt to read the current directory and then decrease the color depth and then copy all changed files into a new sub directory.

I was going to use Irfanview software to do the color depth changes since it can use command line scripting.

Thanks for any input and I will post mine if I figure it out before I have a reply.

-Chris

Link to comment
Share on other sites

have a user right click on a directory and from a pull down it will give them an option

Search for explorer integration add context menu item or the like..

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

Ok. I making some progress, but I have run into a snag.

I want to copy my images to a new Sub folder called reduced_images which is a sub folder in my working directory. The folder gets creaated but none of the files are copied. Can someone please show me where I screwed up.

Thanks

-Chris

;Make New Sub Reduced Dir

DirCreate(@WorkingDir & "\reduced_images")

;copy files to new Sub Directory

FileCopy(@WorkingDir & "*.*", @WorkingDir & "\reduced_images\*.*")

Link to comment
Share on other sites

Ok. I making some progress, but I have run into a snag.

FileCopy(@WorkingDir & "*.*", @WorkingDir & "\reduced_images\*.*")
    @WorkingDir & "\*.*"
Edited by flyingboz

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

FileCopy(@WorkingDir & "*.*", @WorkingDir & "\reduced_images\*.*")
    @WorkingDir & "\*.*"
I'll be interested to see your contextmenu code / process when you've got that working.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

I'll be interested to see your contextmenu code / process when you've got that working.

in scripts and scraps, i have something i wrote that lets you add/remove/editcontext menu actions for any file type. if you check my topics by clicking on my name, it should be pretty easy to spot.
Link to comment
Share on other sites

in scripts and scraps, i have something i wrote that lets you add/remove/editcontext menu actions for any file type. if you check my topics by clicking on my name, it should be pretty easy to spot.

The script camerons contextmenuworks by file extension, correct? He needs one that operates on the Folder, I believe.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

ah... one sec i'll find where it's at in the registry...

just add keys to:

HKEY_CLASSES_ROOT\Folder\shell\CommandNameYouWant\Command\

the default key is the one that will contain the command. for example:

RegWrite("HKEY_CLASSES_ROOT\Folder\shell\Resizeinator\Command\","","REG_EXPAND_SZ",'"c:\resizer\resizer.exe" %1')
Link to comment
Share on other sites

Its almost working. I made the registry changes for my script but it's not working on the directory I am clicking on. It seems to default to the home directory of the sub directory I am clicking on. Does that make any sense? :bashingHead:

---------------------------------------------------------------------------

Here is my Registry Change

[HKEY_CLASSES_ROOT\Folder\shell\Image Reducer]

@="Image Reducer"

[HKEY_CLASSES_ROOT\Folder\shell\Image Reducer\command]

@="c:\\windows\\system32\\reduce_image.exe" "%1"

-----------------------------------------------------------------------------

Here is my AU3 script

;Make New Sub Reduced Dir

Dircopy(@workingdir, @workingdir & "\reduced_images")

;Change working directory

FileChangeDir(@workingdir & "\reduced_images")

;Runs IV

RunWait(@ComSpec & " /c " & "i_view32.exe *.jpg /resize=(640,480) /bpp=4 /convert=*.jpg")

Edited by y2kcmoore
Link to comment
Share on other sites

---------------------------------------------------------------------------

Here is my Registry Change

[HKEY_CLASSES_ROOT\Folder\shell\Image Reducer]

@="Image Reducer"

[HKEY_CLASSES_ROOT\Folder\shell\Image Reducer\command]

@="c:\\windows\\system32\\reduce_image.exe"

this will just run the executable. it won't pass the name of the folder you selected.... if you're manually adding it to the registry, try using:

"c:\\windows\\system32\\reduce_image.exe" %1 (with the quotes)

if you're doing it programmatically, use the same thing, except surround it in single quotes, so that the double quotes are passed.

Link to comment
Share on other sites

Thanks to everyone that gave me guidance.

The program is working but not at 100%, but everyone loves it. The script will only work on directories called "Pictures" and it is written only for JPG files. For the script to work you must install Irfanview software which is free and easily scriptable and make sure it's installed in your %systemroot%\system32 directory.

http://www.irfanview.com/

Here are the instructions I gave my users.

You must name the directory where your pictures are stored pictures (without the quotes) for this program to work. Copy your JPG files to the "Pictures" Directory and "Right Click" on the "Pictures" Directory and in the pull down select "Image Reducer". It will create a sub-directory inside the pictures folder called reduced_pictures and it will copy your JPG files and reduce them to a more manageable size.

:Now for the script for image_reducer.exe

; ----------------------------------------------------------------------------

;

; AutoIt Version: 3.1.0

; Author: C.Moore

;

; Script Function:

; Reduce JPG Images to 640x480

; ----------------------------------------------------------------------------

; Script Start - Add your code below here

FileChangeDir(@workingdir & "\pictures")

;Make New Sub Reduced Dir

Dircopy(@workingdir, @workingdir & "\reduced_pictures")

;Change working directory

FileChangeDir(@workingdir & "\reduced_pictures")

;Runs IV

RunWait(@ComSpec & " /c " & "i_view32.exe *.jpg /resize=(640,480) /bpp=4 /convert=*.jpg")

;End of Script

--------------------------------------------------------------------------------------

To Intergrate for a right click pull down function

Win2K Registry Settings

--------------------------------------------------------

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\Image_Reducer]

@="Image Reducer"

[HKEY_CLASSES_ROOT\Folder\shell\Image_Reducer\command]

@="\"c:\\winnt\\system32\\reduce_image.exe\" \"%1\""

-------------------------------------------------------------

WinXP Registry Settings

-------------------------------------------------------------

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Folder\shell\Resize for PONTIS]

[HKEY_CLASSES_ROOT\Folder\shell\Image_Reducer]

@="Image Reducer"

[HKEY_CLASSES_ROOT\Folder\shell\Image_Reducer\command]

@="\"c:\\windows\\system32\\reduce_image.exe\" \"%1\""

--------------------------------------------------------------------

Thanks again for eveyone's guidance

-Chris

Link to comment
Share on other sites

Thanks to everyone that gave me guidance.

The program is working but not at 100%, but everyone loves it. The script will only work on directories called "Pictures"

FileChangeDir(@workingdir & "\pictures")

that line is where your issue is. that's why the directory has to be named pictures. now if you've added the %1 after the command in your context menu addition, then the folder name being right clicked on is actually being passed to the script, and you can use that to go to the right directory as so:

If $CmdLine[0] Then
    FileChangeDir($CmdLine[1])
Else
    FileChangeDir(@workingdir & "\pictures")
EndIf

the first line checks to see if any parameters were passed to the script, if yes, that would be the directory right clicked on. if not, then it will still default to the path you had previously.

Link to comment
Share on other sites

resize all photos.

If you are using WinXP and don't really need the color reduction, you could use the Windows XP PowerToy called ResizePhotos...
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...