Loading...

asp application crash

Support for GdPicture Light Imaging Toolkit and GdPicture Pro Imaging ActiveX/SDK.

asp application crash

Postby rik » Fri Sep 25, 2009 2:49 pm

Hi,
we're using GdPicture Light Imaging Toolkit Ver. 4.12.0 (just updated) in our asp application and we're experiencing some problem. During intense use (multiple access to the function we use to process/resize images) we get the following error: "Unexpected error. A trappable error (C0000005) occurred in an external object."
To make things come back to work again we've to recycle the application. We've already tried to isolate the application in order to give it specific resources but nothing changed.
This is the function we use. May you please help us to solve the issue?

Code: Select all
function resizeImage(imageFileName,resizedFileName,newWidth,newHeight)
   Dim resized
   Dim nImageID
   isPNGImage = false
   resized = false
   jpgQuality = 95
   jpgInterpolation = 7
   jpgContrast = 8
   white960 = Server.MapPath ("white.jpg")
   if len(trim(imageFileName)) > 0 and len(trim(resizedFileName)) > 0 then
      if isNumeric(newWidth) and isNumeric(newHeight) then
         Set oGdPicture = Server.CreateObject("gdpicture4.imaging")
         oGdPicture.SetLicenseNumber(Application("GDPictureLicenceNumber"))
         nARGBWhiteColor = oGdPicture.ARGB(255, 255, 255, 255)
         nImageID = oGdPicture.CreateImageFromFile(imageFileName)
         if oGdPicture.GetImageFormat() = "PNG" then
            oGdPicture.ConvertTo32BppARGB()
            nImagePNG = oGdPicture.GetNativeImage
            nImageBackground = oGdPicture.CreateImageFromFile(white960)
            oGdPicture.SetNativeImage (nImageBackground)
            call oGdPicture.DrawImage(nImagePNG, 1, 1, oGdPicture.GetWidth, oGdPicture.GetHeight)
         end if
         if newWidth > 0 then
            if newHeight > 0 then
               if nImageID <> 0 then
                  oGdPicture.SetContrast(jpgContrast)
                  oGdPicture.ResizeImage newWidth, newHeight, jpgInterpolation
                  oGdPicture.SaveAsJPEG resizedFileName, jpgQuality
                  oGdPicture.CloseNativeImage()
                  resized = true
               end if
            else
               if nImageID <> 0 then
                  oGdPicture.SetContrast(jpgContrast)
                  oGdPicture.ResizeWidthRatio  newWidth,jpgInterpolation
                  oGdPicture.SaveAsJPEG resizedFileName, jpgQuality
                  oGdPicture.CloseNativeImage()
                  resized = true
               end if
            end if
         else
            if newHeight > 0 then
               if nImageID <> 0 then
                  oGdPicture.SetContrast(jpgContrast)
                  oGdPicture.ResizeHeightRatio newHeight, jpgInterpolation
                  oGdPicture.SaveAsJPEG resizedFileName, jpgQuality
                  oGdPicture.CloseNativeImage()
                  resized = true
               end if
            end if
         end if   
         set oGdPicture = nothing   
      end if   
   end if   
   resizeImage = resized
end function


Thanks for your help
rik
 
Posts: 3
Joined: Fri Sep 25, 2009 2:39 pm

Re: asp application crash

Postby Loïc » Fri Sep 25, 2009 3:07 pm

Hi,

You are creating 2 GdPicture image in memory bout you release only one of they:
Code: Select all
nImageID = oGdPicture.CreateImageFromFile(imageFileName)
nImageBackground = oGdPicture.CreateImageFromFile(white960)


Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: asp application crash

Postby rik » Fri Sep 25, 2009 5:41 pm

Hi Loic,
thanks for your reply.
We've corrected the error but we still have the same problem; this is our code now:

Code: Select all
function resizeImage(imageFileName,resizedFileName,newWidth,newHeight)
   Dim resized
   Dim nImageID
   isPNGImage = false
   resized = false
   jpgQuality = 95
   jpgInterpolation = 7
   jpgContrast = 8
   white960 = Server.MapPath ("white-960-960.jpg")
   if len(trim(imageFileName)) > 0 and len(trim(resizedFileName)) > 0 then
      if isNumeric(newWidth) and isNumeric(newHeight) then
         Set oGdPicture = Server.CreateObject("gdpicture4.imaging")
         oGdPicture.SetLicenseNumber(Application("GDPictureLicenceNumber"))
         nARGBWhiteColor = oGdPicture.ARGB(255, 255, 255, 255)
         nImageID = oGdPicture.CreateImageFromFile(imageFileName)
         if oGdPicture.GetImageFormat() = "PNG" then
            oGdPicture.ConvertTo32BppARGB()
            nImagePNG = oGdPicture.GetNativeImage
            nImageBackground = oGdPicture.CreateImageFromFile(white960)
            oGdPicture.SetNativeImage (nImageBackground)
            call oGdPicture.DrawImage(nImagePNG, 1, 1, oGdPicture.GetWidth, oGdPicture.GetHeight)
            isPNGImage = true
         end if
         if newWidth > 0 then
            if newHeight > 0 then
               if nImageID <> 0 then
                  oGdPicture.SetContrast(jpgContrast)
                  oGdPicture.ResizeImage newWidth, newHeight, jpgInterpolation
                  oGdPicture.SaveAsJPEG resizedFileName, jpgQuality
                  oGdPicture.CloseNativeImage()
                  resized = true
               end if
            else
               if nImageID <> 0 then
                  oGdPicture.SetContrast(jpgContrast)
                  oGdPicture.ResizeWidthRatio  newWidth,jpgInterpolation
                  oGdPicture.SaveAsJPEG resizedFileName, jpgQuality
                  oGdPicture.CloseNativeImage()
                  resized = true
               end if
            end if
         else
            if newHeight > 0 then
               if nImageID <> 0 then
                  oGdPicture.SetContrast(jpgContrast)
                  oGdPicture.ResizeHeightRatio newHeight, jpgInterpolation
                  oGdPicture.SaveAsJPEG resizedFileName, jpgQuality
                  oGdPicture.CloseNativeImage()
                  resized = true
               end if
            end if
         end if   
         if isPNGImage then
            oGdPicture.CloseImage(nImagePNG)
            oGdPicture.CloseImage(nImageBackground)
         end if
         oGdPicture.CloseImage(nImageID)
         set oGdPicture = nothing   
      end if   
   end if   
   resizeImage = resized

Thanks
rik
 
Posts: 3
Joined: Fri Sep 25, 2009 2:39 pm

Re: asp application crash

Postby Loïc » Fri Sep 25, 2009 5:46 pm

Hi,

Unfortunately if I don't know the line which crash your code I can't do anything.
Try to make break point to identify when the error appends.

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: asp application crash

Postby rik » Fri Nov 13, 2009 3:54 pm

Hi,
unfortunately we're still experiencing randomly the error "A trappable error (C0000005) occurred in an external object. The script cannot continue running..", working on some pictures.
In attachment you may find one of the pictures. The code is pasted after this email
May you please help us?
Thanks



