For eller kan man finde størrelsen af billet med FSO og et par functioner og så resize i image tagen med hight og width, men det ændre ikke fil størrelsen som man kunne gøre med ASPImage.
Det kan gøre med FSO eller har du adgang til imgSize kompunenten?
Disse function kan du ligge i bunden af din kode og de bruger FSO til at find størrelsen på et billed.
<% '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: '::: ::: '::: This routine will attempt to identify any filespec passed ::: '::: as a graphic file (regardless of the extension). This will ::: '::: work with BMP, GIF, JPG and PNG files. ::: '::: ::: '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: '::: Based on ideas presented by David Crowell ::: '::: (credit where due) ::: '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: '::: blah blah blah blah blah blah blah blah blah blah blah blah ::: '::: blah blah blah blah blah blah blah blah blah blah blah blah ::: '::: blah blah Copyright *c* MM, Mike Shaffer blah blah ::: '::: blah blah ALL RIGHTS RESERVED WORLDWIDE blah blah ::: '::: blah blah Permission is granted to use this code blah blah ::: '::: blah blah in your projects, as long as this blah blah ::: '::: blah blah copyright notice is included blah blah ::: '::: blah blah blah blah blah blah blah blah blah blah blah blah ::: '::: blah blah blah blah blah blah blah blah blah blah blah blah ::: ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: '::: ::: '::: This function gets a specified number of bytes from any ::: '::: file, starting at the offset (base 1) ::: '::: ::: '::: Passed: ::: '::: flnm => Filespec of file to read ::: '::: offset => Offset at which to start reading ::: '::: bytes => How many bytes to read ::: '::: ::: '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: function GetBytes(flnm, offset, bytes)
Dim objFSO Dim objFTemp Dim objTextStream Dim lngSize
on error resume next
Set objFSO = CreateObject("Scripting.FileSystemObject")
' First, we get the filesize 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 ' Get All! GetBytes = objTextStream.Read(lngSize) 'ReadAll else GetBytes = objTextStream.Read(bytes) end if
objTextStream.Close set objTextStream = nothing set objFSO = nothing
end function
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: '::: ::: '::: Functions to convert two bytes to a numeric value (long) ::: '::: (both little-endian and big-endian) ::: '::: ::: '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 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
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: '::: ::: '::: 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)"
<% '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: '::: TESTE KODE ::: ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Set objFSO = CreateObject("Scripting.FileSystemObject") Set f1 = objFSO.GetFile(Server.MapPath("34thinking.jpg")) if instr(ucase(f1.Name), ".GIF") OR instr(ucase(f1.Name), ".JPG") then 'Kalder function som returnere størrelsen på billet if gfxSpex(server.MapPath(f1.Name), intWidth, intHigh, intColor, strType) = true then 'Definer MAX hight og width maxWidth = 50
fixWidth = false if (intWidth > maxWidth) then fixWidth = true end if
er det letteste ikk at kalde dimensioner på billederne, og så indsætte denne linie: """ width=""" & maxWidth & """ hight=""" & Int(intHigh/(intWidth/maxWidth)) &
Ved bare ikk helt hvor jeg skal få, intHigh og intWidth fra
Det leteste er at define en fast højde og brede i image tagen:
<img src="fil.jpg" width="50" hight="200">
men så vil det jo se sjovt ud for nogle billeder hvis højde svinder meget. Så derfor er der lavet en function som tjekke på størrelsen på billet: if gfxSpex(server.MapPath(f1.Name), intWidth, intHigh, intColor, strType) = true then
og ud fra breden i forhold til max brede sættes højden: Response.Write "<img src=""" & (f1.Name) & """ width=""" & maxWidth & """ hight=""" & Int(intHigh/(intWidth/maxWidth)) & """>"
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.