This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > PainShop Pro Scripting > May 2006 > Help Req'd - Problem with script - Polkadots





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Help Req'd - Problem with script - Polkadots
Howard Dickson

2006-05-19, 6:51 am

### Request assistance from scripting gurus out there ###

I've written a new script 'Polkadots' which as the name implies creates
circled areas within an image. It does this by selecting multiple
selections, inverting to alter the background, then deselecting to finish.

It calculates the number of circle selections per image width, and
automatically crops the image height to fit an exact number of vertical
rows.

This all works well when you select say 5 circles (polkadots) across the
image width, but when you start to increase the number of dots
(selections) to say 10+ the script takes ages to run (2 minutes or more)
and when complete, if you Undo it, it takes so long PSP hangs with loads
of hard disk activity.

I think I've found the problem, but don't know how to control/erradicate
it, which is a pity, as it's quite a good script effect IMHO.

When the script is run, a number of .tmp files are written to the
WindowsXP default 'Documents and Settings/Local Settings/Temp' folder,
each can be up to 20MB in size. So if choosing a high number of dots in
the script, these temp files can add up to over 200Mb! Hence I guess the
system slow down and Undo hang-up.

Is there any way that this can be controlled from within a script?
Do all these selection .tmp files have to be saved?
Is there a better way to do what I've done without the huge tmp file
storage?

Any help from the scripting gurus would be appreciated.
I've attached the PSP9 working copy of the script to this post.

Rgds,
Howard
--

---oooOOOooo---

Sheilsoft
ComputerSystems

www.sheilsoft.com

---oooOOOooo---

SuzShook

2006-05-19, 7:08 pm

Hi, Howard. I just gave your new script a test run in PSP X. I tried it
with 15 dots, and it ran in about 12 seconds, and UNDO'd in about 6 seconds.
Could it have to do with the amount of memory you have? I tried it with
other numbers, but with anything greater than 16 dots, after about 14
seconds, I got a message asking if I wanted to continue the script.
Responding Yes just continually brought back that message, over and over.
No message in the Script Output palette to explain why that was happening.
But I don't get any hang, Howard, either on execution or on undo. Suz

Howard Dickson wrote:
> ### Request assistance from scripting gurus out there ###
>
> I've written a new script 'Polkadots' which as the name implies
> creates circled areas within an image. It does this by selecting
> multiple selections, inverting to alter the background, then
> deselecting to finish.
>
> It calculates the number of circle selections per image width, and
> automatically crops the image height to fit an exact number of
> vertical rows.
>
> This all works well when you select say 5 circles (polkadots) across
> the image width, but when you start to increase the number of dots
> (selections) to say 10+ the script takes ages to run (2 minutes or
> more) and when complete, if you Undo it, it takes so long PSP hangs
> with loads of hard disk activity.
>
> I think I've found the problem, but don't know how to
> control/erradicate it, which is a pity, as it's quite a good script
> effect IMHO.
>
> When the script is run, a number of .tmp files are written to the
> WindowsXP default 'Documents and Settings/Local Settings/Temp' folder,
> each can be up to 20MB in size. So if choosing a high number of dots
> in the script, these temp files can add up to over 200Mb! Hence I
> guess the system slow down and Undo hang-up.
>
> Is there any way that this can be controlled from within a script?
> Do all these selection .tmp files have to be saved?
> Is there a better way to do what I've done without the huge tmp file
> storage?
>
> Any help from the scripting gurus would be appreciated.
> I've attached the PSP9 working copy of the script to this post.
>
> Rgds,
> Howard



Howard Dickson

2006-05-19, 7:08 pm

Suz,

Thanks for looking at it.
I've been writing/testing it in PSP9, and my system has 1Gb memory, with
plenty of hard disk space.

I was wondering if PSP has a paged memory setting that I couldn't find,
that I could turn off within the script, or whether that was necessary.

Certainly from what you've said, it appears to run much faster with you.
Don't know if that's PSPX or your system. I'll go try it on PSPX here.

Strange about that message, huh?

Thanks again.

Rgds,
Howard

SuzShook wrote:
> Hi, Howard. I just gave your new script a test run in PSP X. I tried it
> with 15 dots, and it ran in about 12 seconds, and UNDO'd in about 6 seconds.
> Could it have to do with the amount of memory you have? I tried it with
> other numbers, but with anything greater than 16 dots, after about 14
> seconds, I got a message asking if I wanted to continue the script.
> Responding Yes just continually brought back that message, over and over.
> No message in the Script Output palette to explain why that was happening.
> But I don't get any hang, Howard, either on execution or on undo. Suz
>
> Howard Dickson wrote:
>
>



--

---oooOOOooo---

Sheilsoft
ComputerSystems

www.sheilsoft.com

---oooOOOooo---
cwodave

2006-05-19, 7:08 pm

Howard Dickson wrote:
> ### Request assistance from scripting gurus out there ###

(Snip)
> Rgds,
> Howard


I just ran it using PSP-X
I have 2gig memory and lots of hard drive.

10 dots ran in about 60 sec and undo in maybe 5 sec
5 dots 15 sec and undo in 5 sec
15 dots ran in about 60 sec and undo in about 5 sec

I have no hang-ups

Dave


Howard Dickson

2006-05-19, 7:08 pm

cwodave wrote:
> Howard Dickson wrote:
> (Snip)
>
> I just ran it using PSP-X
> I have 2gig memory and lots of hard drive.
>
> 10 dots ran in about 60 sec and undo in maybe 5 sec
> 5 dots 15 sec and undo in 5 sec
> 15 dots ran in about 60 sec and undo in about 5 sec
>
> I have no hang-ups
>
> Dave
>
>

Dave,

Thanks for the info. I tried running it with PSPX, and perhaps it ran
slightly faster than PSP9, but my times were similar to yours, with only
1GB memory here. It's obviously very image dependant too. I've been
testing with 3008 x 2000 pixel images at 300, and as you would guess
2.5MB files run faster than the normal 5 MB file size for this image format.

I also tried the selection phase of the script on a transparent layer
first, before using that in the image, but the times weren't much different.

Hmmm...

Rgds,
Howard

--

---oooOOOooo---

Sheilsoft
ComputerSystems

www.sheilsoft.com

---oooOOOooo---
Spandex Rutabaga

2006-05-19, 7:08 pm

Howard Dickson wrote:
>
> ### Request assistance from scripting gurus out there ###
>
> I've written a new script 'Polkadots' which as the name implies creates
> circled areas within an image. It does this by selecting multiple
> selections, inverting to alter the background, then deselecting to finish.


I don't really know what the script does but I'd like to suggest
something completely different. The suggestion has the potential to
generate all the dots in one step and to use a single selection,
avoiding the nested loops you have currently. That should speed
things along and require less writing out of image data for undo.

The trick is to generate your dots with the Halftone filter (as in
the attached), which was applied to the upper three-level grey image.
The filter's Size control adjusts the distance between the centers of
the dots. The grey level from which the dots are generated determines
the size of the dots. As a bonus, you can set the angle of the
direction in which the dots run and also generate lines and square
dots.

I have in mind placing a new layer over the image, filling it with
the appropriate level of grey and putting down dots at the relevant
Size in black on white. (Those dots are anti-aliased by the way.)
Then you can use the sequence Select All, Select Color Range
(Black, Subtract, with enough Softness to keep the anti-aliasing),
Invert to select the dots. Now you can discard the grey layer and
just work with the selection in the image. You could also put the
dots down using Transparent for the background and then select them
using the All Opaque option of the Magic Wand. You'd loose the
original anti-aliasing but you could use the Anti-alias function in
the Magic Wand.

It is possible that with large images having very few dots either
the Size control or the possible grey levels won't get you the dot
pattern you want, especially if you want to exactly fill with whole
dots. In that case you can generate the dot layer as if for a
smaller image (but as big as you can) and resize the layer to get
what you want in the image. Obviously there are details to work out
but there are no loops and there are very few steps. (You might want
to test on very small images whatever scheme you end up using just
in case increments round down to zero and you loop forever.)
Howard Dickson

2006-05-19, 7:08 pm

Spandex Rutabaga wrote:
> Howard Dickson wrote:
>
> I don't really know what the script does but I'd like to suggest
> something completely different. The suggestion has the potential to
> generate all the dots in one step and to use a single selection,
> avoiding the nested loops you have currently. That should speed
> things along and require less writing out of image data for undo.
>
> The trick is to generate your dots with the Halftone filter (as in
> the attached), which was applied to the upper three-level grey image.
> The filter's Size control adjusts the distance between the centers of
> the dots. The grey level from which the dots are generated determines
> the size of the dots. As a bonus, you can set the angle of the
> direction in which the dots run and also generate lines and square
> dots.
>
> I have in mind placing a new layer over the image, filling it with
> the appropriate level of grey and putting down dots at the relevant
> Size in black on white. (Those dots are anti-aliased by the way.)
> Then you can use the sequence Select All, Select Color Range
> (Black, Subtract, with enough Softness to keep the anti-aliasing),
> Invert to select the dots. Now you can discard the grey layer and
> just work with the selection in the image. You could also put the
> dots down using Transparent for the background and then select them
> using the All Opaque option of the Magic Wand. You'd loose the
> original anti-aliasing but you could use the Anti-alias function in
> the Magic Wand.
>
> It is possible that with large images having very few dots either
> the Size control or the possible grey levels won't get you the dot
> pattern you want, especially if you want to exactly fill with whole
> dots. In that case you can generate the dot layer as if for a
> smaller image (but as big as you can) and resize the layer to get
> what you want in the image. Obviously there are details to work out
> but there are no loops and there are very few steps. (You might want
> to test on very small images whatever scheme you end up using just
> in case increments round down to zero and you loop forever.)
>
>
> ------------------------------------------------------------------------
>

Span,

Sounds like a cunning plan!

I'll have a play with that over the weekend.
Thanks again!

Rgds,
Howard
--

---oooOOOooo---

Sheilsoft
ComputerSystems

www.sheilsoft.com

---oooOOOooo---
Sponsored Links


Copyright 2003 - 2009 forum4designers.com  Software forum  Computer Hardware reviews