Copy link to clipboard
Copied
Hi!
I'm pretty new to photoshop scripting so bear with me, but I made a script to automatically resize a bunch of images.
It works as it should, the thing is, one of the images on the folder was corrupted, so mid script I got an error saying that the image couldn't be opened, then the script continued. All of the other images got correctly resized, but there was no way for me to tell which one was the corrupted one, so I had to check one by one until I found it.
Is there a way to detect via code if the image is corrupted? So as an example I could make an alert in that case showing the name of the image that didn't open.
Copy link to clipboard
Copied
Shouldn't be script to not be continued when image wasn't opened as it couldn't then resize epmty space?
Copy link to clipboard
Copied
The script just ignores the corrupt images, so the script doesn't break.
What I would like to do is find a way to store the names of the images that throw an error, or if that's too dificult, maybe throw an alert with the name of the image that didn't open?
Copy link to clipboard
Copied
Unless things have changed in the PSCC era, there is no way to gracefully handle extreme errors when opening an image file. You will get an Error Alert and you cannot avoid it.
To get around this your best bet maybe to call an external program (e.g. IrfanView?) or see if you can call Bridge to validate the file. I used to use IrfanView to prescan files for corruption before processing in PS especially if it was a large number of files.
Copy link to clipboard
Copied
Maybe I do not understand correctly, but I have everything working in CC2018
var ok = true;
try { open(File("C:\\BadOrCorruptedFile.JPG")) } catch(e) { ok = false; }
alert(ok)
Copy link to clipboard
Copied
That's great that they finally 'fixed' it. We have requested this change for years.