Ver Mensaje Individual
  #6 (permalink)  
Antiguo 04/02/2009, 21:27
Avatar de sjam7
sjam7
 
Fecha de Ingreso: diciembre-2001
Ubicación: Guadalajara, Mexico
Mensajes: 3.672
Antigüedad: 22 años, 4 meses
Puntos: 16
Respuesta: fotos se ven mal

Bueno mira, te paso los codigos

El del .net seria asi:
[highlight=asp]<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
try{
Response.Cache.VaryByParams["Image;Width;Height;ForceAspect"] = true;
Response.ContentType = "image/jpeg";
System.Collections.Hashtable imageOutputFormatsTable = new System.Collections.Hashtable();
imageOutputFormatsTable.Add(System.Drawing.Imaging .ImageFormat.Gif.Guid, System.Drawing.Imaging.ImageFormat.Gif);
imageOutputFormatsTable.Add(System.Drawing.Imaging .ImageFormat.Jpeg.Guid, System.Drawing.Imaging.ImageFormat.Jpeg);
imageOutputFormatsTable.Add(System.Drawing.Imaging .ImageFormat.Bmp.Guid, System.Drawing.Imaging.ImageFormat.Gif);
imageOutputFormatsTable.Add(System.Drawing.Imaging .ImageFormat.Tiff.Guid, System.Drawing.Imaging.ImageFormat.Jpeg);
imageOutputFormatsTable.Add(System.Drawing.Imaging .ImageFormat.Png.Guid, System.Drawing.Imaging.ImageFormat.Jpeg);

string imageLocation;
bool forceaspect = true;
int newHeight;
int newWidth;
int reqHeight = 50;
int reqWidth = 50;
int origHeight;
int origWidth;

imageLocation = Server.MapPath(Request.QueryString["Image"]);
if (Request.QueryString["Height"] != null){
reqHeight = Convert.ToInt32(Request.QueryString["Height"]);
}
if (Request.QueryString["ForceAspect"] != null){
forceaspect = Convert.ToBoolean(Request.QueryString["ForceAspect"]);
}
if(Request.QueryString["Width"] != null){
reqWidth = Convert.ToInt32(Request.QueryString["Width"]);
}
if (Request.QueryString["ForceAspect"] == "true"){
forceaspect = true;
}

System.Drawing.Bitmap origBitmap = new System.Drawing.Bitmap(imageLocation);
origHeight = origBitmap.Height;
origWidth = origBitmap.Width;

if (forceaspect){
//Force Aspect Change
newHeight = reqHeight;
newWidth = reqWidth;
}
else{
//Landscape
newWidth = reqWidth;
newHeight = (int)(((double)origBitmap.Height / (double)origBitmap.Width) * reqWidth);
}

System.Drawing.Bitmap outputImage = new System.Drawing.Bitmap(origBitmap, newWidth, newHeight);
//outputImage.SetResolution(24, 24); //use this line for lower resolution thumbnails
outputImage.SetResolution(10, 10);

//outputImage.InterpolationMode = InterpolationMode.HighQualityBicubic;
System.Drawing.Imaging.ImageFormat outputFormat = (System.Drawing.Imaging.ImageFormat)imageOutputFor matsTable[origBitmap.RawFormat.Guid];

outputImage.Save(Response.OutputStream, outputFormat);
outputImage.Dispose();
origBitmap.Dispose();
}
catch (Exception ex){
//log error so we may know the problem. you need to have write permits, of course on log path
System.IO.StreamWriter sw=null;
try{
sw=new System.IO.StreamWriter(Server.MapPath("error.txt") ,true);
sw.WriteLine("Error : " + ex.Message + " processing " + Request.QueryString["Image"]);
}
catch{}
finally{sw.Close();}
//now display the error image
Response.Redirect("thumberror.gif");
}
}
</script>[
/highlight]

y su tu servidor soporta el componente ASPJPEG podrias usar algo asi:
[highlight=asp]<%
Response.Expires = 0
imagen=request("imagen")

' create instance of AspJpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")

' Open source file
Jpeg.Open Server.MapPath("admin\productos\"&imagen)

' Set new height and width
Jpeg.Width = Request("ancho")
Jpeg.Height = Request("alto")

if Jpeg.Height="" then
Jpeg.Height = Jpeg.OriginalHeight * Jpeg.Width / Jpeg.OriginalWidth
else
Jpeg.Width = Jpeg.OriginalWidth * Jpeg.Height / Jpeg.OriginalHeight
end if

Jpeg.Interpolation = 2
Jpeg.Quality=80
Jpeg.SendBinary
%>[
/highlight]