All pastes #812283 Raw Edit

K|O|G|I

public text v1 · immutable
·published 2007-12-11 17:24 UTC
rendered paste body
For Each File In Folder.Files
  If Instr( File.Type, "JPG") <> 0 Then
    Set Img = Server.CreateObject("Persits.Jpeg")
    Img.OpenBinary GetScreenshot(File.Name,"BINARY")
    Img.PreserveAspectRatio = True
    If Img.OriginalWidth > 100 or Img.OriginalHeight > 100 Then
      If Img.OriginalWidth > Img.OriginalHeight Then
        Img.Width = 100
      Else
        Img.Height = 100
      End If
    End If
    X = 20 + 120 * XCount
    Y = 40 + 120 * YCount
   If X >= 600 then
      XCount = 0
      YCount = YCount + 1
      X = 20 + 120 * XCount
      Y = 40 + 120 * YCount
   end if
    Jpeg.Canvas.DrawBar X - 1, Y - 1, X + 101, Y + 101
    Jpeg.Canvas.DrawImage X + (100 - Img.Width) / 2, Y + (100 - Img.Height) / 2, Img
    XCount = XCount + 1
    Counter = Counter + 1
  End If
Next
Jpeg.SendBinary
End Sub
Function GetScreenshot(TemplateVersion,SendType)
Dim Jpeg
Dim Img
ScreenPath = Server.Mappath("images\main\MainSite.JPEG")
Path = Server.Mappath("images\main")
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.Open ScreenPath
Set Img = Server.CreateObject("Persits.Jpeg")
Img.Open Path & "\" & TemplateVersion
Jpeg.Canvas.DrawImage 0,116.3, Img
Select case left(ucase(SendType),7)
   Case "BINARY"  'sent to an ASPJPeg object for further manipulation
      GetScreenshot = Jpeg.Binary
   Case "SENDBIN" 'sent to a screen
         Jpeg.PreserveAspectRatio = True
         startDimension = Instr(SendType,"(")+1
         endDimension = Instr(SendType,")")
         arrmaxDimensions = split((mid(SendType,startDimension,endDimension-startDimension)),",")
         maxHeight = int(arrmaxDimensions(0))
         maxWidth = int(arrmaxDimensions(1))
      If maxWidth > 0 OR maxHeight > 0 then
         if maxWidth = 0 then maxWidth = NULL
         if maxHeight = 0 then maxHeight = NULL
         If Jpeg.OriginalWidth > maxWidth or Jpeg.OriginalHeight > maxHeight Then
            If Jpeg.OriginalWidth > Jpeg.OriginalHeight Then
               Jpeg.Width = maxWidth
            Else
               Jpeg.Height = maxHeight
            End If
         End If
      end if
      GetScreenshot = Jpeg.SendBinary
   Case "SAVE"   'saved to disk
      GetScreenshot = Jpeg.Save (SendType)
End Select
End Function