Ver Mensaje Individual
  #4 (permalink)  
Antiguo 25/11/2009, 11:31
Avatar de pempas
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!