Skip to content
This repository has been archived by the owner on Jul 31, 2020. It is now read-only.

Commit

Permalink
Commit version 0.41 (2008/05/27)
Browse files Browse the repository at this point in the history
  • Loading branch information
yupswing committed Jan 13, 2015
1 parent 22b2a5d commit 7531893
Show file tree
Hide file tree
Showing 17 changed files with 2,729 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dotnet/index.htm
@@ -0,0 +1,15 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>wbResize 0.41</title>
</head>

<body style="margin:100px 0 0;text-align:center;">
<h1>wbResize 0.41</h1>
<p><small>scritto in C# per ASP.net [ .NET Framework 2.0 ]<br/>
sviluppato da <a href="http://www.imente.org/">Simone Cingano [imente]</a></small></p>
<p><a href="samplesave.aspx">versione save</a> - <a href="samplefly.htm">versione onthefly</a><br/>
<small>la versione save necessita di permessi di scrittura nella cartella upload</small></p>
</body>
</html>
49 changes: 49 additions & 0 deletions dotnet/samplefly.aspx
@@ -0,0 +1,49 @@
<%@ Page Language="C#" LCID=1040 Debug="true" Trace="false" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Runtime.InteropServices" %>
<%@ Import Namespace="System.Globalization" %>
<script Language="C#" runat="server" src="wbresize/wbresize.cs"></script>
<script Language="C#" runat="server" src="wbresize/quantizer.cs"></script>
<script Language="C#" runat="server">
string ThumbType = "";
void Page_Load(object sender, System.EventArgs e)
{
ThumbType = (Request.QueryString["t"]==null)?"":Request.QueryString["t"];
wbResize ImageResizer = new wbResize();
ImageResizer.LoadImage(Server.MapPath("upload/sample.jpg")); //accetta path, image e stream
ImageResizer.SetFileType(ThumbType); //Tipo di output [jpg, gif, bmp, tiff, png]
ImageResizer.SetThumbSize(500, 500, false); //Width, Height e forzatura
//ImageResizer.SetThumbSize(50); //IMPOSTA LA % DELL'ORIGINALE
ImageResizer.SetOptionHighQuality(true); //Alta qualità
ImageResizer.SetOptionJpegQuality(100); //Qualità JPEG
ImageResizer.SetOptionFilter(InterpolationMode.HighQualityBicubic); //Filtro di Interpolazione
ImageResizer.SetOptionGifDepth(4); //Profondità colore GIF [0 = off, 1, 2, 4, 8, 255 = grayscale]
ImageResizer.SetOptionGifPalette(255); //Dimensione Palette GIF [9-255]
ImageResizer.SetOptionTiffCompress(true); //Compressione TIFF
print(ImageResizer.Resize(),ThumbType);
}
private void print(MemoryStream memorystream, string filetype) {
//stampa nell'outputstream un'immagine (passata in un memorystream)
switch (filetype) {
case "gif": Response.ContentType = "image/gif"; break;
case "png": Response.ContentType = "image/png"; break;
case "bmp": Response.ContentType = "image/bmp"; break;
case "tiff": Response.ContentType = "image/tiff"; break;
default: Response.ContentType = "image/jpeg"; break;
}
memorystream.WriteTo( Response.OutputStream );
}
</script>
17 changes: 17 additions & 0 deletions dotnet/samplefly.htm
@@ -0,0 +1,17 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>wbResize 0.41 - onTheFly Sample</title>
</head>

<body style="text-align:center;margin:20px 0;">
<img id="ResultImage" src="samplefly.aspx" /><br/>
<small>esempio on the fly di wbResize<br />
in questo caso viene passato solo il tipo di file di output come parametro<br />
ma nulla vieta di sfruttare tutte le potenzialità della classe<br />
[sconsigliati sono gli usi intensivi della modalità onthefly]</small><br/>
<a href="javascript:;" onclick="document.getElementById('ResultImage').src = 'samplefly.aspx?t=jpg';">ridimensiona in jpeg</a><br/>
<a href="javascript:;" onclick="document.getElementById('ResultImage').src = 'samplefly.aspx?t=gif';">ridimensiona in gif</a>
</body>
</html>
55 changes: 55 additions & 0 deletions dotnet/samplesave.aspx
@@ -0,0 +1,55 @@
<%@ Page Language="C#" LCID=1040 Debug="true" Trace="false" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Runtime.InteropServices" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<script Language="C#" runat="server" src="samplesave.cs"></script>
<script Language="C#" runat="server" src="wbresize/wbresize.cs"></script>
<script Language="C#" runat="server" src="wbresize/quantizer.cs"></script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>wbResize 0.41 - Save Sample</title>
</head>
<style type="text/css">
body {
background:#FFF;
padding:0;
margin:0;
text-align:center;
}
.error {
color: red;
font-weight: bold;
}
</style>
</head>
<body>
<div style="width:90%;margin:20px auto;">
<h3>Esempio funzionante di wbResize 0.41 per ASP.net [Framework .NET 2.0]</h3>
<small>Parametri impostabili: tipo di output, calcolo automatico ridimensionamento, alta qualità di ridimensionamento,<br/>
livello di compressione jpeg, filtro di interpolazione, profondità e dimensione palette gif, compressione tiff</small>
<form name="inviafile" id="inviafile" enctype="multipart/form-data" runat="server"><br>

Select File 1:&nbsp;<input id="File1" type="file" runat="Server"/><br>
Select File 2:&nbsp;<input id="File2" type="file" runat="Server"/><br>
Select File 3:&nbsp;<input id="File3" type="file" runat="Server"/><br>
Select File 4:&nbsp;<input id="File4" type="file" runat="Server"/><br><br>
<label>Output files:</label> <select id="ThumbType" runat="Server">
<option value="jpg">Jpg</option>
<option value="gif">Gif</option>
<option value="png">Png</option>
</select><br><br>

<input id="Submit" type="submit" value="Upload and resize" runat="Server" onserverclick="SubmitFiles"/></div>

</form>
</div>
</body>
</html>
68 changes: 68 additions & 0 deletions dotnet/samplesave.cs
@@ -0,0 +1,68 @@
public string thumbtype = "jpg";
public System.Web.UI.WebControls.Image[] ResultImages = new System.Web.UI.WebControls.Image[4];
public System.Web.UI.WebControls.Label Status = new System.Web.UI.WebControls.Label();

void Page_Load(object sender, System.EventArgs e)
{
for (int i = 0; i < ResultImages.Length;i++) {
ResultImages[i] = new System.Web.UI.WebControls.Image();
Controls.AddAt(Controls.Count - 1, ResultImages[i]);
}
Controls.AddAt(Controls.Count - 1, Status);
}

void SubmitFiles(Object sender, EventArgs e)
{
HttpFileCollection uploadedFiles = Request.Files;
thumbtype = ThumbType.Value;
Status.Text = "<hr/><p><strong>Uploading...</strong><br/>";
string path = "";
string filename = "";

for (int i = 0; i < uploadedFiles.Count; i ++)
{
if (uploadedFiles[i].FileName!="") {
filename = "upload/" + uploadedFiles[i].FileName + ".thumb." + thumbtype;
Status.Text += "<span class=\"status\">" + filename + " uploaded</span><br/>";
Resize(uploadedFiles[i],filename);
ResultImages[i].ImageUrl = filename;
}
else
{
ResultImages[i].ImageUrl = "";
Status.Text += "<span class=\"status\">" + "No file specified in field " + (i+1) + "</span><br/>";
}
}
Status.Text += "</p><hr/>";

}

void Resize(HttpPostedFile file, string filename)
{
try {
wbResize ImageResizer = new wbResize();

ImageResizer.LoadImage(file.InputStream); //accetta path, image e stream
ImageResizer.SetFileType(thumbtype); //Tipo di output [jpg, gif, bmp, tiff, png]
ImageResizer.SetThumbSize(500, 500, false); //Width, Height e forzatura
//ImageResizer.SetThumbSize(50); //IMPOSTA LA % DELL'ORIGINALE

ImageResizer.SetOptionHighQuality(true); //Alta qualità
ImageResizer.SetOptionJpegQuality(100); //Qualità JPEG
ImageResizer.SetOptionFilter(InterpolationMode.HighQualityBicubic); //Filtro di Interpolazione
ImageResizer.SetOptionGifDepth(4); //Profondità colore GIF [0 = off, 1, 2, 4, 8, 255 = grayscale]
ImageResizer.SetOptionGifPalette(255); //Dimensione Palette GIF [9-255]
ImageResizer.SetOptionTiffCompress(true); //Compressione TIFF

/* DATI IN STREAM */
//MemoryStream stream = ImageResizer.Resize();

/* SALVATAGGIO SU PATH */
ImageResizer.ResizeAndSave(Server.MapPath(filename));
Status.Text += "<span class=\"status\">" + filename + " resized [" + ImageResizer.Report("size") + "]</span><br/>";
}
catch
{
Status.Text += "<span class=\"error\">" + filename + " resize error</span><br/>";
}
}
Binary file added dotnet/upload/sample.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7531893

Please sign in to comment.