Unable to open image error 2695 & 3983

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tylernol
Posts: 3
Joined: 2016-09-08T08:28:19-07:00
Authentication code: 1151

Unable to open image error 2695 & 3983

Post by tylernol »

I'm trying to build a powershell script to resize all photos in a directory including the sub-directory. It appears to work, but it doesn't seem to want to open the photos. I've researched the error codes but most of them are for batch files or other command languages I'm not familiar with.

Code: Select all

Get-ChildItem C:\folder2shrink  |
where {$_.PsIsContainer} | 
foreach {mogrify -resize 1024x768 *.png}
Can anyone shine light on why this isn't working?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Unable to open image error 2695 & 3983

Post by fmw42 »

I suspect it is in your powershell and not Imagemagick. I do not think those codes are Imagemagick codes. Try running your mogrify command in a terminal window outside your powershell. If that works, then the issue is your powershell script.

Often when running a script, it does not know where to find Imagemagick. Try putting the full path to mogrify. Does that work?

In the future please always provide your IM version and platform, though I see you are on Windows.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Unable to open image error 2695 & 3983

Post by snibgo »

I suspect the poster hasn't us given the entire error message.

I suspect the problem is that there are no *.png files in the current directory.
snibgo's IM pages: im.snibgo.com
tylernol
Posts: 3
Joined: 2016-09-08T08:28:19-07:00
Authentication code: 1151

Re: Unable to open image error 2695 & 3983

Post by tylernol »

I tried the full path to mogrify and it still threw the same error but I figured out why it was throwing it. I needed to provide Powershell.exe -Command first. Anyway, the folder I'm pointed to contains nothing but png files and a sub-folder holding more png files.. The code now looks like this:

Code: Select all

Powershell.exe -Command Get-ChildItem C:\folder2shrink |
where {$_.PsIsContainer} |
foreach {mogrify -resize 1024x768 *.png}
It follows through with no visible errors, however it doesn't run the mogrify script.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Unable to open image error 2695 & 3983

Post by snibgo »

Instead of mogrify, what happens if you have "dir *.png"? Do you get files listed?
snibgo's IM pages: im.snibgo.com
tylernol
Posts: 3
Joined: 2016-09-08T08:28:19-07:00
Authentication code: 1151

Re: Unable to open image error 2695 & 3983

Post by tylernol »

It still follows through but doesn't print anything, but that line typed into powershell works fine. So I guess its something with my syntax and not imagemagick.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Unable to open image error 2695 & 3983

Post by fmw42 »

Are you sure you are changing directories to the directory that contains the png images. If you are not in the correct directory, mogrify will not have any png images to process.

I also recommend that you backup your images or use -path with mogrify to some existing empty directory where the output results should be placed.

Also note that mogrify does not traverse subdirectories.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Unable to open image error 2695 & 3983

Post by snibgo »

Yes. I don't know Powershell, but I think the command shown loops through directories but then does a dir or mogrify in the original directory, because there is no reference in the command to a loop variable.
snibgo's IM pages: im.snibgo.com
Post Reply