help requested with GflAx.LoadBitmap

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, xnview

stanleytberry
Posts: 7
Joined: Mon Apr 09, 2007 6:39 pm

help requested with GflAx.LoadBitmap

Post by stanleytberry »

Help please with GflAx.LoadBitmap. What am I doing wrong?

Using this URL

http://www.myWebSite.us/image.asp?pictu ... yWidth=100

results in this returned

2 keywords passed.
Key = 'pictureFile' for Item = '../pictures/x-mas 2006/Our Chariot/DSC_0001.JPG'.
Key = 'displayWidth' for Item = '100'.
GflAx object created successfully.
pictureFile = '../pictures/x-mas 2006/Our Chariot/DSC_0001.JPG'.
'Error to open file' loading picture '../pictures/x-mas 2006/Our Chariot/DSC_0001.JPG'
.


'pictures' is a virtual defined on the web site which has as its source a share defined on another machine

image.asp is

Code: Select all

<%@ LANGUAGE=VBScript%>
<%Option Explicit%>
<%Response.Buffer = True%>
<%
Dim i, key, GflAx, pictureFile, actualHeight, actualWidth, displayHeight, displayWidth, displayPercent
Response.Write Request.QueryString.Count & " keywords passed." & "<br>"
For i = 1 To Request.QueryString.Count
	key = Request.QueryString.Key(i)
	Response.Write "Key = '" & key & "' for Item = '"
	Response.Write Request.QueryString.Item(key) & "'." & "<br>"
Next
On Error Resume Next
Set GflAx = Server.CreateObject("GflAx.GflAx")
If Err <> 0 Then
	Response.Write "'" & Err.Description & "' creating GflAx object." & "<br>"	
Else
	Response.Write "GflAx object created successfully." & "<br>"
	pictureFile = Request.QueryString("pictureFile")
	Response.Write "pictureFile = '" & pictureFile & "'." & "<br>"
	GflAx.LoadBitmap Request.QueryString("pictureFile")
	If Err <> 0 Then
		Response.Write "'" & Err.Description & "' loading picture '"
		Response.Write Request.QueryString("pictureFile") & "'." & "<br>"
	Else
		actualHeight = GflAx.height
		Response.Write "Actual picture height = " & actualHeight & "." & "<br>"
		actualWidth = GflAx.width
		Response.Write "Actual picture width = " & actualWidth & "." & "<br>"
		displayWidth = Request.QueryString("displayWidth")
		Response.Write "Display width = " & displayWidth & "." & "<br>"
		displayPercent = displayWidth / actualWidth
		Response.Write "Display percent = " & displayPercent & "." & "<br>"
		displayHeight = Round(actualHeight * displayPercent, 0)
		Response.Write "Display height = " & displayHeight & "." & "<br>"
		GflAx.Resize displayWidth, displayHeight
		If Err <> 0 Then
			Response.Write "'" & Err.Description & "' resizing picture." & "<br>"
		Else
			GflAx.SaveFormat = 1	' 1 = JPEG
			If Err <> 0 Then
				Response.Write "'" & Err.Description & "' setting SaveFormat." & "<br>"
			Else
				GflAx.SaveJPEGProgressive = TRUE
				If Err <> 0 Then
					Response.Write "'" & Err.Description & "' setting SaveJPEGProgressive." & "<br>"
				Else
					GflAx.SaveJPEGQuality = 85
					If Err <> 0 Then
						Response.Write "'" & Err.Description & "' setting SaveJPEGQuality." & 

"<br>"
					Else
						'Response.ContentType = "image/jpeg"
						'Response.BinaryWrite GflAx.SendBinary
					End If
				End If
			End If
		End If
	End If
	Set GflAx = Nothing
End If
%>
Additionally, I've tried
?pictureFile=/pictures/x-mas%202006/Our%20Chariot/DSC_0001.JPG&displayWidth=100
(no ..) and
?pictureFile=pictures/x-mas%202006/Our%20Chariot/DSC_0001.JPG&displayWidth=100
(no ../) and additionally I've tried all 3 variations with the filepath enclosed in "s ... all with the same result.

I can display the picture with this snippet today

Code: Select all

<%
		Response.Write "<img align=""center"" "
Response.Write "width=600 "
		Response.Write "alt=""" & Session.Contents("objPicRecordset")("pictureFile") & """ "
		Response.Write "border=0 " & vbCrLf
		Response.Write "src=""" & getPictureURL(Session.Contents("objPicRecordset")("pictureFile")) & """"
		Response.Write ">"
		%>
where pictureFile is pictures/x-mas%202006/Our%20Chariot/DSC_0001.JPG (or any other picture in the repository) and the
intent was to replace that source parameter with "src=""" & genURL(
image.asp?pictureFile=Session.Contents("objPicRecordset")("pictureFile")&displayWidth=600) & """" and get rid of the browser width specification.

I have control over the filepath specified in the database ... I just don't understand what it needs to be to allow GflAx locate the file.

Thanks,
Stan
User avatar
xnview
Author of XnView
Posts: 36866
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: help requested with GflAx.LoadBitmap

Post by xnview »

stanleytberry wrote:Help please with GflAx.LoadBitmap. What am I doing wrong?
Do you have an url to access DSC_0001.JPG?
someting like http://www.myWebSite.us/pictures/x-mas 2006/Our Chariot/DSC_0001.JPG is good?
Pierre.
stanleytberry
Posts: 7
Joined: Mon Apr 09, 2007 6:39 pm

Help please with GflAx.LoadBitmap. What am I doing wrong?

Post by stanleytberry »

http://www.Stan-and-Jeanne.us/pictures/x-mas 2006/Our Chariot/DSC_0001.JPG works.
Stan
User avatar
xnview
Author of XnView
Posts: 36866
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Help please with GflAx.LoadBitmap. What am I doing wrong

Post by xnview »

stanleytberry wrote:http://www.Stan-and-Jeanne.us/pictures/x-mas 2006/Our Chariot/DSC_0001.JPG works.
You have no 'Path = Server.MapPath("/GflAx")' or something similar, perhaps the problem...
Pierre.
stanleytberry
Posts: 7
Joined: Mon Apr 09, 2007 6:39 pm

Post by stanleytberry »

I added a Server.MapPath(...) to image.asp

Code: Select all

<LANGUAGE>
<Option>
<Response>
<%
Dim i, key, GflAx, pictureFile, pictureFilePath, actualHeight, actualWidth, displayHeight, displayWidth, displayPercent
Response.Write Request.QueryString.Count & " keywords passed." & "<br>"
For i = 1 To Request.QueryString.Count
	key = Request.QueryString.Key(i)
	Response.Write "Key = '" & key & "' for Item = '"
	Response.Write Request.QueryString.Item(key) & "'." & "<br>"
Next
On Error Resume Next
Set GflAx = Server.CreateObject("GflAx.GflAx")
If Err <> 0 Then
	Response.Write "'" & Err.Description & "' creating GflAx object." & "<br>"	
Else
	Response.Write "GflAx object created successfully." & "<br>"
	pictureFile = Request.QueryString("pictureFile")
	Response.Write "pictureFile = '" & pictureFile & "'." & "<br>"
	pictureFilePath = Server.MapPath(pictureFile)
	Response.Write "Path to picture file ='" & pictureFilePath & "'." & "<br>"
	GflAx.LoadBitmap pictureFilePath
	If Err <> 0 Then
		Response.Write "'" & Err.Description & "<br>"
	Else
		actualHeight = GflAx.height
		Response.Write "Actual picture height = " & actualHeight & "." & "<br>"
		actualWidth = GflAx.width
		Response.Write "Actual picture width = " & actualWidth & "." & "<br>"
		displayWidth = Request.QueryString("displayWidth")
		Response.Write "Display width = " & displayWidth & "." & "<br>"
		displayPercent = displayWidth / actualWidth
		Response.Write "Display percent = " & displayPercent & "." & "<br>"
		displayHeight = Round(actualHeight * displayPercent, 0)
		Response.Write "Display height = " & displayHeight & "." & "<br>"
		GflAx.Resize displayWidth, displayHeight
		If Err <> 0 Then
			Response.Write "'" & Err.Description & "' resizing picture." & "<br>"
		Else
			GflAx.SaveFormat = 1	' 1 = JPEG
			If Err <> 0 Then
				Response.Write "'" & Err.Description & "' setting SaveFormat." & "<br>"
			Else
				GflAx.SaveJPEGProgressive = TRUE
				If Err <> 0 Then
					Response.Write "'" & Err.Description & "' setting SaveJPEGProgressive." & "<br>"
				Else
					GflAx.SaveJPEGQuality = 85
					If Err <0>
and I get this result
  • 2 keywords passed.
    Key = 'pictureFile' for Item = 'pictures/x-mas 2006/Our Chariot/DSC_0001.JPG'.
    Key = 'displayWidth' for Item = '100'.
    GflAx object created successfully.
    pictureFile = 'pictures/x-mas 2006/Our Chariot/DSC_0001.JPG'.
    Path to picture file ='\\domainServer\pictures\x-mas 2006\Our Chariot\DSC_0001.JPG'.
    'Error to open file
Should this work?

Thanks,
Stan
User avatar
xnview
Author of XnView
Posts: 36866
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Post by xnview »

And i'm sure that \\domainServer\pictures\x-mas 2006\Our Chariot\DSC_0001.JPG is a good pathname?
Pierre.
stanleytberry
Posts: 7
Joined: Mon Apr 09, 2007 6:39 pm

Post by stanleytberry »

The result in my previous append should indicate that it is. That result was copied from the page returned by http://www.stan-and-jeanne.us/image.asp ... ures/x-mas 2006/Our Chariot/DSC_0001.JPG&displayWidth=100 which used the image.asp as in my previous append.

Further, the \\domainServer\pictures share currently has permissions set to allow access to all, as does the system security on the folder and files that constitute the share.

Could you tell me, does GflAx use the FileSystemObject to read the file?
Stan
stanleytberry
Posts: 7
Joined: Mon Apr 09, 2007 6:39 pm

Post by stanleytberry »

http://support.microsoft.com/kb/197964 may describe the cause of my problem if GflAx uses the FileSystemObject to access files. I will assume that it does.

The solution appears to be fraught with danger. It may take a few days but I will post the results of my attempt to implement it.
Stan
stanleytberry
Posts: 7
Joined: Mon Apr 09, 2007 6:39 pm

Post by stanleytberry »

There wasn't as much danger as I originally thought. After following the instructions in the knowledge base article, clearing the history on the test machine, and modifying my image.asp to

Code: Select all

On Error Resume Next
Set GflAx = Server.CreateObject("GflAx.GflAx")
If Err <> 0 Then
	Response.Write "'" & Err.Description & "' creating GflAx object." & "<br>"	
Else
	Response.Write "GflAx object created successfully." & "<br>"
	pictureFile = Request.QueryString("pictureFile")
	Response.Write "pictureFile = '" & pictureFile & "'." & "<br>"
	pictureFilePath = Server.MapPath(pictureFile)
	Response.Write "Path to picture file ='" & pictureFilePath & "'." & "<br>"
'------------------------- see if file can be found by FileSystemObject ------
	Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
	If Err <> 0 Then
		Response.Write "'" & Err.Description & "creating FileSystemObject." & "<br>"
	Else
		Response.Write "FileSystemObject created." & "<br>"
		If Not oFSO.FileExists(pictureFilePath) Then
			Response.Write "FileSystemObject.FileExists method failed."
		Else
			Response.Write "FileSystemObject.FileExists successful." & "<br>"
			GflAx.LoadBitmap pictureFilePath
			If Err <> 0 Then
				Response.Write "'" & Err.Number & ": " & Err.Description & "'" & "<br>"
			Else
				Response.Write "GflAx.LoadBitmap successful." & "<br>"
				actualHeight = GflAx.height
				Response.Write "Actual picture height = " & actualHeight & "." & "<br>"
				actualWidth = GflAx.width
				Response.Write "Actual picture width = " & actualWidth & "." & "<br>"
				displayWidth = Request.QueryString("displayWidth")
				Response.Write "Display width = " & displayWidth & "." & "<br>"
				displayPercent = displayWidth / actualWidth
				Response.Write "Display percent = " & displayPercent & "." & "<br>"
				displayHeight = Round(actualHeight * displayPercent, 0)
				Response.Write "Display height = " & displayHeight & "." & "<br>"
				GflAx.Resize displayWidth, displayHeight
				If Err <> 0 Then
					Response.Write "'" & Err.Description & "' resizing picture." & "<br>"
				Else
					GflAx.SaveFormat = 1	' 1 = JPEG
					If Err <> 0 Then
						Response.Write "'" & Err.Description & "' setting SaveFormat." & "<br>"
					Else
						GflAx.SaveJPEGProgressive = TRUE
						If Err <> 0 Then
							Response.Write "'" & Err.Description & "' setting SaveJPEGProgressive." & "<br>"
						Else
							GflAx.SaveJPEGQuality = 85
							If Err <0>
I got this result (copied directly from the resulting web page at the client)
  • 2 keywords passed.
    Key = 'pictureFile' for Item = 'pictures/x-mas 2006/Our Chariot/DSC_0001.JPG'.
    Key = 'displayWidth' for Item = '100'.
    GflAx object created successfully.
    pictureFile = 'pictures/x-mas 2006/Our Chariot/DSC_0001.JPG'.
    Path to picture file ='\\domainServer\pictures\x-mas 2006\Our Chariot\DSC_0001.JPG'.
    FileSystemObject created.
    FileSystemObject.FileExists successful.
    GflAx.LoadBitmap successful.
    Actual picture height = 349.
    Actual picture width = 522.
    Display width = 100.
    Display percent = 0.191570881226054.
    Display height = 67.
which satisfies me that it's fixed. Knowledgebase Article 197964
Stan
stanleytberry
Posts: 7
Joined: Mon Apr 09, 2007 6:39 pm

Post by stanleytberry »

For some reason my image.asp code was truncated in my previous append. If anyone really wants to see it all, please append here and I'll try again.

Sorry,
Stan