Skip to main content
Inspiring
April 4, 2019
Question

Crash when batching thousands of images with complex script

  • April 4, 2019
  • 4 replies
  • 2662 views

I am trying to batch large numbers of high-res images through my processing script (about 3000 lines of js) that saves various sizes and crops of the images as well as pasting them into smart objects in template files, saving out listing images and writing to csv file to track the data. Everything works fine for a few hours and through almost a thousand of the images but then Photoshop tries to open the Help page a couple of times and crashes with a general unknown error.

It seems that it might be running out of or misusing it's available resources as it doesn’t crash on the same part of the script or the same image each time but usually after a running for a long time.

Is there a limit to the number of times Photoshop can perform certain actions such as opening or saving files? Is there any way to close and reopen Photoshop at set times in a script to allow it to free up the resources and not trip up over itself?

I can provide a copy of the script to look through but I warn you it's fairly long and relies on some external psd files to run.

Win10 10.0.17134 Build 17134

32GB Ram

Photoshop CC 20.0.4

This topic has been closed for replies.

4 replies

Participating Frequently
April 5, 2019

Bonjour

You can try the Kukurykus method
See HERE !

SuperMerlin
Inspiring
April 4, 2019

You might want to look at Bridge to manage the restart using:

app.scheduleTask(script, delay[, repeat]); delay in milliseconds

You would need to have some method of counting/restart of your script.

This way you could have Photoshop closed and restarted.

Inspiring
April 4, 2019

Thank you SuperMerlin, I hadn't even thought of including Bridge in the mix! I'll test that out this afternoon and post my results on Monday.

JJMack
Community Expert
Community Expert
April 4, 2019

Are you sure the is the version of windows you are  using.  The numbers you gave do not seem correct to me their formats seem incorrect. My version number is 4 digits not 5 and my Build format  is 5 digits.3digits.   Photoshop is a resource hungry applications and how you configure it my increase its appetite.  For example History Stated if you keelp many watch out writibf a batching script.

The Performance of replace Content was very poor and unexpected. I have my Preferences set to keep up to 100 History states.  When I batch a mockup with large number of replacements images I found this caused Photoshop to use all my systems Rams. I configured Photoshop to be allowed to use 30GB of RAM my system has 40GB. After Photoshop utilized all the RAM it can Photoshop started using use a lot of extra scratch space.  So I restructured my script to suspend-history processing mockup templates. The Performance improved outstanding.

The test case I used was a Collage type mockup that has 9 smart Object layers update. Either by Replace Content or Edit Smart Object. There were a total of 81 images which produced 9 output Jpeg files.

The Photo Collage is a simple collage template with no smart object layers. It just get 9 smart object layer placed in sized, positioned and shaped. Distortion is not supported, warping,rotation, perspective etc. This is done on a duplicate document so only collages with a large number of image would create too many history states to manage in ram on my 40GB workstation.

When a batch Mockup script is run in its default mode (Replace Smart Object Content). You will see little or no activity in the History Palette and Layers Pallet. You may think the script is hung. It is not you can monitor the output folder and see output jpeg files being saved.  When run in Edit Smart Object mode you will see much activity in the palettes. Also Photoshop Image Window updating may not be what you expect.

CS6 and CC 2019 Performance is about the same  CC 2014 seems somewhat slower.  My processors are also slow only 2GHz Photoshop minimum requirement.

Some think the may also be a memory leak In Photoshop or Windows Re: I Love Photoshop CC But...

Took my 1.5 hours for my to populate 3,444 mockups files.

JJMack
Inspiring
April 4, 2019

Thank you JJMack for taking the time for such a detailed test and response! It's very much appreciated.

I just copied the Windows info from the System page, here's the details from the About page -

Version: 1803

OS Build: 17134.648

I have tried to optimise the performance settings of Photoshop, time to time over the last year, while building this script, as I know how hungry it can be. I have it set to only 10 History States because I prefer to work as non-destructively as possible (the script only needs 2 undo states max), max RAM usage is 70% (20984MB out of 29952MB), Cache levels 6, Tile Size 1024K, Scratch disk is only root HDD (not SSD) but has 754GB free space. I keep the number of open documents to no more than 5 at a time and make sure no document is more than 10 layers. And each template document only has one Smart Object layer, which is opened and has an image pasted into it (deleting previous layers before). History log is off, Generator is off and I disabled auto-save in case that was what was causing the hiccup.

This may be a silly question but do you know if Photoshop better performing without GPU support since it will skip some advanced rendering features? Are there any other features that can be disabled to improve performance over a large number of files? I am in the habit of closing and reopening the program while I am manually working with it to free up the resources and it would be ideal if there is some way to do this within a script?

Perhaps I am just throwing too much at it. Yesterday's batch was 1000 images going in to the process to create 7000 print-ready images (300dpi), and 43,000 listing jpgs. It made it about 75% of the way before crashing so I can run smaller batches, but I prefer to work out the reasons for something not working.

Thanks again for you help.

JJMack
Community Expert
Community Expert
April 4, 2019

If Photoshop is slowly accumulating machine resources like ram that you can see using the Task manager you may want to try adding  an Edit Purge All after so many  documents  are processed to see if Photoshop can free up some resources.  Perhaps there may  be a leak of some kind a purge may help.  If your machine runs out of scratch space and you are using startup disk Photoshop default setting for scratch space.  I would expect your system would have problems running.

JJMack
April 4, 2019

Hi

This may be a better forum to ask your question, I can move this thread for you if you like

Photoshop Scripting

Inspiring
April 4, 2019

That would be excellent, thank you

April 4, 2019

No problem

Moving to Photoshop Scripting from Photoshop