• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to detect if an image wont open in photoshop with script?

Community Beginner ,
Aug 27, 2018 Aug 27, 2018

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.

TOPICS
Actions and scripting

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Aug 27, 2018 Aug 27, 2018

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 27, 2018 Aug 27, 2018

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Aug 27, 2018 Aug 27, 2018

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Aug 27, 2018 Aug 27, 2018

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Aug 27, 2018 Aug 27, 2018

Copy link to clipboard

Copied

LATEST

That's great that they finally 'fixed' it. We have requested this change for years.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines