Magick.NET
By Jax
Magick.NET ??
ImageMagick is a powerful image manipulation library that supports
over 100 major file formats (not includin...
Use Resize
using (var image = new MagickImage("001.png")) { 
image.Resize(100, 100); 
image.Write("thumb.jpg"); 
} 
PNG to JPG background issue
using (var image = new MagickImage("001.png")) { 
image.Resize(100, 100); 
image.Extent(image....
Use Crop
using (var image = new MagickImage("001.png")) { 
int size = Math.Min(image.Width, image.Height); 
image.Crop(siz...
Input / Output functions
public MagickImage(Bitmap bitmap); 
public MagickImage(byte[] data); 
public MagickImage(MagickIm...
Resize functions
image.AdaptiveResize(100, 100); 
//     Resize using mesh interpolation. It works well for small resizes ...
效率 (sec)
• size: 5906 x 8268 run: 100
• AdaptiveResize:
48.133
• Resize:
224.000
• Sample:
47.448
• Scale:
85.788
•
•
•
•
...
Setup 注意事項
• Use NuGet
• Magick.NET-Q8-x86
• Magick.NET-Q8-x64
• Magick.NET-Q16-x86
• Magick.NET-Q16-x64
• 需要安裝
• Visual C...
Q8 or Q16?
• Versions with Q8 in the name are 8 bits-per-pixel component (e.g. 8bit red, 8-bit green, etc.), whereas, Q16 ...
ImageMagick Command-line Tools
http://www.imagemagick.org/script/index.php
Use
convert test.png -resize 100x100 -quality 8...
Upcoming SlideShare
Loading in …5
×

Magick.net

1,551 views

Published on

Published in: Technology, Art & Photos
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,551
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Magick.net

  1. 1. Magick.NET By Jax
  2. 2. Magick.NET ?? ImageMagick is a powerful image manipulation library that supports over 100 major file formats (not including sub-formats). With Magick.NET you can use ImageMagick without having to install ImageMagick on your server or desktop. http://magick.codeplex.com/documentation
  3. 3. Use Resize using (var image = new MagickImage("001.png")) {  image.Resize(100, 100);  image.Write("thumb.jpg");  } 
  4. 4. PNG to JPG background issue using (var image = new MagickImage("001.png")) {  image.Resize(100, 100);  image.Extent(image.Width, image.Height, new MagickColor("#FFF"));  image.Format = MagickFormat.Jpeg;  image.Quality = 80;  image.Write("thumb.jpg");  }
  5. 5. Use Crop using (var image = new MagickImage("001.png")) {  int size = Math.Min(image.Width, image.Height);  image.Crop(size, size, Gravity.Center);  image.Write("crop.jpg");  } using (var image = new MagickImage("001.png")) {  image.Crop(new MagickGeometry(20, 20, 200, 200));  image.Write("crop.jpg");  }  
  6. 6. Input / Output functions public MagickImage(Bitmap bitmap);  public MagickImage(byte[] data);  public MagickImage(MagickImage image);  public MagickImage(Stream stream);  public MagickImage(string fileName);  public MagickImage(MagickColor color, int width, int height);  public string ToBase64();  public Bitmap ToBitmap();  public Bitmap ToBitmap(ImageFormat imageFormat);  public byte[] ToByteArray();  public override sealed string ToString();  public void Write(Stream stream);  public void Write(string fileName); 
  7. 7. Resize functions image.AdaptiveResize(100, 100);  //     Resize using mesh interpolation. It works well for small resizes of less  //     than +/- 50% of the original image size. For larger resizing on images a  //     full filtered and slower resize function should be used instead.  image.Resize(100, 100);  //     Resize image to specified size.  image.Sample(100, 100);  //     Resize image by using pixel sampling algorithm.  image.Scale(100, 100);  //     Resize image by using simple ratio algorithm. 
  8. 8. 效率 (sec) • size: 5906 x 8268 run: 100 • AdaptiveResize: 48.133 • Resize: 224.000 • Sample: 47.448 • Scale: 85.788 • • • • • size: 2480 x 3508 run: 100 AdaptiveResize: 9.994 Resize: 36.165 Sample: 9.161 Scale: 15.153
  9. 9. Setup 注意事項 • Use NuGet • Magick.NET-Q8-x86 • Magick.NET-Q8-x64 • Magick.NET-Q16-x86 • Magick.NET-Q16-x64 • 需要安裝 • Visual C++ Redistributable for Visual Studio 2012 Update 4
  10. 10. Q8 or Q16? • Versions with Q8 in the name are 8 bits-per-pixel component (e.g. 8bit red, 8-bit green, etc.), whereas, Q16 are 16 bits-per-pixel component. A Q16 version permits you to read or write 16-bit images without losing precision but requires twice as much resources as the Q8 version.
  11. 11. ImageMagick Command-line Tools http://www.imagemagick.org/script/index.php Use convert test.png -resize 100x100 -quality 80 thumb.jpg convert test.png -adaptive-resize 100x100 -quality 80 thumb.jpg

×