Skip to content

JpegEncoder producing incorrect output on linux-arm (since Beta006) #871

Closed
@qdraw

Description

@qdraw

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported
  • I have discussed this on gitter

Description

I have some Image encoding issues on linux-arm. This code bellow works with beta-0005, but not beta-0006 or newer. I have also tested it with the latest nightly build 1.0.0-dev002459 The issues are only visible on linux-arm, on other platforms it is working well

UPDATE (22/05/2019, @antonfirsov)

Resizing is not relevant here, it's the issue of the jpeg encoder.

TL;DR:

  • load jpeg -> resize -> save jpeg [PINK]
  • load jpeg -> save jpeg [PINK]
  • load png -> save jpeg [PINK]
  • load gif -> save jpeg [PINK]
  • load jpeg -> resize -> save png [OK]
  • load jpeg -> save png [OK]

The images are looking like this, I have tried it with multiple jpeg images
QZNU6ZQ3I6C7WV76TUB2X7C57E
Source of the image:
https://raw.githubusercontent.com/SixLabors/ImageSharp/master/tests/Images/Input/Jpg/baseline/Lake.jpg

Steps to Reproduce

I'm initially used it for resizing but it happens also when you write the image:
I'm using the following code:

using (var inputStream = _iStorage.ReadStream(subPath))
using (var image = Image.Load(inputStream))
{
	image.Save(outputStream, new JpegEncoder{
		Quality = 100,
	});
						
	_iStorage.WriteStream(outputStream, outputHash);  
}

public Stream ReadStream(string path, int maxRead = -1)
{
	if ( ! ExistFile(path) ) throw new FileNotFoundException(path);
	
	FileStream fileStream;
	fileStream = new FileStream(path, FileMode.Open, FileAccess.Read,FileShare.Read, maxRead, false);
	return fileStream;
}

public bool WriteStream(Stream stream, string path)
{
	if ( !stream.CanRead ) return false;
	
	stream.Seek(0, SeekOrigin.Begin);
				
	using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write))
	{
		stream.CopyTo(fileStream);
	}
	stream.Dispose();
	return true;
}

System Configuration

When running on linux-arm as release and debug

  • ImageSharp version: 0006 and newer
  • Other ImageSharp packages and versions:
  • Environment (Operating system, version and so on): linux-arm
  • .NET Framework version: build as: 2.2.104, runtime: 2.1.8
  • Additional information: running on a Raspberry Pi 2 or 3

--
Edit: tested based on the feedback of @JimBobSquarePants:, this produces a 'normal' image

image.Save(outputStream, new PngEncoder{
    ColorType = PngColorType.Rgb, 
   CompressionLevel = 9, 
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions