fschultz / NetImageLibrary

Library to help with image handling such as resizing, cropping, applying filters (brightess, contrast, unsharpen mask, chroma key etc), watermarking, thumbnail creation, opening/saving files or streams and more.
http://kaliko.com/image-library/
Other
90 stars 27 forks source link

BlitFill issue on high resolution images #8

Closed MichaelQuint closed 8 years ago

MichaelQuint commented 8 years ago

I'm getting strange issues with the BlitFill method on high resolution images, im using the method to watermark the images on my website with a watermark image ive created. I followed the tutorial to do so, for smaller images it works fine, for others not so much. Ive attached the results below:

image "7.jpg" ( the last one ) is correct.

11 12 4 7

MichaelQuint commented 8 years ago

Also, here is the code im using to produce the results.

                KalikoImage img = null;
                using (var ms = new MemoryStream(picture.Image))
                {
                    img = new KalikoImage(ms);
                    img.BlitFill(watermark);
                }

                byte[] image = null;
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    img.SaveJpg(memoryStream, 99);
                    image = memoryStream.ToArray();
                }
fschultz commented 8 years ago

Thank you for the bug report! I will look into why this happens.

fschultz commented 8 years ago

The issue seems to be related to the DPI resolution of the images. An image with for instance 300 DPI results in the same error as seen in the attached images, while the exact same image but in 96 DPI produces the correct result. I hope to have a fix for this soon.

MichaelQuint commented 8 years ago

Awesome, I appreciate the support!

fschultz commented 8 years ago

I've created a new branch where all constructors should be DPI-independent. It would be great if you can verify if this solves your problem, thanks!

The new branch is: https://github.com/fschultz/NetImageLibrary/tree/dpi-fix

MichaelQuint commented 8 years ago

Yessir, that did the trick. So converting the Image to Bitmap fixes this? very intereting

fschultz commented 8 years ago

Great! Yes, it seems that wrapping it as Bitmap is the easiest way to keep everything intact and in the same time resetting the DPI-information.