Code: Select all
function createCroppedThumb(imageFileName,cropFileName,cropWidth,cropHeight)
   'response.Write "resizeImage<br>imageFileName:" & imageFileName&"<br>resizedFileName: "&resizedFileName&"<br>newWidth: "&newWidth&"<br>newHeight: "&newHeight&"<hr>"
   'Interpolations
   'Value Description
   '0    InterpolationModeDefault
   '1    InterpolationModeLowQuality
   '2    InterpolationModeHighQuality
   '3    InterpolationModeBilinear
   '4    InterpolationModeBicubic
   '5    InterpolationModeNearestNeighbor
   '6    InterpolationModeHighQualityBilinear
   '7    InterpolationModeHighQualityBicubic
   Dim resized
   Dim nImageID
   Dim debugPath
   Dim imageWidth
   Dim imageHeight
   Dim imageProportion
   Dim cropProportion
   Dim imageNamedProportion
   Dim cropNamedProportion
   Dim isDebug
   Dim imageType
   isDebug = false
   debugPathCropped = "/_debug/getCroppedThumb"
   myUniqueresizeID = vbNullString
   if isDebug then
      set rsNewID = connSfilate.execute("SELECT NEWID() AS myUniqueresizeID")
      myUniqueresizeID = rsNewID("myUniqueresizeID")
      myUniqueresizeID = replace(myUniqueresizeID,"{","")
      myUniqueresizeID = replace(myUniqueresizeID,"}","")
      rsNewID.close
      set rsNewID = nothing
   end if   
   if isDebug then call logToLine("1;getCroppedThumb;"&strErr&" - call: "&imageFileName,myUniqueresizeID,debugPathCropped)
   isPNGImage = false
   cropped = false
   jpgQuality = 95
   jpgInterpolation = 7
   jpgContrast = 8
   white960 = Server.MapPath ("/_images/gdpicture/white-960-960.jpg")
   if len(trim(imageFileName)) > 0 and len(trim(cropFileName)) > 0 then
      if isNumeric(newWidth) and isNumeric(newHeight) then
         Set oGdPicture = Server.CreateObject("gdpicture4.imaging")
         if isDebug then call logToLine("2-1;getCroppedThumb;Server.CreateObject(""gdpicture4.imaging"")",myUniqueresizeID,debugPathCropped)   
         oGdPicture.SetLicenseNumber(Application("GDPictureLicenceNumber"))
         if isDebug then call logToLine("2-2;createCroppedThumb;oGdPicture.SetLicenseNumber(Application(""GDPictureLicenceNumber""))",myUniqueresizeID,debugPathCropped)   
         'nARGBWhiteColor = oGdPicture.ARGB(255, 255, 255, 255)
         if isDebug then call logToLine("2-3;getCroppedThumb;oGdPicture.CreateImageFromFile(imageFileName): "&nImageID,myUniqueresizeID,debugPathCropped)   
         nImageID = oGdPicture.CreateImageFromFile(imageFileName)
         imageType =  oGdPicture.GetImageFormat()
         if imageType = "PNG" then
            oGdPicture.ConvertTo32BppARGB()
            nImagePNG = oGdPicture.GetNativeImage
            oGdPicture.SetNativeImage (nImagePNG)
            call oGdPicture.DrawImage(nImagePNG, 1, 1, oGdPicture.GetWidth, oGdPicture.GetHeight)
         end if
         
         imageWidth = oGdPicture.GetWidth()
         imageHeight = oGdPicture.GetHeight()
         imageProportion = getImageProportion(imageWidth,imageHeight)
         cropProportion = getImageProportion(cropWidth,cropHeight)
         imageNamedProportion = getPropotionName(imageProportion)
         cropNamedProportion = getPropotionName(cropProportion)
         
         if isDebug then call logToLine("2-4;getCroppedThumb;imageWidth: "&imageWidth,myUniqueresizeID,debugPathCropped)
         if isDebug then call logToLine("2-4;getCroppedThumb;imageHeight: "&imageHeight,myUniqueresizeID,debugPathCropped)   
         if isDebug then call logToLine("2-4;getCroppedThumb;cropWidth: "&cropWidth,myUniqueresizeID,debugPathCropped)
         if isDebug then call logToLine("2-4;getCroppedThumb;cropHeight: "&cropHeight,myUniqueresizeID,debugPathCropped)   
         if isDebug then call logToLine("2-4;getCroppedThumb;imageProportion: "&imageProportion,myUniqueresizeID,debugPathCropped)   
         if isDebug then call logToLine("2-4;getCroppedThumb;cropProportion: "&cropProportion,myUniqueresizeID,debugPathCropped)      
         if nImageID > 0 then
            oGdPicture.SetContrast(jpgContrast)   
            select case imageNamedProportion
               case "verticale"     'Master Verticale
                  if cropProportion < 1 then 'Crop Verticale
                     if isDebug then call logToLine("3A;getCroppedThumb;'Master Verticale - Crop Verticale - cropWidth,cropHeight : " & cropWidth & ", " & cropHeight,myUniqueresizeID,debugPathCropped)   
                     if imageProportion >= cropProportion then
                        oGdPicture.ResizeHeightRatio cropHeight, jpgInterpolation
                        nSrcLeft = round((oGdPicture.GetWidth()- cropWidth)/2)
                        nSrcTop = 0
                        oGdPicture.Crop nSrcLeft, nSrcTop, cropWidth, cropHeight
                        if isDebug then call logToLine("3B;getCroppedThumb;'imageProportion >= cropProportion - nSrcLeft,nSrcTop: "&nSrcLeft&","&nSrcTop,myUniqueresizeID,debugPathCropped)      
                     else
                        oGdPicture.ResizeWidthRatio cropWidth,jpgInterpolation
                        nSrcLeft = 0
                        nSrcTop = 0
                        oGdPicture.Crop nSrcLeft, nSrcTop, cropWidth, cropHeight
                        if isDebug then call logToLine("3B;getCroppedThumb;'imageProportion < cropProportion  - nSrcLeft,nSrcTop: "&nSrcLeft&","&nSrcTop,myUniqueresizeID,debugPathCropped)      
                     end if
                     cropped = true
                  else 'Crop Orizzontale o quadrato
                     if isDebug then call logToLine("3A;getCroppedThumb;'Master Verticale - Crop Orizzontale o quadrato - cropWidth,cropHeight : " & cropWidth & ", " & cropHeight,myUniqueresizeID,debugPathCropped)   
                     oGdPicture.ResizeWidthRatio cropWidth,jpgInterpolation
                     nSrcLeft = 0
                     nSrcTop = 0
                     oGdPicture.Crop nSrcLeft, nSrcTop, cropWidth, cropHeight
                     if isDebug then call logToLine("3B;getCroppedThumb;'imageProportion VS cropProportion indifferente - nSrcLeft,nSrcTop: "&nSrcLeft&","&nSrcTop,myUniqueresizeID,debugPathCropped)      
                     cropped = true
                  end if
               case "orizzontale"  'Master Orizzontale
                  if cropProportion > 1 then 'Crop Orizzontale
                     if isDebug then call logToLine("3A;getCroppedThumb;'Master Verticale - Crop Orizzontale - cropWidth,cropHeight : " & cropWidth & ", " & cropHeight,myUniqueresizeID,debugPathCropped)   
                     if imageProportion >= cropProportion then
                        oGdPicture.ResizeHeightRatio cropHeight, jpgInterpolation
                        nSrcTop = round((oGdPicture.GetHeight()- cropHeight)/2)
                        nSrcLeft = 0
                        oGdPicture.Crop nSrcLeft, nSrcTop, cropWidth, cropHeight
                        if isDebug then call logToLine("3B;getCroppedThumb;'imageProportion >= cropProportion - nSrcLeft,nSrcTop: "&nSrcLeft&","&nSrcTop,myUniqueresizeID,debugPath)      
                     else 'Crop Verticale o quadrato
                        oGdPicture.ResizeWidthRatio cropWidth,jpgInterpolation
                        nSrcLeft = 0
                        nSrcTop = 0
                        oGdPicture.Crop nSrcLeft, nSrcTop, cropWidth, cropHeight
                        if isDebug then call logToLine("3B;getCroppedThumb;'imageProportion < cropProportion  - nSrcLeft,nSrcTop: "&nSrcLeft&","&nSrcTop,myUniqueresizeID,debugPath)      
                     end if
                     cropped = true
                  else 'Crop Verticale o Quadrato
                     if isDebug then call logToLine("3A;getCroppedThumb;'Master Verticale - Crop Verticale o Quadrato - cropWidth,cropHeight : " & cropWidth & ", " & cropHeight,myUniqueresizeID,debugPath)   
                     oGdPicture.ResizeHeightRatio cropHeight, jpgInterpolation
                     nSrcLeft = round((oGdPicture.GetWidth()- cropWidth)/2)
                     nSrcTop = 0
                     oGdPicture.Crop nSrcLeft, nSrcTop, cropWidth, cropHeight
                     if isDebug then call logToLine("3B;getCroppedThumb;'imageProportion VS cropProportion indifferente - nSrcLeft,nSrcTop: "&nSrcLeft&","&nSrcTop,myUniqueresizeID,debugPath)      
                     cropped = true
                  end if
               case "quadrata"     'Master Quadrato
                  select case cropNamedProportion
                     case "verticale"    'Crop Verticale
                        oGdPicture.ResizeHeightRatio cropHeight, jpgInterpolation
                        nSrcLeft = round((oGdPicture.GetWidth()- cropWidth)/2)
                        nSrcTop = 0
                        oGdPicture.Crop nSrcLeft, nSrcTop, cropWidth, cropHeight   
                     case "orizzontale"   'Crop Orizzontale
                        oGdPicture.ResizeWidthRatio cropWidth,jpgInterpolation
                        nSrcLeft = 0
                        nSrcTop = 0
                        oGdPicture.Crop nSrcLeft, nSrcTop, cropWidth, cropHeight
                     case "quadrata"      'Crop Quadrato
                          oGdPicture.ResizeWidthRatio cropWidth,jpgInterpolation               
                  end select
                  cropped = true
            end select
            
            select case imageType
               case "JPEG"
                  oGdPicture.SaveAsJPEG cropFileName, jpgQuality
               case "PNG"
                  oGdPicture.SaveAsPNG cropFileName
            end select
            oGdPicture.CloseNativeImage()   

         end if   
         oGdPicture.CloseImage(nImageID)
         set oGdPicture = nothing   
         if isDebug then call logToLine("4;getCroppedThumb;set oGdPicture = nothing   ",myUniqueresizeID,debugPathCropped)
      end if   
   end if   
   createCroppedThumb = cropped
   if isDebug then call logToLine("5;getCroppedThumb;strErr: " & strErr & " - resized: " & resized,myUniqueresizeID,debugPathCropped)
