Salta al contenuto
  • CATEGORIES
  • La Community Connect.gt
  • Presentati alla Community
  • News Ufficiali da Connect.gt
  • Internet News
  • A Scuola Di
  • Digital Marketing
  • Intelligenza Artificiale
  • SEO & GEO
  • Web Marketing e Content
  • Google Analytics e Web Analytics
  • Google Ads & Advertising
  • YouTube
  • TikTok, Instagram e altri Social
  • Google Adsense, Affiliazioni e Guadagno
  • E-Commerce
  • Coding e Sistemistica
  • Help Center: consigli per il tuo progetto
  • Hosting e Cloud
  • Coding
  • CMS & Piattaforme Self-Hosted
  • Annunci e Collaborazioni
  • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
  • Collaborazioni WEB e Lavoro: offro e cerco
  • Impresa, Fisco e Leggi
  • Consulenza Legale e Professioni Web
  • Consulenza Fiscale, Imprese, Startup e P.Iva
  • Gli Off Topic
  • PC, Smartphone e altri Hardware
  • Tutti i Software
  • GT Fetish Cafè
  • Discussioni
  • 0 Non letti 0
  • Recenti
  • Hashtag
  • Popolare
  • Utenti
  • Privacy
  • Termini e condizioni
  • © 2026 Search On Media Group S.r.l.
Collassa
Connect.gt
Il network Search On
Connect.gt WMF AI Festival Accademia Advanced SEO Tool AgentCy Social Media Strategies Search Tech
Registrati Accedi
Connect.gt
Stream Interest Categorie Hashtag
  1. La community italiana di SEO, marketing digitale e AI
  2. Categorie
  3. Coding e Sistemistica
  4. Coding
  5. thumbnails su galleria dinamica

thumbnails su galleria dinamica

Pianificato Fissato Bloccato Spostato Coding
12 Post 2 Autori 2.8k Visualizzazioni 1 Seguito
  • Da Vecchi a Nuovi
  • Da Nuovi a Vecchi
  • Più Voti
Rispondi
  • Risposta alla discussione
Effettua l'accesso per rispondere
Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
  • B
    B
    bormiositi
    scritto su ultima modifica di
    User Attivo 0
    #2

    ok, ok, cerco di riproporre il problema in un'altra maniera.

    Ho trovato il seguente script che mi permette di creare le miniature delle immagini che compongono la mia galleria:

    <%@ Page Language="VB" %>
    <%@ Import Namespace="System" %>
    <%@ Import Namespace="System.IO" %>
    <%@ Import Namespace="System.Web" %>
    <%@ Import Namespace="System.Drawing" %>
    <script runat="server">
          'Limite massimo per l'altezza in pixel
        Private Const MaxHeightSafe As Integer = 600
        'Limite massimo per la larghezza in pixel
        Private Const MaxWidthSafe As Integer = 800
        'Percorso dell'immagine su cui reindirizzare le richieste non valide
        Private Const ErrorImagePath As String = "/error.jpg"
        'Percorso in cui salvare le copie delle immagini, il percorso indicato deve avere i permessi in scrittura
        Private Const ImageCachePath As String = "/public/tempfiles"
        'Salva su disco una copia riutilizzabile delle thumbnails create
        Private Const UseCache As Boolean = True
        'Di seguito sono riportati i valori predefiniti che verranno utilizzati quando non vengono specificati parametri
        Private Const DefaultHeight As Integer = 600
        Private Const DefaultWidth As Integer = 800
        Private Const DefaultResizeMode As ResizeMode = ResizeMode.AutoResize
        Private Const AllowCustomFormat As Boolean = False 'Impostare a False per ignorare il parametro del formato, True per utilizzarlo
        Private Const AllowCustomQuality As Boolean = False 'Impostare a False per ignorare il parametro della qualità, True per utilizzarlo
        Private Const MinQuality As Long = 10 'Qualità minima
        Private Const DefaultQuality As Long = 30 'Qualità predefinita
        Private Const MaxQuality As Long = 100 'Qualità massima
        Private Enum ResizeMode
            AutoResize = 0
            ManualResize = 1
        End Enum
        Private ReadOnly Property Mode() As ResizeMode
            Get
                Dim myReqMode As String = Request.QueryString("mode")
                If myReqMode Is Nothing OrElse Not IsNumeric(myReqMode) Then Return DefaultResizeMode
                If CInt(myReqMode) = 0 Then Return ResizeMode.AutoResize Else Return ResizeMode.ManualResize
            End Get
        End Property
        Private ReadOnly Property CustomQuality() As Long
            Get
                Dim myValue As String = Request.QueryString("quality")
                If myValue Is Nothing OrElse Not IsNumeric(myValue) Then Return DefaultQuality
                Dim myNumValue As Long = CLng(myValue)
                If myNumValue > MaxQuality OrElse myNumValue < MinQuality Then
                    Return DefaultQuality
                Else
                    Return myNumValue
                End If
            End Get
        End Property
        Private ReadOnly Property MaxHeight() As Integer
            Get
                Dim myValue As String = Request.QueryString("height")
                If myValue Is Nothing OrElse Not IsNumeric(myValue) Then Return DefaultHeight
                Dim myIntValue As Integer = CInt(myValue)
                If myIntValue < MaxHeightSafe Then
                    Return myIntValue
                Else
                    Return MaxHeightSafe
                End If
            End Get
        End Property
        Private ReadOnly Property MaxWidth() As Integer
            Get
                Dim myValue As String = Request.QueryString("width")
                If myValue Is Nothing OrElse Not IsNumeric(myValue) Then Return DefaultWidth
                Dim myIntValue As Integer = CInt(myValue)
                If myIntValue < MaxWidthSafe Then
                    Return myIntValue
                Else
                    Return MaxWidthSafe
                End If
            End Get
        End Property
        Private _ImagePath As String
        Private ReadOnly Property ImagePath() As String
            Get
                If Not _ImagePath Is Nothing Then Return _ImagePath
                Dim sRequestPath As String = Request.QueryString("path")
                If sRequestPath Is Nothing Then Return Nothing
                'Rimuovo le doppie / e i doppi . con le espressioni regolari
                sRequestPath = Regex.Replace(sRequestPath, "\/{2,}", "/")
                sRequestPath = Regex.Replace(sRequestPath, "\.{2,}", ".")
                If sRequestPath.Substring(0, 1) = "/" Then sRequestPath = sRequestPath.Substring(1)
                _ImagePath = sRequestPath
                Return _ImagePath
            End Get
        End Property
        Sub Page_Load(ByVal Sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try
                Dim LocalImageFilePath As String
                Dim LocalThumbnailCacheFilePath As String
                LocalImageFilePath = Server.MapPath("/" & ImagePath)
                If Not File.Exists(LocalImageFilePath) Then
                    Response.Redirect(ErrorImagePath)
                    Exit Sub
                End If
                Dim myImageFormatString As String
                Dim myImageFormatClass As System.Drawing.Imaging.ImageFormat
                If AllowCustomFormat = False Then
                    myImageFormatString = "jpeg"
                    myImageFormatClass = System.Drawing.Imaging.ImageFormat.Jpeg
                Else
                    Dim myType As String = Request.QueryString("format")
                    If myType Is Nothing Then
                        myImageFormatClass = System.Drawing.Imaging.ImageFormat.Jpeg
                        myImageFormatString = "jpeg"
                    Else
                        Select Case myType.Trim.ToLower
                            Case "jpeg"
                                myImageFormatClass = System.Drawing.Imaging.ImageFormat.Jpeg
                                myImageFormatString = "jpeg"
                            Case "png"
                                myImageFormatClass = System.Drawing.Imaging.ImageFormat.Png
                                myImageFormatString = "png"
                            Case Else
                                myImageFormatClass = System.Drawing.Imaging.ImageFormat.Jpeg
                                myImageFormatString = "jpeg"
                        End Select
                    End If
                End If
                Dim ImageQuality As Long
                If AllowCustomQuality Then
                    ImageQuality = CustomQuality
                Else
                    ImageQuality = DefaultQuality
                End If
                Dim TempFilePath As String = Server.MapPath(ImageCachePath)
                LocalThumbnailCacheFilePath = Path.Combine(TempFilePath, ImagePath.Replace("/", "_")) & "_" & Int(Mode) & "_" & Int(MaxWidth) & "_" & Int(MaxWidth) & "_" & ImageQuality & "." & myImageFormatString & ".thumb"
                Dim mySourceFile As New System.IO.FileInfo(LocalImageFilePath)
                If UseCache Then
                    If File.Exists(LocalThumbnailCacheFilePath) Then
                        Dim myDestFile As System.IO.FileInfo
                        myDestFile = New System.IO.FileInfo(LocalThumbnailCacheFilePath)
                        'Se il file della thumbnail è stato modificato nella stessa data oppure in seguito
                        'rispetto al file sorgente allora può essere utilizzato quello
                        If myDestFile.LastWriteTime.CompareTo(mySourceFile.LastWriteTime) >= 0 Then
                            'Il file esiste e va bene
                            Response.ContentType = "image/" & myImageFormatString
                            Response.WriteFile(myDestFile.FullName)
                            Exit Sub
                        Else
                            'Il file esiste ma è vecchio e va sostituito
                            myDestFile.Delete()
                        End If
                    End If
                End If
                Dim orginalimg As System.Drawing.Image
                Try
                    orginalimg = System.Drawing.Image.FromFile(mySourceFile.FullName)
                Catch
                    Response.Redirect(ErrorImagePath)
                    Exit Sub
                End Try
                Dim ThumbnailWidth, ThumbnailHeight As Integer
                Select Case Mode
                    Case ResizeMode.AutoResize
                        ' ResizeMode.AutoResize: Ridimensiona l'immagine per restare nei limiti impostati, mantenendo le proporzioni
                        Dim myRatio As Double = orginalimg.Width / orginalimg.Height
                        If myRatio > 1 Then 'La larghezza è maggiore dell'altezza, quindi fisso l'altezza e calcolo il resto
                            ThumbnailHeight = MaxHeight
                            ThumbnailWidth = orginalimg.Width / orginalimg.Height * MaxHeight
                        ElseIf myRatio < 1 Then 'L'altezza è maggiore della larghezza, quindi fisso la larghezza e calcolo il resto
                            ThumbnailWidth = MaxWidth
                            ThumbnailHeight = orginalimg.Height / orginalimg.Width * MaxWidth
                        ElseIf myRatio = 1 Then 'Larghezza = Altezza
                            ThumbnailWidth = MaxWidth
                            ThumbnailHeight = MaxHeight
                        End If
                    Case ResizeMode.ManualResize
                        ' ResizeMode.ManualResize: Ridimensiona con le misure indicate nei parametri
                        ThumbnailWidth = MaxWidth
                        ThumbnailHeight = MaxHeight
                End Select
                Response.ContentType = "image/" & myImageFormatString
                Dim panel As Bitmap
                panel = New Bitmap(ThumbnailWidth, ThumbnailHeight, Imaging.PixelFormat.Format24bppRgb)
                Dim g As Graphics = Graphics.FromImage(panel)
                g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
                g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
                g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
                g.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
                g.DrawImage(orginalimg, 0, 0, ThumbnailWidth, ThumbnailHeight)
                Dim stream As System.IO.Stream = Response.OutputStream
                Dim MemStream As New System.IO.MemoryStream()
                If myImageFormatClass.Equals(System.Drawing.Imaging.ImageFormat.Jpeg) Then
                    Dim Info() As System.Drawing.Imaging.ImageCodecInfo = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders
                    Dim Params As New System.Drawing.Imaging.EncoderParameters(1)
                    Params.Param(0) = New System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, ImageQuality)
                    panel.Save(MemStream, Info(1), Params)
                Else
                    panel.Save(MemStream, myImageFormatClass)
                End If
                g.Dispose()
                panel.Dispose()
     
                If UseCache Then
                    Dim myS As New IO.FileStream(LocalThumbnailCacheFilePath, IO.FileMode.CreateNew)
                    MemStream.WriteTo(myS)
                    myS.Close()
                    Response.WriteFile(LocalThumbnailCacheFilePath)
                Else
                    MemStream.WriteTo(Response.OutputStream)
                End If
                orginalimg.Dispose()
                MemStream.Close()
                MemStream.Dispose()
            Catch ex As Exception
                Response.Redirect(ErrorImagePath)
            End Try
        End Sub
    </script>
    

    Le miniature appunto vengo generate nella pagina Asp della galleria mediante il seguente indirizzo

    advancedresizetool.aspx?format=[COLOR=blue][I]jpeg[/I][/COLOR]&quality=[COLOR=blue][I]40[/I][/COLOR]&mode=[COLOR=blue][I]0[/I][/COLOR]&width=[COLOR=blue][I]200[/I][/COLOR]&height=[COLOR=blue][I]150[/I][/COLOR]&path=[COLOR=blue][I]/immagini/miafoto.jpg[/I][/COLOR]
    

    Come faccio ad inserire nel precedente indirizzo il path di una immagine il cui percorso è salvato in un campo di tabella su db access?

    Ovvero, devo inserire l'indirizzo sopra nel seguente script nel primo img src:

    <% if rs("immg1")<>"" then
    response.write ("<a href=public"&rs("immg1")&" rel='lightbox[ciao]'><[B]img src='public"&rs("immg1")&"[/B]' id='resizable_1' border='0'/></a>")
    else
    response.write ("<img src='images/all.gif'>")
    end if
    %>
    

    al posto dell'attuale img src.

    Potreste gentilmente aiutarmi?

    Grazie

    1 Risposta Ultima Risposta
    Miglior risposta 0
    0
    • C
      C
      cali1981
      scritto su ultima modifica di
      Super User 20
      #3

      Se ho capito bene su rs("immg1") c'è il path dell'immagine, non potresti inserire quel campo dinamico nell'url che hai indicato sopra?

      1 Risposta Ultima Risposta
      Miglior risposta 0
      0
      • B
        B
        bormiositi
        scritto su ultima modifica di
        User Attivo 0
        #4

        grazie cali per l'interessamento.

        E' proprio quello il problema, non so come fare, ho provato così ma non funziona...

         <% if rs("immg2")<>"" then
        response.write ("<a href=public"&rs("immg2")&" rel='lightbox[ciao]'>[B]<img src='resize_ok.aspx?format=jpeg&quality=40&mode=0&width=200&height=150&path=/immagini/<%=rs("immg2")%>'/>[/B]</a>")
        else
        response.write ("<img src='images/all.gif'>")
        end if
        %>
        
        1 Risposta Ultima Risposta
        Miglior risposta 0
        0
        • C
          C
          cali1981
          scritto su ultima modifica di
          Super User 20
          #5

          Non funziona che vuol dire? Da un indirizzo errato e errore?

          1 Risposta Ultima Risposta
          Miglior risposta 0
          0
          • B
            B
            bormiositi
            scritto su ultima modifica di
            User Attivo 0
            #6

            ok, ho risolto così

            response.write ("<a href=public"&rs("immg2")&" rel='lightbox[ciao]'><img src='resize_ok.aspx?format=jpeg&quality=40&mode=0&width=100&height=150&path=/immagini/"& rs("immg2") &"'/></a>")
            

            ora però il problema è che non vedo proprio la miniatura con le dimensioni indicate nella stringa ma vedo solo una barretta verticale...

            Non mastico nulla di asp .net con cui è scritto lo script che fa il resize al volo.

            Riusciresti ad indicarmi dove devo dargli le dimensioni della larghezza a cui voglio resizare le img?

            1 Risposta Ultima Risposta
            Miglior risposta 0
            0
            • C
              C
              cali1981
              scritto su ultima modifica di
              Super User 20
              #7

              Vuol dire penso che non crea l'immagine, quello script non so come funziona, dovresti innanzitutto vedere se l'url dell'immagine è giusto, cioè se l'url creto da /immagini/"& rs("immg2") è in effetti un'immagine valida. Puoi scrivere qui sotto l'url generato?

              1 Risposta Ultima Risposta
              Miglior risposta 0
              0
              • B
                B
                bormiositi
                scritto su ultima modifica di
                User Attivo 0
                #8

                dove lo vedo l'url generato?

                1 Risposta Ultima Risposta
                Miglior risposta 0
                0
                • C
                  C
                  cali1981
                  scritto su ultima modifica di
                  Super User 20
                  #9

                  Nel codice html della pagina.

                  1 Risposta Ultima Risposta
                  Miglior risposta 0
                  0
                  • B
                    B
                    bormiositi
                    scritto su ultima modifica di
                    User Attivo 0
                    #10

                    scusa ma non lo trovo, non capisco

                    1 Risposta Ultima Risposta
                    Miglior risposta 0
                    0
                    • C
                      C
                      cali1981
                      scritto su ultima modifica di
                      Super User 20
                      #11

                      Scusa ma tu quel codice dove lo stai mettendo? Dentro una pagina asp no? E poi come la testi? Aprendola nel browser immagino no? Ok, nella pagina dove vedi la barretta verticale, vedi il sorgente html, li dentro da qualche parte c'è <a href=public...> <img src='resize_ok.asp?.... Io vorrei vedere quel codice html, oppure avere un link alla pagina se è online.

                      1 Risposta Ultima Risposta
                      Miglior risposta 0
                      0
                      • B
                        B
                        bormiositi
                        scritto su ultima modifica di
                        User Attivo 0
                        #12

                        ok cali, sono riuscito a sistemare, era semplicemente sbagliato il path --> puntava ad un'altra cartella dove ovviamente non trovava nulla.

                        Ti ringrazio per la pazienza e per il prezioso aiuto.

                        Grazie ancora!!!!!!

                        1 Risposta Ultima Risposta
                        Miglior risposta 0
                        0

                        Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.

                        Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.

                        Con il tuo contributo, questo post potrebbe essere ancora migliore 💗

                        Registrati Accedi
                        Rispondi
                        • Risposta alla discussione
                        Effettua l'accesso per rispondere
                        • Da Vecchi a Nuovi
                        • Da Nuovi a Vecchi
                        • Più Voti


                        • Accedi

                        • Non hai un account? Registrati

                        • Accedi o registrati per effettuare la ricerca.
                        • Primo post
                          Ultimo post
                        Home Accedi Registrati
                        Menu
                        • CATEGORIES
                        • La Community Connect.gt
                        • Presentati alla Community
                        • News Ufficiali da Connect.gt
                        • Internet News
                        • A Scuola Di
                        • Digital Marketing
                        • Intelligenza Artificiale
                        • SEO & GEO
                        • Web Marketing e Content
                        • Google Analytics e Web Analytics
                        • Google Ads & Advertising
                        • YouTube
                        • TikTok, Instagram e altri Social
                        • Google Adsense, Affiliazioni e Guadagno
                        • E-Commerce
                        • Coding e Sistemistica
                        • Help Center: consigli per il tuo progetto
                        • Hosting e Cloud
                        • Coding
                        • CMS & Piattaforme Self-Hosted
                        • Annunci e Collaborazioni
                        • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
                        • Collaborazioni WEB e Lavoro: offro e cerco
                        • Impresa, Fisco e Leggi
                        • Consulenza Legale e Professioni Web
                        • Consulenza Fiscale, Imprese, Startup e P.Iva
                        • Gli Off Topic
                        • PC, Smartphone e altri Hardware
                        • Tutti i Software
                        • GT Fetish Cafè
                        • Discussioni
                        • Non letti 0
                        • Recenti
                        • Hashtag
                        • Popolare
                        • Utenti
                        • Privacy
                        • Termini e condizioni
                        • © 2026 Search On Media Group S.r.l.