Saving GIF from DSLR Remote Pro with and without overley, two folders

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
production
Posts: 6
Joined: 2015-08-19T03:02:22-07:00
Authentication code: 1151

Saving GIF from DSLR Remote Pro with and without overley, two folders

Post by production »

Hi everyone!

I'm trying to make a script working so it saves gif with and without overlay when using Dslr Remote Pro.

Is there any way to save two copies of gif in a separate folders?

Many thanks!
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Saving GIF from DSLR Remote Pro with and without overley, two folders

Post by glennrp »

It might be possible by using the -write option. But I'd handle that in the script,
not in ImageMagick.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Saving GIF from DSLR Remote Pro with and without overley, two folders

Post by snibgo »

In general, an IM convert command can create multiple outputs. I always use "+write", not "-write".
snibgo's IM pages: im.snibgo.com
production
Posts: 6
Joined: 2015-08-19T03:02:22-07:00
Authentication code: 1151

Re: Saving GIF from DSLR Remote Pro with and without overley, two folders

Post by production »

I'm new with all this codes, understand most of it but could you tell me where should I paste it and what goes next after +write , -write ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Saving GIF from DSLR Remote Pro with and without overley, two folders

Post by snibgo »

Include it at the appropriate place in the convert command. After "+write", put the filename, with directory. See http://www.imagemagick.org/script/comma ... .php#write

If you paste the current command here, perhaps we can be more helpful. I know nothing about Dslr Remote Pro.
snibgo's IM pages: im.snibgo.com
production
Posts: 6
Joined: 2015-08-19T03:02:22-07:00
Authentication code: 1151

Re: Saving GIF from DSLR Remote Pro with and without overley, two folders

Post by production »

Code: Select all

;-----------------------------------------------------------------------
; AutoHotkey script to create an animated GIF from photobooth photos.
;
; Usage: Double click on this script to install it (this updates the PhotoboothStatusCmdXML
; setting in the Windows registry). Double click on the script again if you wish to uninstall it.
; Once installed run the photobooth software as normal and the script will be run automtically
; and will save the animated GIFs in a subfolder named GIF.
; Edit the resizeWidth, titleDelay and imageDelay settings below to configure the way the animated
; GIF is created.
; A title screen can be displayed (after the photos) by saving a file named GIF_title.jpg in the
; photobooth images folder. Please note the GIF_title.jpg image must have the same aspect ratio as
; the photos otherwise you may see parts of the last photo when the title screen is displayed.
; An optional overlay can be added to each photo by saving a file named GIF_overlay_1.png,
; GIF_overlay_2.png, GIF_overlay_3.png etc. in the photobooth images folder. If the numbered file
; isn't found the script will look for GIF_overlay.png instead.
;
; AutoHotKey is free and can be downloaded from:
; http://www.autohotkey.com
;
; This script comes with no warranty or support whatsoever and may
; be freely copied or modified as required.
;
; Written by Chris Breeze, www.breezesys.com
; 20131019: Updated to handle pathnames containing spaces
;-----------------------------------------------------------------------
#SingleInstance,force
#NoEnv
SetWorkingDir %A_ScriptDir%

; resize photos to this width (in pixels)
resizeWidth := 600

; how long to display title screen (in 1/100 sec)
titleDelay := 200

; how long to display each photo (in 1/100 sec)
imageDelay := 20

; Subfolder name where GIF is saved
outputDir := "GIF"

IfNotExist, %1%
{
	; no file passed via command line: install or uninstall the script
	install("DSLRRemotePro")
	;install("NKRemote")
	;install("PSRemote")
	;install("WebcamPhotobooth")
	exitapp
}

; Extract filename and directory from XML pathname
dir = %1%
RegExMatch(dir, "([^\\]+)$", filename) 
RegExMatch(dir, "(.*)\\", dir) 

SetWorkingDir %dir%
FileCreateDir %outputDir%

