Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    resize.aspx di immagini

    salve a tutti.
    sto utilizzando la seguente classe, contenuta nel file resize.aspx:

    <%@ import namespace="System" %>
    <%@ import namespace="System.Drawing" %>
    <%@ import namespace="System.Drawing.Imaging" %>
    <%@ import namespace="System.IO" %>

    <script runat="server">

    Function NewthumbSize(currentwidth, currentheight)
    ' Calculate the Size of the New image
    dim k,a,b,c,d as Double
    k=currentwidth/currentheight
    a=currentwidth
    b=currentheight
    c=Request.QueryString("h")
    d=Request.QueryString("w")

    if (k>1) then
    a=d
    b=d/k
    else
    a=c*k
    b=c
    end if

    dim NewSize as New Size(a, b)
    return NewSize
    End Function


    Sub sendFile()
    ' create New image and bitmap objects. Load the image file and put into a resized bitmap.
    dim g as System.Drawing.Image = System.Drawing.Image.FromFile(server.mappath(reque st("src")))
    dim thisFormat=g.rawformat
    dim thumbSize as New size
    thumbSize=NewthumbSize(g.width,g.height)
    dim imgOutput as New Bitmap(g, thumbSize.width, thumbSize.height)

    ' send the resized image to the viewer
    imgOutput.save(response.outputstream, thisformat) ' output to the user

    ' tidy up
    g.dispose()
    imgOutput.dispose()

    end sub

    Sub sendError()

    ' if no height, width, src then output "error"
    dim imgOutput as New bitmap(120, 120, pixelformat.format24bpprgb)
    dim g as graphics = graphics.fromimage(imgOutput)
    'create a New graphic object from the above bmp
    g.clear(color.yellow) ' blank the image
    g.drawString("ERRORE!", New font("verdana",14,fontstyle.bold),systembrushes.wi ndowtext,new pointF(2,2))

    ' Set the contenttype
    response.contenttype="image/jpeg"

    ' send the resized image to the viewer
    imgOutput.save(response.outputstream, imageformat.jpeg) ' output to the user

    ' tidy up
    g.dispose()
    imgOutput.dispose()

    end sub


    </script>

    <%
    ' make sure Nothing has gone to the client
    response.clear

    if request("src")="" then
    call sendError()
    else

    if file.exists(server.mappath(request("src"))) then
    call sendFile()
    else
    call sendError()
    end if

    end if

    response.end
    %>

    e funziona a meraviglia, soltanto che ha due problemi:
    1. non va con le gif
    2. non va con immagini presenti su altri server.

    c'e' qualcuno che ha ovviato a tali difetti?
    grazie.
    riccardo - milano.

  2. #2
    per il discorso delle gif ci si può lavorare.
    per il discorso "altri server" puoi fargli anche ciao ciao con la mamina, perchè è impossibile fare una cosa del genere su un altro server

  3. #3

    altro server

    grazie per la risposta.
    La questione dell'immagine su altro server:
    se si utilizzasse la stessa tecnologia per creare l'immagine in miniatura per "prelevare" l'immagine e poi elaborarla a piacimento?

  4. #4
    Ho risolto la questione delle gif.
    Occorre aggiungere all'inizio:
    <%@ Import Namespace="System.Drawing.Imaging.ImageFormat"%>
    e poi mettere:

    ' Set the contenttype
    if thisformat.equals(system.drawing.imaging.imageform at.Gif) then
    response.contenttype="image/gif"
    else
    response.contenttype="image/jpeg"
    end if

    Rimane la questione delle immagini presenti su altro server

  5. #5
    potremmo provare a leggere le img e fare un resize durante lo stream. non so sinceramente non la vedo impossibile.. non ho molto tempo altrimenti ti avrei aiutato

    cmq fammi sapere! conta sul mio aiuto per eventuali problemi!

  6. #6
    grazie, grazie.

    sto leggendo la documentazione del framework, e per ora ho provato questo:

    Sub sendFile()
    ' initialise the web object
    Dim webClient As New System.Net.WebClient()

    ' set the URL
    Dim strFilename as string
    strFilename="http://www.sito.it/cartella/immagine.gif"

    ' create a bitmap based on the image from the URL
    Dim g = New

    System.Drawing.Bitmap(webClient.OpenRead(strFilena me))


    ma non riesce a leggere il flusso di dati corrispondente all'immagine richiamata nella stringa strFilename.

    Devo studiare ancora...

  7. #7
    è possibile con questo script
    SALVARE la miniatura sul server anzicchè visualizzarla sul browser?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.