end function
'*******************************************************************************************************************


'*******************************************************************************************************************
function resizeImage(imageFileName,resizedFileName,newWidth,newHeight)
   'response.Write "resizeImage<br>imageFileName:" & imageFileName&"<br>resizedFileName: "&resizedFileName&"<br>newWidth: "&newWidth&"<br>newHeight: "&newHeight&"<hr>"
   'Interpolations
   'Value Description
   '0    InterpolationModeDefault
   '1    InterpolationModeLowQuality
   '2    InterpolationModeHighQuality
   '3    InterpolationModeBilinear
   '4    InterpolationModeBicubic
   '5    InterpolationModeNearestNeighbor
   '6    InterpolationModeHighQualityBilinear
   '7    InterpolationModeHighQualityBicubic
   Dim resized
   Dim nImageID
   Dim debugPathResizeImg
   Dim isDebug
   isDebug = false
   debugPathResizeImg = "/_debug/resizeImage"
   myUniqueresizeID = vbNullString
   if isDebug then
      set rsNewID = connSfilate.execute("SELECT NEWID() AS myUniqueresizeID")
      myUniqueresizeID = rsNewID("myUniqueresizeID")
      myUniqueresizeID = replace(myUniqueresizeID,"{","")
      myUniqueresizeID = replace(myUniqueresizeID,"}","")
      rsNewID.close
      set rsNewID = nothing
   end if
   if isDebug then call logToLine("1;resizeImage;"&strErr&" - call: "&imageFileName,myUniqueresizeID,debugPathResizeImg)
   isPNGImage = false
   resized = false
   jpgQuality = 95
   jpgInterpolation = 7
   jpgContrast = 8
   white960 = Server.MapPath ("/_images/gdpicture/white-960-960.jpg")
   if len(trim(imageFileName)) > 0 and len(trim(resizedFileName)) > 0 then
      if isNumeric(newWidth) and isNumeric(newHeight) then
         Set oGdPicture = Server.CreateObject("gdpicture4.imaging")
         if isDebug then call logToLine("2-1;resizeImage;Server.CreateObject(""gdpicture4.imaging"")",myUniqueresizeID,debugPathResizeImg)   
         oGdPicture.SetLicenseNumber(Application("GDPictureLicenceNumber"))
         if isDebug then call logToLine("2-2;resizeImage;oGdPicture.SetLicenseNumber(Application(""GDPictureLicenceNumber""))",myUniqueresizeID,debugPathResizeImg)   
         'nARGBWhiteColor = oGdPicture.ARGB(255, 255, 255, 255)
         nImageID = oGdPicture.CreateImageFromFile(imageFileName)
         if isDebug then call logToLine("2-3;resizeImage;oGdPicture.CreateImageFromFile(imageFileName): "&nImageID,myUniqueresizeID,debugPathResizeImg)   
         if oGdPicture.GetImageFormat() = "PNG" then
            oGdPicture.ConvertTo32BppARGB()
            nImagePNG = oGdPicture.GetNativeImage
            nImageBackground = oGdPicture.CreateImageFromFile(white960)
            oGdPicture.SetNativeImage (nImageBackground)
            call oGdPicture.DrawImage(nImagePNG, 1, 1, oGdPicture.GetWidth, oGdPicture.GetHeight)
            isPNGImage = true
            if isDebug then call logToLine("2-4;resizeImage;isPNG: "&nImageID,myUniqueresizeID,debugPathResizeImg)   
         end if
         if newWidth > 0 then
            if newHeight > 0 then
               if nImageID <> 0 then
                  oGdPicture.SetContrast(jpgContrast)
                  'oGdPicture.FxSharpen()
                  'oGdPicture.FxSharpenMore()
                  oGdPicture.ResizeImage newWidth, newHeight, jpgInterpolation
                  'oGdPicture.FxStretchContrast()
                  oGdPicture.SaveAsJPEG resizedFileName, jpgQuality
                  oGdPicture.CloseNativeImage()
                  resized = true
                  if isDebug then call logToLine("3;resizeImage;Image resized - newWidth,newHeight : " & newWidth & ", " & newHeight,myUniqueresizeID,debugPathResizeImg)   
               end if
            else
               if nImageID <> 0 then
                  oGdPicture.SetContrast(jpgContrast)
                  'oGdPicture.FxSharpen()
                  'oGdPicture.FxSharpenMore()
                  oGdPicture.ResizeWidthRatio  newWidth,jpgInterpolation
                  'oGdPicture.FxStretchContrast()
                  oGdPicture.SaveAsJPEG resizedFileName, jpgQuality
                  'oGdPicture.SaveAsPNG(resizedFileName)
                  oGdPicture.CloseNativeImage()
                  resized = true
                  if isDebug then call logToLine("3;resizeImage;Image resized - newWidth : " & newWidth,myUniqueresizeID,debugPathResizeImg)   
               end if
            end if
         else
            if newHeight > 0 then
               if nImageID <> 0 then
                  oGdPicture.SetContrast(jpgContrast)
                  'oGdPicture.FxSharpen()
                  'oGdPicture.FxSharpenMore()
                  oGdPicture.ResizeHeightRatio newHeight, jpgInterpolation
                  'oGdPicture.FxStretchContrast()
                  oGdPicture.SaveAsJPEG resizedFileName, jpgQuality
                  oGdPicture.CloseNativeImage()
                  resized = true
                  if isDebug then call logToLine("3;resizeImage;Image resized - newHeight : " & newHeight,myUniqueresizeID,debugPathResizeImg)
               end if
            end if
         end if   
         if isPNGImage then
            oGdPicture.CloseImage(nImagePNG)
            oGdPicture.CloseImage(nImageBackground)
            if isDebug then call logToLine("3 - bis;resizeImage; CloseImage if isPNG",myUniqueresizeID,debugPathResizeImg)
         end if
         oGdPicture.CloseImage(nImageID)
         set oGdPicture = nothing   
         if isDebug then call logToLine("4;resizeImage;set oGdPicture = nothing   ",myUniqueresizeID,debugPathResizeImg)
      end if   
   end if   
   resizeImage = resized
   if isDebug then call logToLine("5;resizeImage;strErr: " & strErr & " - resized: " & resized,myUniqueresizeID,debugPathResizeImg)
end function
Attachments
kika648604.jpg
rik
 
Posts: 3
Joined: Fri Sep 25, 2009 2:39 pm

Re: asp application crash

Postby Loïc » Fri Nov 13, 2009 5:04 pm

Hi,

Could you try a call to:

Code: Select all
oGdPicture.DisableGdimgplugCodec(True)


Before opening the image ?

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France


Return to GdPicture [Pro] ActiveX

Who is online

Users browsing this forum: No registered users and 3 guests

cron