Smart Image Processor ASP 2 Support Product Page

Answered

how can I make SIP2 serve images rather than write them to disc?

Asked 17 Sep 2014 08:50:44
1
has this question
17 Sep 2014 08:50:44 Andy Lucas posted:
I want to process images on the fly so when a particular server calls an image SIP2 will add a watermark and serve it directly to the browser rather than saving it to disc, is SIP2 capable of saving to memory and if so how?
Server : iis6
Many thanks

Replies

Replied 17 Sep 2014 09:12:11
17 Sep 2014 09:12:11 Teodor Kuduschiev replied:
Hello Andy,
Unfortunately this is not possible with SIP2.
Replied 17 Sep 2014 11:55:28
17 Sep 2014 11:55:28 Andy Lucas replied:
Ok so I have created the next best thing. I use a temp writable folder where SIP2 creates the new overlayed image then using an ADODB.Stream object send it to the browser as image/jpeg, clean up using the FSO


<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../ScriptLibrary/incSIP2Class.asp" -->
<
%Function CreateGuid()
    CreateGuid = Left(CreateObject("Scriptlet.TypeLib").Guid,38)
End Function
Function ReadBinaryFile(FileName)
   Const adTypeBinary = 1
   'Create Stream object
   Dim BinaryStream
   Set BinaryStream = CreateObject("ADODB.Stream")
   'Specify stream type - we want To get binary data.
   BinaryStream.Type = adTypeBinary       
   'Open the stream
   BinaryStream.Open       
   'Load the file data from disk To stream object
   BinaryStream.LoadFromFile FileName       
   'Open the stream And get binary data from the object
   ReadBinaryFile = BinaryStream.Read
End Function 

dim imgIn
imgIn=""
if request.querystring("i")<>"" then imgIn=request.querystring("i")
dim franid
franid=""
if request.querystring("fid")<>"" then franid=request.querystring("fid")

dim imgname
imgname=CreateGuid()&".jpg"
Dim sip1
Set sip1 = New ImageProcessor
sip1.Key = "75A00BE8-A16F-4F15-B5A7-AF2CBBB3C2FE"
sip1.ScriptFolder = "../ScriptLibrary"
sip1.Component = "AspNet"
sip1.Source = "file"
sip1.AutoOrient = false
sip1.KeepMetaData = false
sip1.Matte = "#FFFFFF"
sip1.Load "/upload/"&franid&"/"&imgIn&".jpg"
sip1.AddWatermark "/images/PNG/123-overlay-01.png", "Bottom-Right", false, "#000000", "100"
sip1.Overwrite = false
sip1.Mask = "/upload/tmp/"&imgname
sip1.SaveJPEG 100
Set sip1 = Nothing


    Dim path, gifdata
    ' Locate the file on disk
    path = server.mappath("/upload/tmp/"&imgname)
    ' Read the GIF image data
   gifdata = ReadBinaryFile(path)     
   ' Send the GIF image to the browser
   Response.ContentType = "image/jpeg"
   Response.Buffer = True
   Response.Clear
   Response.BinaryWrite gifdata
   Response.Flush

dim fs
Set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.FileExists(path) then
  fs.DeleteFile(path)
end if
set fs=nothing
%>

Reply to this topic