Avatar billede milandt Nybegynder
04. maj 2003 - 17:30 Der er 2 kommentarer og
2 løsninger

billede proportioner

hejsa

jeg skal bruge et asp script der kan give mig højde og bredde på et jpg-billede. jeg har et script:

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  ':::                                                            :::
  ':::  This function does most of the real work. It will attempt  :::
  ':::  to read any file, regardless of the extension, and will    :::
  ':::  identify if it is a graphical image.                      :::
  ':::                                                            :::
  ':::  Passed:                                                    :::
  ':::      flnm        => Filespec of file to read              :::
  ':::      width      => width of image                        :::
  ':::      height      => height of image                        :::
  ':::      depth      => color depth (in number of colors)      :::
  ':::      strImageType=> type of image (e.g. GIF, BMP, etc.)    :::
  ':::                                                            :::
  ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  function gfxSpex(flnm, width, height, depth, strImageType)

    dim strPNG
    dim strGIF
    dim strBMP
    dim strType
    strType = ""
    strImageType = "(unknown)"

    gfxSpex = False

    strPNG = chr(137) & chr(80) & chr(78)
    strGIF = "GIF"
    strBMP = chr(66) & chr(77)

    strType = GetBytes(flnm, 0, 3)

    if strType = strGIF then                ' is GIF

        strImageType = "GIF"
        Width = lngConvert(GetBytes(flnm, 7, 2))
        Height = lngConvert(GetBytes(flnm, 9, 2))
        Depth = 2 ^ ((asc(GetBytes(flnm, 11, 1)) and 7) + 1)
        gfxSpex = True


    elseif left(strType, 2) = strBMP then        ' is BMP

        strImageType = "BMP"
        Width = lngConvert(GetBytes(flnm, 19, 2))
        Height = lngConvert(GetBytes(flnm, 23, 2))
        Depth = 2 ^ (asc(GetBytes(flnm, 29, 1)))
        gfxSpex = True

    elseif strType = strPNG then            ' Is PNG

        strImageType = "PNG"
        Width = lngConvert2(GetBytes(flnm, 19, 2))
        Height = lngConvert2(GetBytes(flnm, 23, 2))
        Depth = getBytes(flnm, 25, 2)

        select case asc(right(Depth,1))
          case 0
              Depth = 2 ^ (asc(left(Depth, 1)))
              gfxSpex = True
          case 2
              Depth = 2 ^ (asc(left(Depth, 1)) * 3)
              gfxSpex = True
          case 3
              Depth = 2 ^ (asc(left(Depth, 1)))  '8
              gfxSpex = True
          case 4
              Depth = 2 ^ (asc(left(Depth, 1)) * 2)
              gfxSpex = True
          case 6
              Depth = 2 ^ (asc(left(Depth, 1)) * 4)
              gfxSpex = True
          case else
              Depth = -1
        end select


    else

        strBuff = GetBytes(flnm, 0, -1)        ' Get all bytes from file
        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 if

  end function




men jeg kan ikke få gfxSpex til at blive true

skal bruge et andet, eller en løsning på mit problem
Avatar billede eagleeye Praktikant
04. maj 2003 - 18:15 #1
Umiddelbat mangler du en function som hedder: GetBytes.
Der er kun en function i det du har vist, jeg har engang brug noget ligne men der var 3 eller 4 funtioner som alle skulle bruges:

Prøv at bruge dette eks:
http://www.dmxzone.com/ShowDetail.asp?NewsId=564
Avatar billede milandt Nybegynder
04. maj 2003 - 19:25 #2
er det ik den eksakt samme funktion som jeg har pastet ovenover og som jeg ik kunne få til at virke?
Avatar billede eagleeye Praktikant
04. maj 2003 - 19:56 #3
Jo den som hedder  gfxSpex
Derudover skal du havde de to øverste funktioner:  GetBytes  samt  lngConvert
som også bruges.
Avatar billede dta Nybegynder
12. maj 2003 - 13:11 #4
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester