Foros del Web » Programando para Internet » ASP Clásico »

Cambiar tamaño de imagen (thumbail)

Estas en el tema de Cambiar tamaño de imagen (thumbail) en el foro de ASP Clásico en Foros del Web. Bueno pues lo que quiero es cambiar el tamaño de una imagen JPG subida por el usuario, es decir quiero crear una imagen pequeñita de ...
  #1 (permalink)  
Antiguo 08/02/2006, 16:07
Avatar de hanscruz  
Fecha de Ingreso: junio-2005
Mensajes: 278
Antigüedad: 19 años
Puntos: 0
Cambiar tamaño de imagen (thumbail)

Bueno pues lo que quiero es cambiar el tamaño de una imagen JPG subida por el usuario, es decir quiero crear una imagen pequeñita de la que suba por ejemplo si es de 1000x1000 u otra crear otra de 50x50, pero no quiero usar el ASPJPGE ya que es de pago, en una anterior ocasion cuando busque informacion sobre el ASPUpload encontre un post donde se hablaba de un script para cambiar el tamaño que era gratuito pero ya busque y no doy con dicho post.

Tambien busque en hotsripts pero los que encontre aunque sean gratuitos necesitan instalarse o grabar una .dll. espero su ayuda pues lo necesito urgen

Saludos.
__________________
:policia:
  #2 (permalink)  
Antiguo 08/02/2006, 17:21
Avatar de sjam7  
Fecha de Ingreso: diciembre-2001
Ubicación: Guadalajara, Mexico
Mensajes: 3.672
Antigüedad: 22 años, 5 meses
Puntos: 16
creo que sin componentes solo podras hacerlo con asp.net, busca aqui en el foro
  #3 (permalink)  
Antiguo 08/02/2006, 17:45
Avatar de hanscruz  
Fecha de Ingreso: junio-2005
Mensajes: 278
Antigüedad: 19 años
Puntos: 0
Y se puede mezclar paginas asp con asp.net? funciona normal
__________________
:policia:
  #4 (permalink)  
Antiguo 09/02/2006, 01:39
 
Fecha de Ingreso: noviembre-2002
Ubicación: DF
Mensajes: 1.056
Antigüedad: 21 años, 6 meses
Puntos: 37
Si puedes usar ambas no importa, con tal que el hosting tenga configurado el .net. , yo he probado el thumbnailer que puede generarse con .net y es realmente eficaz.
El code va mas o menos asi:

<%@ 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 = 100;
int reqWidth = 100;
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 if (origBitmap.Height >= origBitmap.Width){
//Portrait
newHeight = reqHeight;
newWidth = (int)(((double)origBitmap.Width / (double)origBitmap.Height) * reqHeight);
}
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);

//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{
Response.Redirect("galleryImages/thumberror.gif");
}
}
</script>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:18.