Shrink images as they are uploaded to the PWShttp://forums.asp.net/t/1040773.aspx/1?Shrink+images+as+they+are+uploaded+to+the+PWSSat, 04 Nov 2006 12:57:57 -050010407731448640http://forums.asp.net/p/1040773/1448640.aspx/1?Shrink+images+as+they+are+uploaded+to+the+PWSShrink images as they are uploaded to the PWS <p><span style="font-size:10pt; font-family:Arial">Hi,</span></p> <p><span style="font-size:10pt; font-family:Arial">&nbsp;</span></p> <p><span style="font-size:10pt; font-family:Arial">I'm looking for a way to auto shrink the images as they are being uploaded to the PWS before they are saved to the database. Some of the images are enormous 3000 &#43;&nbsp;and I would like to shrink them down to 640.</span></p> <p><span style="font-size:10pt; font-family:Arial">&nbsp;</span></p> <p><span style="font-size:10pt; font-family:Arial">Is there a way to modify the PWS to include an auto shrink feature either in the code of the upload process or in the database stored procedures so as the images are always shrunk to a good web optimized size</span></p> <p>&nbsp;</p> 2006-11-01T01:06:16-05:001449458http://forums.asp.net/p/1040773/1449458.aspx/1?Re+Shrink+images+as+they+are+uploaded+to+the+PWSRe: Shrink images as they are uploaded to the PWS <p>I experienced the same issue.&nbsp; Was actually hosting on Go Daddy and filled the DB up.&nbsp; Images are not stored as compressed in the DB @ Go Daddy so it doesn't take many.</p> <p>&nbsp;</p> <p>I used the PWS kit from Jeremy Wadsworth and modified it to meet my needs.&nbsp; It stores the pictures in directories instead of the DB and only puts a pointer in the DB.&nbsp; Seems to run faster and you don't have the DB issue.</p> <p>&nbsp;</p> <p>Also, I would recommend using Adobe Elements and do the save for web process.&nbsp; It makes the images smaller and easier to upload as well as less space and you don't sacrifice too much quality.&nbsp;</p> <p>&nbsp;</p> <p>Bob</p> <p>&nbsp;</p> 2006-11-01T16:54:29-05:001449936http://forums.asp.net/p/1040773/1449936.aspx/1?Re+Shrink+images+as+they+are+uploaded+to+the+PWSRe: Shrink images as they are uploaded to the PWS <p>I agree with Bob that it is recommended that Images be processed and converted to smaller image size regardless of whether you use the file system or database. I think often time people make the mistake of uploading the&nbsp;original image file off the camera which in most cases is way too large to be putting up on the web. If you're using Photoshop, there is an Image Processor that allows for batch processing of images.</p> 2006-11-01T22:40:38-05:001450299http://forums.asp.net/p/1040773/1450299.aspx/1?Re+Shrink+images+as+they+are+uploaded+to+the+PWSRe: Shrink images as they are uploaded to the PWS <p>Jeremy,</p> <p>&nbsp;</p> <p>I agree that they need to be compressed or shrunk before uploaded. I'm looking to see if there is a way to compress them as part of the upload process built into the PWS. Presently i'm gathering the files then shrinking them and uploading them. I would like to be able to give the upload ability to my friends and family but i know they have no idea how to shrink images. </p> <p>&nbsp;</p> <p>I'm looking for something that I can add to the PWS or make some code changes on the PWS to shrink by&nbsp;a set percentage when my friends or family select files for upload so whatever goes into the database has already been shrunk by the upload page of the PWS</p> 2006-11-02T06:16:43-05:001451397http://forums.asp.net/p/1040773/1451397.aspx/1?Re+Shrink+images+as+they+are+uploaded+to+the+PWSRe: Shrink images as they are uploaded to the PWS <font face="Times New Roman" size="3"> <p class="MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-family:Arial">I had a similar issue; mine was the quality of the displayed image in 600x400 when its resized at runtime from a larger image.</span></p> <p class="MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-family:Arial">I ended up using Adobe to bulk resize all images to 600x400 before uploading.</span></p> <span style="font-family:Arial"> <p class="MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-family:Arial"></span></p> <span style="font-family:Arial">&nbsp;</span> <p class="MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-family:Arial">I agree that a resize at runtime is much easier, <span>&nbsp;</span>I will have a go at it this weekend.</span></p> <p class="MsoNormal" style="margin:0cm 0cm 0pt">&nbsp;</p> <p class="MsoNormal" style="margin:0cm 0cm 0pt">Cheers,</p> <p class="MsoNormal" style="margin:0cm 0cm 0pt">Hs2K</p> </span></font> 2006-11-02T20:40:47-05:001451436http://forums.asp.net/p/1040773/1451436.aspx/1?Re+Shrink+images+as+they+are+uploaded+to+the+PWSRe: Shrink images as they are uploaded to the PWS <p><span style="font-size:10pt; font-family:Arial">Got it. Now I dont need to use Adobe any more. [:)]</span></p> <p><span style="font-size:10pt; font-family:Arial">While this change will resize the images before they get saved into the database, it will not save you the time waiting for the huge images being uploaded.</span></p> <p><span style="font-size:10pt; font-family:Arial">In App_Code\PhotoManager.vb go to the Sub AddPhoto and change this line,</span></p> <p><span style="font-size:10pt; color:blue; font-family:Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.Parameters.Add(New SqlParameter(&quot;@BytesOriginal&quot;, BytesOriginal))</span></p> <p><span style="font-size:10pt; font-family:Arial">&nbsp;To</span></p> <p><span style="font-size:10pt; color:blue; font-family:Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.Parameters.Add(New SqlParameter(&quot;@BytesOriginal&quot;, ResizeImageFile(BytesOriginal, 600)))</span></p> <p><span style="font-size:10pt; font-family:Arial">Now the image is resized to 600x400 before it's stored into the DB. You don't have to go all the way down to 600x400, you could always keep&nbsp;the @BytesFull at 1024 so the downloaded image a little bigger than the full image size.&nbsp;So now my new Sub AddPhoto looks like this,</span></p> <p><span style="font-size:10pt; color:blue; font-family:Arial">Public Shared Sub AddPhoto(ByVal AlbumID As Integer, ByVal Caption As String, ByVal Google As String, ByVal Lat As String, ByVal Lon As String, ByVal BytesOriginal() As Byte)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Using connection As New SqlConnection(ConfigurationManager.ConnectionStrings(&quot;Personal&quot;).ConnectionString)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Using command As New SqlCommand(&quot;AddPhoto&quot;, connection)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.CommandType = CommandType.StoredProcedure<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.Parameters.Add(New SqlParameter(&quot;@AlbumID&quot;, AlbumID))<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.Parameters.Add(New SqlParameter(&quot;@Caption&quot;, Caption))<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.Parameters.Add(New SqlParameter(&quot;@Google&quot;, Google))<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.Parameters.Add(New SqlParameter(&quot;@Lon&quot;, Lon))<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.Parameters.Add(New SqlParameter(&quot;@Lat&quot;, Lat))<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.Parameters.Add(New SqlParameter(&quot;@BytesOriginal&quot;, ResizeImageFile(BytesOriginal, 600)))<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.Parameters.Add(New SqlParameter(&quot;@BytesFull&quot;, ResizeImageFile(BytesOriginal, 600)))<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.Parameters.Add(New SqlParameter(&quot;@BytesPoster&quot;, ResizeImageFile(BytesOriginal, 198)))<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.Parameters.Add(New SqlParameter(&quot;@BytesThumb&quot;, ResizeImageFile(BytesOriginal, 100)))<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connection.Open()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.ExecuteNonQuery()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Using<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Using<br> &nbsp;&nbsp;&nbsp; End Sub</span></p> <p><span style="font-size:10pt; font-family:Arial">&nbsp;Hope that helps,</span></p> <p><span style="font-size:10pt; font-family:Arial">Hs2K</span></p> 2006-11-02T21:23:50-05:001452980http://forums.asp.net/p/1040773/1452980.aspx/1?Re+Shrink+images+as+they+are+uploaded+to+the+PWSRe: Shrink images as they are uploaded to the PWS <p>HS2K,</p> <p>&nbsp;</p> <p>Great this seems to work fine. Thanks for the help</p> 2006-11-04T12:57:57-05:00