Announcement

Collapse
No announcement yet.

JPG Size

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • JPG Size

    I'm trying to use the function on a web server.

    I's it possible to open the file in binary for read only as the directory
    containging the jpg's is read only permission.

    Code:
    FUNCTION JPGDims( BYVAL File AS STRING ) EXPORT AS STRING
      LOCAL ErrCount AS INTEGER
      LOCAL LongLoop1 AS LONG
      LOCAL Lbuf AS LONG
      LOCAL Buf AS STRING
      LOCAL JPGy AS INTEGER
      LOCAL JPGx AS INTEGER
      LOCAL FileHan AS INTEGER
      FileHan = FREEFILE
      DO
        ON ERROR RESUME NEXT
        OPEN File FOR BINARY ACCESS READ AS FileHan
        IF ERR = 0 THEN EXIT DO
        INCR ErrCount
        IF ErrCount = 100 OR ERR = 53 THEN EXIT FUNCTION
        SLEEP 250
      LOOP
      lbuf = LOF( FileHan )
      GET$ FileHan, lbuf, buf
      CLOSE FileHan
      LongLoop1 = 0
      DO
        INCR LongLoop1
        IF ASC( buf, LongLoop1 ) = VAL( "&HFF" ) THEN
          IF ASC( buf, LongLoop1 + 1 ) = > VAL( "&HC0" ) AND ASC( buf, LongLoop1 + 1 ) < = VAL( "&HC3" ) THEN
            JPGy = ASC( buf, LongLoop1 + 5 ) * 256 + ASC( buf, LongLoop1 + 6 )
            JPGx = ASC( buf, LongLoop1 + 7 ) * 256 + ASC( buf, LongLoop1 + 8 )
            EXIT DO
          END IF
        END IF
      LOOP UNTIL LongLoop1 > lbuf - 10
      FUNCTION = TRIM$( STR$( JPGx )) + "/" + TRIM$( STR$( JPGy ))
    END FUNCTION
    ------------------

  • #2
    Your code is already opening the file for read-only access.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Comment


    • #3


      ------------------

      Comment

      Working...
      X