Atalasoft DotImage - Resize a stream
I'm grabbing an image over the internet via WebClient into a stream.
I need to resize the image (constraining proportions but with max width 120px) and the开发者_运维百科n return as another stream.
Can someone show me the code to do this. I've dug through the developer guide but can't find the answer.
You don't need WebClient to do this.
AtalaImage atalaImage = AtalaImage.FromURL(url); // grab the image from url.
ResampleCommand rc = new ResampleCommand(width, height); // create resize command
atalaImage = rc.Apply(atalaImage).Image; // resize
Edit: You can also use ResampleCommand with max size.
ResampleCommand rc = new ResampleCommand(maxSize);
With this code available here:
http://snippets.dzone.com/posts/show/1485
You can resize a image stored in a file. You just need to save the stream to a file, modify it and send it back again. Of course you can also work directly in memory modifying the code.
精彩评论