Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Risoluzione immagini

  1. #1

    Risoluzione immagini

    Ciao a tutti, sto cercando di risolvere questo problema:
    Devo visualizzare le dimensioni (possibilmente in cm quadri) delle immagini residenti sul mio server. Ora, ho scaricato uno splendido script che mi "estrae" la dimensione in pixel e fino qui, ok. Dovrei a questo punto fare una conversione dei dati da pixel a centimetri e per fare questa operazione ho bisogno di sapere anche la risoluzione effettiva dell'immagine. Diciamo che in linea di massima le immagini sono sempre a 300 Dpi ma può succedere che mi vengano fornite img con risoluzioni diverse e quindi da qui nasce la mia necessità di gestire la cosa in modo più "intelligente".

    Posto il codice per estrarre le dimensioni, se poi qualche anima pia mi aiuta.....grassie!

    codice:
    <% 
     function GetBytes(flnm, offset, bytes) 
          on error resume next 
          Set objFSO = CreateObject("Scripting.FileSystemObject") 
          Set objFTemp = objFSO.GetFile(flnm) 
          lngSize = objFTemp.Size 
          set objFTemp = nothing 
          fsoForReading = 1 
          Set objTextStream = objFSO.OpenTextFile(flnm, fsoForReading) 
          if offset > 0 then 
             strBuff = objTextStream.Read(offset - 1) 
          end if 
          if bytes = -1 then 
             GetBytes = objTextStream.Read(lngSize) 
          else 
             GetBytes = objTextStream.Read(bytes) 
          end if 
          objTextStream.Close 
          set objTextStream = nothing 
          set objFSO = nothing 
       end function 
    
    
      function lngConvert(strTemp) 
         lngConvert = clng(asc(left(strTemp, 1)) + ((asc(right(strTemp, 1)) * 256))) 
      end function 
    
    
      function lngConvert2(strTemp) 
         lngConvert2 = clng(asc(right(strTemp, 1)) + ((asc(left(strTemp, 1)) * 256))) 
      end function 
    
    
      function gfxSpex(flnm, width, height, depth, strImageType) 
          gfxSpex = False 
          strType = GetBytes(flnm, 0, 3) 
            strBuff = GetBytes(flnm, 0, -1) 
            lngSize = len(strBuff) 
            flgFound = 0 
            strTarget = chr(255) & chr(216) & chr(255) 
            flgFound = instr(strBuff, strTarget) 
            if flgFound = 0 then 
               exit function 
            end if 
            strImageType = "JPG" 
            lngPos = flgFound + 2 
            ExitLoop = false 
            do while ExitLoop = False and lngPos < lngSize 
               do while asc(mid(strBuff, lngPos, 1)) = 255 and lngPos < lngSize 
                  lngPos = lngPos + 1 
               loop 
               if asc(mid(strBuff, lngPos, 1)) < 192 or asc(mid(strBuff, lngPos, 1))> 195 then 
                  lngMarkerSize = lngConvert2(mid(strBuff, lngPos + 1, 2)) 
                  lngPos = lngPos + lngMarkerSize  + 1 
               else 
                  ExitLoop = True 
               end if 
           loop 
           if ExitLoop = False then 
              Width = -1 
              Height = -1 
              Depth = -1 
           else 
              Height = lngConvert2(mid(strBuff, lngPos + 4, 2)) 
              Width = lngConvert2(mid(strBuff, lngPos + 6, 2)) 
              Depth = 2 ^ (asc(mid(strBuff, lngPos + 8, 1)) * 8) 
              gfxSpex = True 
           end if 
     end function 
    
    
     Set objFSO = CreateObject("Scripting.FileSystemObject") 
      'questa variabile è quella che porta il nome del file da analizzare nella funzione 
     nomefile="test.jpg" 
     Set objF = objFSO.GetFile(Server.MapPath("images/"&nomefile)) 
    
    
        if instr(ucase(objF.Name), ".JPG") then 
           'stampo i valori: tipofile,nome,datacreazione,dimensione,larghezza,altezza,colori 
        	response.write "<Table border=1><tr><td>" & objF.Type &"</td><td>" & objF.name & "</td><td>" & objF.DateCreated & "</td><td>" & Int(objF.Size/1024)&" kb</td></TR></table>"
    	end if
        if gfxSpex(objF.Path, w, h, c, strType) = true then
    		response.write w & " x " & h & " " & c & " colori" 
        end if 
    
    
      set objF = nothing 
      set objFSO = nothing 
    %>
    Intanto continuo a ravanare in rete
    Grazie ancora

  2. #2
    ops! ho risolto lo stesso senza impazzire. Posso calcolare la superficie usando le basse risoluzione che ho già sul server.

    Esempio:
    immagine 1091x1400pixel 118.11 Px/cm (300Dpi) = 9,24 x 11,85 cm

    cioè:
    1091/118,11 = 9,24
    1400/118,11 = 11,52

    oppure (stessa immagine a bassa risoluzione):
    immagine 262x336pixel 28.346 Px/cm (72Dpi) = 9,24 x 11,85 cm

    cioè:
    262/28,346 = 9,24
    336/28,346 = 11,85

    Se serve a qualcuno....

  3. #3
    grazie mille utilissimo

  4. #4
    mi ricorderò di questo topic

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.