![]() Then you wouldn't have to create an intermediate Bitmap object in your Crop function. Unless you need to work with metafiles, you should probably be using Bitmap objects internally and not Images. It seems like if your only operations are load, save, scale, and crop, you should be able to easily replace the implementation later if you want. If you go with imagemagick, you should probably use a Q8 build for the speed and memory gains, unless the extra precision is important to you. I can't say one is clearly better than the other for your use case. GDI+ is a drawing library, and it wasn't designed for large images, but at least a Bitmap object won't hold any resources other than the memory for the pixel data and image metadata (contrary to popular belief, they do not contain HBITMAP objects). That and 32-bit RGB are probably the most efficient formats. GDI+ Bitmap objects will always store uncompressed data in memory and will generally default to 32-bit RGBA. (If you are working with very large images, ImageMagick is the clear winner.) It also can use multiple threads, but I doubt that will matter unless you're working with very large images. My impression is that in practice ImageMagick will typically work with a 64-bit RGBA buffer internally, unless you use a Q8 version which will use 32-bit RGBA. 'identify -version' will tell you what your bit depth is. It seems ImageMagick will internally convert images to an uncompressed format with 4 channels and a specific bit depth, typically 16 bits per channel, and do its work with the uncompressed data, which may be in memory or on disk depending on the size. I did happen upon this page describing ImageMagick's architecture: I know a few things about how GDI+ works but nothing about ImageMagick. ![]() Gr.DrawImage(sourceImage, new Rectangle(0, 0, width, height)) Ĭan you link to somewhere people have said that GDI+ shouldn't be used on the server? Maybe they know something I don't. ![]() Gr.PixelOffsetMode = PixelOffsetMode.HighQuality Gr.InterpolationMode = InterpolationMode.HighQualityBicubic Gr.SmoothingMode = SmoothingMode.AntiAlias Using (Graphics gr = Graphics.FromImage(newImage)) This is the code I use to resize: internal Image ResizeTo(Image sourceImage, int width, int height) Using (Bitmap bmpImage = new Bitmap(image))īmpCrop = bmpImage.Clone(r, bmpImage.PixelFormat) This is the code I use to crop: internal Image Crop(Image image, Rectangle r) I believed GDI+, ImageMagick or any other library should be more or less the same for those basic operations, and I liked the idea of using native GDI+ believing whatever MS is shipping with. I don't know the details, but I guess it's for the memory consumption, and indeed I can see GDI+ is using more memory to do the same operation (crop and resize) over the same image than ImageMagick (while to be honest GDI+ is faster). Now that I am rewriting the application from scratch, I replaced ImageMagick with native GDI+ operations, but the more I learn around GDI+ the more I am scared I made the wrong choice.Įverywhere I read that GDI+ is for the desktop and should not be used on a server application. Years ago when I wrote the application I choose ImageMagick, and I did all my cropping and resizing with ImageMagick. I have a web application where users can upload pictures to create their galleries.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |