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

ASPJpeg sin componentes

Estas en el tema de ASPJpeg sin componentes en el foro de ASP Clásico en Foros del Web. Hola, quería saber si existe alguna forma de subir imágenes y cambiarles el tamaño si no existe un componente en el hosting tipo ASPJpeg. Mi ...
  #1 (permalink)  
Antiguo 24/11/2009, 05:33
Avatar de PosProdukcion  
Fecha de Ingreso: noviembre-2004
Ubicación: Manzanares el Real (Madrid)
Mensajes: 726
Antigüedad: 20 años, 5 meses
Puntos: 9
ASPJpeg sin componentes

Hola, quería saber si existe alguna forma de subir imágenes y cambiarles el tamaño si no existe un componente en el hosting tipo ASPJpeg.

Mi cliente no ve claro lo de pagar más por un hosting teniendo este de 1 and 1, que está muy bien con la única pega de que no tiene un componente para imágenes...

¿Sabéis alguna forma de hacer lo mismo sin componente?

Muchas gracias
  #2 (permalink)  
Antiguo 24/11/2009, 07:46
Avatar de Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 18 años, 3 meses
Puntos: 126
Respuesta: ASPJpeg sin componentes

Hola

Tienes XelUpload pero creo que no te permite ni cambiar el tamaño ni renombrar los archivos

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />
  #3 (permalink)  
Antiguo 24/11/2009, 12:49
Avatar de sjam7  
Fecha de Ingreso: diciembre-2001
Ubicación: Guadalajara, Mexico
Mensajes: 3.672
Antigüedad: 23 años, 4 meses
Puntos: 16
Respuesta: ASPJpeg sin componentes

pues checa si soporta asp.net y con ese puedes hacer algun script (o bajarlo) y se puede hacer, yo asi lo hice una vez, solo que no encuentro el archivo .net que use
  #4 (permalink)  
Antiguo 25/11/2009, 11:31
Avatar de pempas  
Fecha de Ingreso: diciembre-2003
Ubicación: Barcelona
Mensajes: 985
Antigüedad: 21 años, 4 meses
Puntos: 6
Respuesta: ASPJpeg sin componentes

Hola, si el hosting soporte .net, puedes usar este script que utilizo yo y me va de fábula:

Código PHP:
<%@ Page Language="VB" Debug="true" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ 
Import Namespace="system.drawing" %>
<%@
Import Namespace="System.Drawing.Drawing2D" %>
<%
' Initialize objects
Dim objImage, objThumbnail As System.Drawing.Image
Dim strServerPath, strFilename As String
Dim shtWidth, shtHeight, MaxHeight, Coefficient, W, H As Short
Dim Forma, MaxWidth
Dim PathNormal, PathThumb, PathGaleria
Get image folder path on server - use "\" string if root
strServerPath = "
Ruta de la carpeta temporal donde está la imagen"
PathNormal = "
Ruta de la carpeta donde irá la foto"
PathThumb = "
Ruta de la carpeta donde irá el thumb" & "thumb"
 
' Retrieve name of file to resize from query string
If Request.QueryString("
img")<>"" Then
 Dim images as String
 images = Replace(Request.QueryString("
img"), "/", "")
 If Mid(images, 1, 1)="" Then 
  images = Mid(images, 2, Len(images))
 End If
 strFilename = Request.ServerVariables("
APPL_PHYSICAL_PATH") & images
Else
 If Instr(1, Request.QueryString("
file"), ":")>0 Then
  strFilename = Request.QueryString("
file")
 Else
  strFilename = strServerPath & Request.QueryString("
file")
 End If
End If
' Retrieve file, or error.gif if not available
Try
    objImage = objImage.FromFile(strFilename)
Catch
    objImage = objImage.FromFile(strServerPath & "
nombre de la imagen NO DISPONIBLE")
End Try
' Retrieve width from query string
If Request.QueryString("
width") = Nothing Then
    shtWidth = objImage.Width
ElseIf Request.QueryString("
width") < 1 Then
    shtWidth = 640
Else
    shtWidth = Request.QueryString("
width")
 W = Request.QueryString("
width")
End If
If Request.QueryString("
height") = Nothing Then
    shtHeight = objImage.Height
ElseIf Request.QueryString("
height") < 1 Then
    shtHeight = 480
Else
    shtHeight = Request.QueryString("
height")
 H = Request.QueryString("
height")
End If
MaxHeight=objImage.Height
MaxWidth=objImage.Width
If shtWidth<MaxWidth And Request.QueryString("
width")<>"" Then 'Si la imagen es mayor que la redimensión
 shtHeight=Cint((MaxHeight / MaxWidth) * shtWidth)
 
ElseIf shtHeight<MaxHeight And Request.QueryString("
height")<>"" Then 'Si la imagen es mayor que la redimensión
 shtWidth=Cint((MaxWidth / MaxHeight) * shtHeight)
 if request.QueryString("
w")<>"" Then
  If Clng(Request.QueryString("
w"))<Clng(shtWidth) Then
   shtHeight=Cint((MaxHeight / MaxWidth) * Request.QueryString("
w"))
   shtWidth=Request.QueryString("
w")
  End If
 end If
Else
 If shtHeight>MaxHeight And Request.QueryString("
w")<>"" Then
  shtHeight=Cint((MaxHeight / MaxWidth) * Request.QueryString("
w"))
  shtWidth=Request.QueryString("
w")
 Else
  shtWidth=MaxWidth
  shtHeight=MaxHeight
 End If
End If
 
' Create thumbnail
objThumbnail = objImage.GetThumbnailImage(shtWidth, _
  shtHeight, Nothing, System.IntPtr.Zero)
If shtWidth > 150 Or shtHeight > 150 Then
 Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(objThumbnail)
 Dim StringSizeF as SizeF
 Dim DesiredWidth as Single, wmFont as Font, RequiredFontSize as Single, Ratio as Single
 Dim strWatermark = "
."
 'If Request.QueryString("
eff")="1" Then strWatermark="."
 'Seteamos la fuente.
 wmFont = New Font("
Tahoma", 2, FontStyle.Bold)
 DesiredWidth = shtWidth * .5
 StringSizeF = g.MeasureString(strWatermark, wmFont)
 Ratio = StringSizeF.Width / wmFont.SizeInPoints
 RequiredFontSize = DesiredWidth / Ratio
 wmFont = New Font("
Verdana", RequiredFontSize, FontStyle.Bold)
 g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
 g.DrawImage(objImage, 0, 0, shtWidth, shtHeight)
 g.SmoothingMode = SmoothingMode.HighQuality 
 Dim letterBrush as SolidBrush = new SolidBrush(Color.FromArgb(50, 255, 255, 255))
 Dim shadowBrush as SolidBrush = new SolidBrush(Color.FromArgb(50, 0, 0, 0)) 
 g.DrawString(strWatermark, wmFont, shadowBrush, 75, (shtHeight * .5) - 1800)
 g.DrawString(strWatermark, wmFont, letterBrush, 77, (shtHeight * .5) - 1802)
End If
 
' Send down to client
Response.ContentType = "
image/jpeg"
If Request.QueryString("
tipo")="normal" Then
 objThumbnail.Save(PathNormal & Request.QueryString("
nombre"), System.Drawing.Imaging.ImageFormat.Jpeg)
ElseIf Request.QueryString("
tipo")="thumb" Then
 objThumbnail.Save(PathThumb & "
t" & Request.QueryString("nombre"), System.Drawing.Imaging.ImageFormat.Jpeg)
Else
 objThumbnail.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
End If
' Tidy up
objImage.Dispose()
objThumbnail.Dispose()
%> 
Este script te permite redimensionar al vuelo las imágenes y redimensionarlas y guardarlas en una carpeta.

Para redimensionar al vuelo, tan solo has de enlazarlo así:

Código PHP:
resize.aspx?img=/fotos/imagen.jpg&height=100&w=140 
El valor "height" y "w" son para el Width y el Heigt respectivamente.

Si lo que quieres es redimensionarla y guardarla en la carpeta:

Código PHP:
resize.aspx?file=/tmp/imagen.jpg&width=Ancho&tipo=normal 
Y para un thumb:

Código PHP:
resize.aspx?file=/tmp/imagen.jpg&width=Ancho&tipo=thumb 
Espero te sirva y te aclares.

Un saludo!
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 22:44.