I am hosting a site on Azure. I am able to upload a photo and save it to Amazon S3. What I am confused about is how to upload that one photo, make three different sized photos from that photo and then upload those photos to Amazon S3.
Asked
Active
Viewed 932 times
1 Answers
1
Is this not a question more on image resizing?
Your text states that you are able to (through your site on azure) save an image on Amazon S3. Correct?
If that is the case, you just need to take your image that has been uploaded, resize it 3 times, then submit each image using the same method you are already using.
I would personally create a separate method which you pass an image and some dimensions, and that returns an image.
Then just call this 3 times with different sizes specified.
public void SomeMethodName()
{
Image img = System.Drawing.Image.FromStream(myStream);
//Send orig image
sendImageToAmazon(img);
//Send resized images
sendImageToAmazon(ImageResize(img, 1280, 960));
sendImageToAmazon(ImageResize(img, 640, 480));
sendImageToAmazon(ImageResize(img, 320, 240));
}
public void sendImageToAmazon(image img)
{
//Your current code
}
public image ImageResize(image orig, int width, int height)
{
//Image resizer code.
}
There is loads of image resizer code on SO. e.g. Resize an Image C#
Image from Filestream stuff here: - asp.net c# convert filestream to image - Save stream as image
Unless I have misunderstood your question...
-
Thanks for the reply. I am uploading 1 file from filestream and once I do that filestream is empty. Because of this the only thing I can think to do is pull from S3 after upload and use that to create the other sizes. Before switching to Azure I had it working by using the webimage class and setting that with the filestream. With this method though I had the luxury of the local file system. Now I do not. Seems I need a way of holding the filestream in a variable and using that to create and send each image. Any more help would be greatly appreciated. – user2109468 Oct 02 '14 at 21:14
-
So if you simply take your filestream and throw it into S3, you are going to miss being able to add functionality before that happens. I would advise taking the filestream, and then converting that to an image / bitmap, which you can then use for processing, then you can send that off to your S3 or image resizer etc. http://stackoverflow.com/questions/3529485/loading-a-picture-file-image-fromfile-vs-filestream If you want to keep using filestreams for your S3 hookup, then simply convert your resized images back to filestreams when sending to S3. – Del Oct 03 '14 at 12:36
-
Useful Links: http://stackoverflow.com/questions/3529485/loading-a-picture-file-image-fromfile-vs-filestream http://stackoverflow.com/questions/14979841/c-sharp-convert-image-to-filestream http://social.msdn.microsoft.com/Forums/vstudio/en-US/b3aa9965-9947-4003-b1e1-57353f083e38/how-to-convert-image-files-to-stream http://www.rasteredge.com/how-to/csharp-imaging/convert-image-to-stream/ Hope that helps. – Del Oct 03 '14 at 12:40
-
Just made some updates to make the code a bit more usable. – Del Oct 03 '14 at 14:29