Windows photo viewer can't run because not enough memory?

Solution 1:

I dig this issue because I had similar problem with photos exported from Android Send Reduced Free application.

This issue in my case is related to included Profile-icc in that JPG file.

  Profiles:
  Profile-icc: 536 bytes

It can be verified with ImageMagick identify -verbose command.

This is maybe not solution for Opening it right from Outlook but You can fix that files in source.

I've discovered that when I run convert BADFILE.jpg -strip GOODFILE.jpg command on that file it opens on Windows 7 Photo Viewer without any problem.

-strip  - strip image of all profiles and comments

You can get this whole tool here: https://imagemagick.org/script/download.php

So if You want make that all images again accessible just run batch on them:

mogrify.exe -format jpg -verbose -path C:\OUTPUT_DIR -strip *.jpg

Might be also used relative path like -path OUTPUT_DIR if You want them in subfolder.

If You have to open that files directly from Outlook I'd recommend for example IrfanView which does not have problem with opening that files. Just set it as default graphics files program.

Some people adviced something related to changeing default profiles in Your screen configuration, but I have it set to my Monitor type so I don't want to mess with that settings.

If You want this fully automatic You need 3 things:

  1. DefaultProgramsEditor ( https://defaultprogramseditor.com/ )
  2. ImageMagick ( https://imagemagick.org/download/binaries/ImageMagick-7.0.10-1-portable-Q16-x64.zip )
  3. Batch script which will process opened file.

1) First decompress ImageMagick to c:\apps\ImageMagick-7.0.10-1-portable-Q16-x64

2) Create batch script c:\apps\gfxopen.bat:

@echo off
C:\Apps\ImageMagick-7.0.10-1-portable-Q16-x64\convert.exe %1 -strip c:\temp\temp12345file.jpg

rundll32 "C:\Program Files\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen c:\temp\temp12345file.jpg

del c:\temp\temp12345file.jpg

3) Decompress DefaultProgramsEditor and run it, then choose File Type Settings > Context Menu > find jpg extension, then > Add...

Command name: Open Fixed Image

Program path: "C:\apps\gfxopen.bat" "%1"

Then choose "Open Fixed Image" and press "Set selected command as default"

Then Save context menu

That's all :)

Solution 2:

For any Android developers who may come across this: Seems that Windows Photo Viewer doesn't like the ICC profile metadata that Bitmap.compress writes (maybe it doesn't like any ICC profiles actually? I haven't checked).

Here's a way to simply strip out that metadata segment from the JPEG file, which results in a JPEG that is compatible with Windows Photo Viewer again:

    // Some image viewer applications (such as Windows Photo Viewer) doesn't seem to like the ICC profile meta data that Android's Bitmap.compress writes.
    // This decorator removes the section.
    private static class RemoveFFE2OutputStreamDecorator extends OutputStream {
        OutputStream underlyingStream;
        boolean marker = false;
        boolean skipSegment = false;

        public RemoveFFE2OutputStreamDecorator(OutputStream underlyingStream) {
            this.underlyingStream = underlyingStream;
        }

        @Override
        public void write(int b) throws IOException {
            // Based on https://en.wikipedia.org/wiki/JPEG#Syntax_and_structure
            if (this.marker) {
                this.marker = false;
                if ((b & 0xFF) == 0xE2) { // The 0xFF,0xE2 segment that Android writes seems to cause trouble with Windows Photo Viewer.
                    this.skipSegment = true;
                } else {
                    this.skipSegment = false;
                    this.underlyingStream.write(0xFF);
                    this.underlyingStream.write(b);
                }
            } else if ((b & 0xFF) == 0xFF) {
                this.marker = true;
            } else if (!this.skipSegment) {
                this.underlyingStream.write(b);
            }
        }

        @Override
        public void flush() throws IOException {
            this.underlyingStream.flush();
        }

        @Override
        public void close() throws IOException {
            this.underlyingStream.close();
        }
    }

Solution 3:

I got the same issue and solved it following simple steps:

  • Open image file with Notepad++, or any other similar hex editors.
  • Find ICC_PROFILE inside the text and replace to ICC_PROFILX (generally on the first text line of file)
  • Save the edited file. That is all!

Before enter image description here After enter image description here

Solution 4:

I fixed this problem by unTick ICC Profile: sRGB when saving jpg with Photoshop.

See Properties of the image:

Photoshop Save As & Image Properties

Solution 5:

Type color in the windows startmenu search box and open the Colour Management.

"color" start menu search

Go then to the Advanced tab and select Agfa:Swop Standard for the Device Profile

Colour Management screen