; read info from XML file
FileRead, Contents, %1%
RegExMatch(Contents, "<date>(.*)</date>", date_taken) 
RegExMatch(Contents, "<time>(.*)</time>", time_taken) 
RegExMatch(Contents, "<prints>(.*)</prints>", prints) 
RegExMatch(Contents, "<user_data>(.*)</user_data>", email) 
RegExMatch(Contents, "<user_data2>(.*)</user_data2>", name) 
RegExMatch(Contents, "<bw_mode>(.*)</bw_mode>", bw) 
RegExMatch(Contents, "<photobooth_images_folder>(.*)</photobooth_images_folder>", photoboothFolder) 

; Look for title page named GIF_title.jpg or title.jpg
title = %photoboothFolder1%\GIF_title.jpg
IfNotExist,%title%
{
	title = %photoboothFolder1%\title.jpg
}

while 1
{
	pattern = <photo image="%A_Index%">(.*)</photo>
	if RegExMatch(Contents, pattern, photo) 
	{
		; check whether we should use the greenscreened copy of the photo
		ifExist,greenscreen\%photo1%
		{
			photo1 = greenscreen\%photo1%
		}

		; look for overlay for this image (e.g. GIF_overlay_1.png) else GIF_overlay.png
		overlay = %photoboothFolder1%\GIF_overlay_%A_Index%.png
		IfNotExist,%overlay%
		{
			overlay = %photoboothFolder1%\GIF_overlay.png
		}
		IfExist,%overlay%
		{
			images = %images% ( "%photo1%" "%overlay%" -resize %resizeWidth% -flatten )
		}
		else
		{
			images = %images% "%photo1%"
		}
	}
	else
	{
		break
	}
}

; construct the ImageMagick convert command
cmd = "%A_ScriptDir%\convert.exe"

; loop forever and add the photos
cmd = %cmd% -loop 0 -delay %imageDelay% %images%

; convert to B&W if bw_mode=1
if (bw1 = 1)
{
	cmd = %cmd% -grayscale Rec601Luma
}

; add title screen if defined
ifExist, %title%
{
	cmd = %cmd% -delay %titleDelay% "%title%"
}

; resize images and save as a GIF
output := SubStr(filename,1,-4)
cmd = %cmd% -resize %resizeWidth% -rotate 270 "%outputDir%\%output%.gif"

; run the command
run %cmd%, %dir%, Hide

exitapp

Install(Product)
{
	; Check product name
	if (Product = "DSLRRemotePro" or Product = "NKRemote")
	{
		Key = Software\BreezeSystems\%Product%\100
	}
	else if (Product = "WebcamPhotobooth")
	{
		Key = Software\BreezeSystems\%Product%\101
	}
	else if (Product = "PSRemote")
	{
		Key = Software\BreezeSystems\%Product%\102
	}
	else
	{
		MsgBox, Product needs to be set to DSLRemotePro, NKRemote, WebcamPhotobooth or PSRemote`nProduct=%Product%
		exit
	}

	; Check whether script is already installed
	RegRead, enabled, HKEY_CURRENT_USER, %Key%, PhotoboothStatusCmdEnable
	RegRead, cmd, HKEY_CURRENT_USER, %Key%, PhotoboothStatusCmdXML
	newCmd = "%A_AhkPath%" "%A_ScriptFullPath%"
	if (cmd = newCmd and enabled = 1)
	{
		MsgBox 4, %A_ScriptName%, The %A_ScriptName% command is already enabled for %Product%.`n`nDo you wish to disable it?
		IfMsgBox Yes
		{
			RegDelete, HKEY_CURRENT_USER, %Key%, PhotoboothStatusCmdXML
		}
		exit
	}

	MsgBox 4, %A_ScriptName%, The %A_ScriptName% command is not enabled for %Product%.`n`nDo you wish to enable it?
	IfMsgBox Yes
	{
		; Install registry settings for the script
		RegWrite, REG_DWORD, HKEY_CURRENT_USER, %Key%, PhotoboothStatusCmdEnable, 1
		if ErrorLevel
		{
			MsgBox, Error writing PhotoboothStatusCmdEnable to Windows registry
			exit
		}
		RegWrite, REG_SZ, HKEY_CURRENT_USER, %Key%, PhotoboothStatusCmdXML, %newCmd%
		if ErrorLevel
		{
			MsgBox, Error writing PhotoboothStatusCmdXML to Windows registry
			exit
		}
		RegWrite, REG_DWORD, HKEY_CURRENT_USER, %Key%, PhotoboothSuppressXml, 0
		if ErrorLevel
		{
			MsgBox, Error writing PhotoboothSuppressXml to Windows registry
			exit
		}

		MsgBox %A_ScriptName% enabled for %Product%.`nSettings copied to the following Windows registry key: HKEY_CURRENT_USER\%Key%`n`nPhotoboothSuppressXml=0`nPhotoboothStatusCmdEnable=1`nPhotoboothStatusCmdXML=%newCmd%
		exit
	}
}

production
Posts: 6
Joined: 2015-08-19T03:02:22-07:00
Authentication code: 1151

Re: Saving GIF from DSLR Remote Pro with and without overley, two folders

Post by production »

You can run this script only once at the time as far as I know. How it works is, Dslr Remote Pro takes 4 photos and saved them in a folder. Then script takes last 4 photos and creates a animated gif of them. You can use GIF_overlay.png files to make overlay for them and here comes my problem. I want them to be saved with and without overlay. Perfect will be to have them in a separate folders. Any idea how to use overlay once, save and then don't use it and save again? Maaaany many thanks for your help!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Saving GIF from DSLR Remote Pro with and without overley, two folders

Post by snibgo »

The command that will be executed (cmd) will be something like:

Code: Select all

"%A_ScriptDir%\convert.exe"
-loop 0 -delay %imageDelay% %images%
-grayscale Rec601Luma
-delay %titleDelay% "%title%"
-resize %resizeWidth% -rotate 270 "%outputDir%\%output%.gif"
Where %images% is one or multiple occurrences, each one being either:

Code: Select all

( "%photo1%" "%overlay%" -resize %resizeWidth% -flatten )
or

Code: Select all

"%photo1%"
You want to change this, so it works as it does now, plus it makes a second output gif in a different directory, this one with no overlays? So it just uses "%photo1%" for each image? Is that correct?

If so, then forget what I said about "+write". It doesn't apply here. The easiest solution would be to build a second command, from a second set of images. After the lines:

Code: Select all

      IfExist,%overlay%
      {
         images = %images% ( "%photo1%" "%overlay%" -resize %resizeWidth% -flatten )
      }
      else
      {
         images = %images% "%photo1%"
      }
... insert:

Code: Select all

      images2 = %images2% "%photo1%"
For every line that contains "cmd", add another for "cmd2", but use "images2" instead of "images". So you will have two "run" commands.

You will also need "outputDir2".
snibgo's IM pages: im.snibgo.com
production
Posts: 6
Joined: 2015-08-19T03:02:22-07:00
Authentication code: 1151

Re: Saving GIF from DSLR Remote Pro with and without overley, two folders

Post by production »

thanks a lot it works perfectly!

only problem is that after the whole script running it leaves script windows open, it's not hiding them.

There's a line with Hide command but after adding second "cmd2" it shows as an error

any idea?

Many thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Saving GIF from DSLR Remote Pro with and without overley, two folders

Post by snibgo »

Sorry, I know nothing about Dslr Remote Pro. From your script, it seems that you can MsgBox cmd and cmd2, to show them on the screen. If an error is occurring, I suggest you copy-paste cmd, cmd2 and any error message here. If the problem is in the syntax of the ImageMagick command, I may be able to spot it.
snibgo's IM pages: im.snibgo.com
production
Posts: 6
Joined: 2015-08-19T03:02:22-07:00
Authentication code: 1151

Re: Saving GIF from DSLR Remote Pro with and without overley, two folders

Post by production »

Code: Select all

; run the command
run %cmd%, %dir%, 

run %cmd2%, %dir2% Hide

exitapp
This part "Hide" is making problem. It also keeps script window open after running it and because I'm using it with dslr remote pro in a full screen mode, after the whole process on a "ready" screen I'v got this script window on which is not what I want, any chance to minimize it or something like this? Running in a background or so?
Post Reply