The same method that uses the mono gdi + library giving very different results on different machines

I scratch my head on this, since I hardly know how to begin to understand the problem in my hands.
The problem is using a static method (and which I took from some post here in SO) that saves the System.Drawing.Image file to a jpeg file on disk and looks something like this:

public static void SaveJpeg(string path, Image image, int quality) { //create an encoder parameter for the image quality EncoderParameter qualityParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality); EncoderParameter compressionParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, (long)EncoderValue.CompressionNone); // Now in this part there is some code which gets the jpeg ImageCodecInfo // from ImageCodecInfo.GetImageEncoders() ImageCodecInfo jpegCodec = GetEncoderInfo("image/jpeg"); //create a collection of all parameters that we will pass to the encoder EncoderParameters encoderParams = new EncoderParameters(2); //set the quality and compression parameters for the codec encoderParams.Param[0] = qualityParam; encoderParams.Param[1] = compressionParam; //save the image using the codec and the parameters image.Save(path, jpegCodec, encoderParams); } 

On my website, users send photos that are first reduced to about 900x900 (from GDI itself, to reduce the file size, which can be up to 4 MB), and then saved to disk. The problem is that running it with the same parameter of the System.Drawing.Image parameter on my machine and in my Linode node gives:
1. On my machine, a 3.1 MB high-resolution image is converted to an ~ 80 kB image.
2. In my Linode, the same image will produce an image of ~ 500 kb.

First of all, I would like to emphasize that I run the same web application on my testing / development computer, which I run in my Linode. In addition, I checked the versions of all the software installed on both machines (gentoo linux, by the way), and I got:
1. Mono: 2.10.5, the same USE flags on both machines,
2. Apache 2.2.21-r1, some USE flags are slightly different (but should not interfere); 3. Mod_mono 2.10, the same USE flags on both machines,
4. libgdiplus 2.10, the first USE flags, and then tried to turn on Cairo on machines without changing the results.
5. cairo 1.10.2-r1, the opengl flag is enabled on my machine, but not in Linode.

I can't think of why SO behavior is different. The big difference is that my Linode is 32-bit Linux 3.0.4, while my machine is 64-bit Linux 2.6.39, although I think this should not interfere either.

Any similar experiences or ideas, anyone?

+4
source share
2 answers

libgdiplus does not do native JPEG processing; it contains only a bit of glue code to map the GDI + API to libjpeg. In addition, libgdiplus itself does not have 32/64 bits of different code paths.

I would suspect some difference between the libjpeg versions used in your box compared to the linode version.

+2
source

Have you checked your libjpeg version on both machines? Perhaps a problem?

0
source

Source: https://habr.com/ru/post/1382019/


All Articles