Hi there.
I have a problem with one of my scripts (recorded macro)...
It is running perfect on single image, but when try to run it in batch mode, it fails...
Basically, in the script there is an operation where i copy a layer and paste it as new image. Then there is something processed on the new image, the result is copyed and pasted back to the original... then the script continues on the original by rearranging layer...
The failure happens when the script executes the rearrangement of layer, because (only in batch mode) it executes it on wrong document...
(it seems to me the script steps are running quicker than corel can switch between documents...)
I had read about "Inserting wait period" into the script, but cant find anywhere how to do it...
Anyone knows???
Or has anyone any idea how to solve this?
Thanks
Script OK on single image, but fails in BATCH mode...
Moderator: Kathy_9
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
Re: Script OK on single image, but fails in BATCH mode...
Can you share the script here?
I've never done a batch with "paste as new image" before. It's entirely possible the issue has to do not with execution timing but the actions themselves not being intended for use in batch scripting. Seeing all of the steps should help us find the problem and offer solutions.
I've never done a batch with "paste as new image" before. It's entirely possible the issue has to do not with execution timing but the actions themselves not being intended for use in batch scripting. Seeing all of the steps should help us find the problem and offer solutions.
https://levifiction.wordpress.com/
-
JoeB
- Posts: 2778
- Joined: Fri Mar 28, 2008 10:04 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: LENOVO 4524PE4 ThinkCentre M91p
- processor: 3.10 gigahertz Intel Quad Core i5-2400
- ram: 8 GB
- Hard_Drive_Capacity: 4.6 TB
- Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
- Location: Canada
Re: Script OK on single image, but fails in BATCH mode...
is there some reason you are copying a layer and pasting as new image to do some processing of that layer and then subsequently putting the processed image back into the original as a layer? Why can't you just do the processing on that layer while it's still a layer in the original image?
Regards,
JoeB
Using PSP 2019 64bit
JoeB
Using PSP 2019 64bit
Re: Script OK on single image, but fails in BATCH mode...
Hi, thank you for your time.
I do not want to make my script public... there is the specific feeling of my images encoded in that procedure...
But i found the problem and solved a part of it... and an other part emerged then...
The problem was, that script in batch mode is supposed to run in background, without actually opening the document...
But when copying a layer from the image and pasting it as a new image, there the script opens a real document...
So the first steps were running on one image and when the new image emerged, all other steps was running on that really opened document...
Now, i solved this, by adding one more copy and paste cycle just on the beginning of the script, so that the image is opened as document from the beginning
But then an other problem emerged - when the script is finished, there is an opened document left...
And with each image in the batch one more...
And after a while there is a warning message (opening 10 and more documents can decrease the performance...) and with this warning the batch is interrupted...
I had try to put a close document command on the beginning of the script, but wasnt able to work it out
It finished with error (no document to close) or with no effect...
So im not able to run that script on batch longer than 10 files...
I do not want to make my script public... there is the specific feeling of my images encoded in that procedure...
But i found the problem and solved a part of it... and an other part emerged then...
The problem was, that script in batch mode is supposed to run in background, without actually opening the document...
But when copying a layer from the image and pasting it as a new image, there the script opens a real document...
So the first steps were running on one image and when the new image emerged, all other steps was running on that really opened document...
Now, i solved this, by adding one more copy and paste cycle just on the beginning of the script, so that the image is opened as document from the beginning
But then an other problem emerged - when the script is finished, there is an opened document left...
And with each image in the batch one more...
And after a while there is a warning message (opening 10 and more documents can decrease the performance...) and with this warning the batch is interrupted...
I had try to put a close document command on the beginning of the script, but wasnt able to work it out
It finished with error (no document to close) or with no effect...
Code: Select all
# SelectDocument
App.Do( Environment, 'SelectDocument', {
'SelectedImage': -1,
'Strict': False,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((17,0,0),1)
}
})
# FileClose
App.Do( Environment, 'FileClose', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((17,0,0),1)
}
})LeviFiction wrote:Can you share the script here?
I've never done a batch with "paste as new image" before. It's entirely possible the issue has to do not with execution timing but the actions themselves not being intended for use in batch scripting. Seeing all of the steps should help us find the problem and offer solutions.
Re: Script OK on single image, but fails in BATCH mode...
Hi, thank You for your time
The reason im doing this is, that in one point of the script i need to split the layer into H S and L and obtain edges from the L chanel, then put this edges as mask back to the document in process...
There is no command to split a layer to HSL... only image can be splitted...
Did i miss something???
The reason im doing this is, that in one point of the script i need to split the layer into H S and L and obtain edges from the L chanel, then put this edges as mask back to the document in process...
There is no command to split a layer to HSL... only image can be splitted...
Did i miss something???
JoeB wrote:is there some reason you are copying a layer and pasting as new image to do some processing of that layer and then subsequently putting the processed image back into the original as a layer? Why can't you just do the processing on that layer while it's still a layer in the original image?
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
Re: Script OK on single image, but fails in BATCH mode...
My reply is going to sound disjointed and unhelpful. So I do apologize if it is unhelpful.
You need to be introduced to the joys of App.TargetDocument an App.ActiveDocument. As well as targeting a document with a command. App.TargetDocument is the image that you're running the script in. App.ActiveDocument is the image that currently has all of PSP's attention. There is an optional last parameter on every App.Do() command that lets you set the target of the command. By using these together you can pinpoint which document gains the attention of a command.
So, for example, You have an image, this image creates another image. This second image becomes the active document. But the original image remains the target document. And using the document parameter you can force a command to work on your target document or your active document without changing which image is the active document. If you keep track of these documents in variables you can easily control which ones get closed.
What follows is Pseudo code, it's only meant to give an idea of what I'm talking about, but is not useable on its own.
So if you use FileClose() at the end of your script and make sure to pass it a reference to the new image you shouldn't have this issue.
That wasn't helpful was it?
You need to be introduced to the joys of App.TargetDocument an App.ActiveDocument. As well as targeting a document with a command. App.TargetDocument is the image that you're running the script in. App.ActiveDocument is the image that currently has all of PSP's attention. There is an optional last parameter on every App.Do() command that lets you set the target of the command. By using these together you can pinpoint which document gains the attention of a command.
So, for example, You have an image, this image creates another image. This second image becomes the active document. But the original image remains the target document. And using the document parameter you can force a command to work on your target document or your active document without changing which image is the active document. If you keep track of these documents in variables you can easily control which ones get closed.
What follows is Pseudo code, it's only meant to give an idea of what I'm talking about, but is not useable on its own.
Code: Select all
OriginalImage = App.TargetDocument
App.Do(Environment, 'Copy',{})
App.Do(Environment, 'PasteAsNewImage", {})
# SelectDocument
App.Do( Environment, 'SelectDocument', {
'SelectedImage': -1,
'Strict': False,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((17,0,0),1)
}
})
NewImage = App.ActiveDocument
#perform edits on NewImage
App.Do(Environment, "Copy", {})
App.Do(Environment, "PasteAsNewLayer,{}, OriginalImage) #<- Notice addition of my OriginalImage at the very end of the command
#By adding OriginalImage to the end I can paste into my original image without having to use "SelectDocument" this also works in reverse.
#I can use this to force close the new image at the end of my script.
# FileClose
App.Do( Environment, 'FileClose', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((17,0,0),1)
}
},NewImage)
That wasn't helpful was it?
https://levifiction.wordpress.com/
Re: Script OK on single image, but fails in BATCH mode...
Well, i will dive into it...
I recorded the macro and edited some little details in text editor... i had no idea about these variables...
Im going to find the way...
But i noticed an other thing right now...
Even if running the script in batch mode on less than 10 images, and choosing to save them as pspimage file, the saved file is only one layer - despite the script ends with 3 layers
... i suppose this also can be the consequence of active and target documents i messed up in the script... (?)
I recorded the macro and edited some little details in text editor... i had no idea about these variables...
Im going to find the way...
But i noticed an other thing right now...
Even if running the script in batch mode on less than 10 images, and choosing to save them as pspimage file, the saved file is only one layer - despite the script ends with 3 layers
... i suppose this also can be the consequence of active and target documents i messed up in the script... (?)
LeviFiction wrote:My reply is going to sound disjointed and unhelpful. So I do apologize if it is unhelpful.
You need to be introduced to the joys of App.TargetDocument an App.ActiveDocument. As well as targeting a document with a command. App.TargetDocument is the image that you're running the script in. App.ActiveDocument is the image that currently has all of PSP's attention. There is an optional last parameter on every App.Do() command that lets you set the target of the command. By using these together you can pinpoint which document gains the attention of a command.
So, for example, You have an image, this image creates another image. This second image becomes the active document. But the original image remains the target document. And using the document parameter you can force a command to work on your target document or your active document without changing which image is the active document. If you keep track of these documents in variables you can easily control which ones get closed.
What follows is Pseudo code, it's only meant to give an idea of what I'm talking about, but is not useable on its own.
So if you use FileClose() at the end of your script and make sure to pass it a reference to the new image you shouldn't have this issue.Code: Select all
OriginalImage = App.TargetDocument App.Do(Environment, 'Copy',{}) App.Do(Environment, 'PasteAsNewImage", {}) # SelectDocument App.Do( Environment, 'SelectDocument', { 'SelectedImage': -1, 'Strict': False, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((17,0,0),1) } }) NewImage = App.ActiveDocument #perform edits on NewImage App.Do(Environment, "Copy", {}) App.Do(Environment, "PasteAsNewLayer,{}, OriginalImage) #<- Notice addition of my OriginalImage at the very end of the command #By adding OriginalImage to the end I can paste into my original image without having to use "SelectDocument" this also works in reverse. #I can use this to force close the new image at the end of my script. # FileClose App.Do( Environment, 'FileClose', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((17,0,0),1) } },NewImage)
That wasn't helpful was it?
