Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1119
  • Last Modified:

How to fix this diplay ASPJpeg thumbnail using Send Binary?

Hi,

I'm using ASPJpeg thumbnail creator and I'm facing a strange problem, sometimes when I access the page with the thumbnails generated with the component, all the thumbs load/looks fine, but sometimes some of the thumbs are not loaded, and if I refresh the page sometimes all are loaded fine.

I'm using the script below, with "Send Binary", and I'm calling it in HTML with <img src="scriptname.asp?photo=nameofphoto.jpg">

Waiting, thank you.
Set Jpeg = Server.CreateObject("Persits.Jpeg")
ResizePath2 = "e:\home\site\web\photos\"&request("photo")&""
Jpeg.Open ResizePath2
 
Jpeg.PreserveAspectRatio = True
L = 100
 
If Jpeg.OriginalWidth > Jpeg.OriginalHeight Then
  Jpeg.Height = L
Else
  Jpeg.Width = L
End If
 
Jpeg.Sharpen 1, 120
 
xCropWidth = 100
xCropHeight = 80
 
xOffset = int((Jpeg.Width-xCropWidth)/2)
yOffset = int((Jpeg.Height-xCropHeight)/2)
 
Jpeg.Crop xOffset, yOffset, Jpeg.Width-xOffset, Jpeg.Height-yOffset
 
Jpeg.SendBinary

Open in new window

0
marcoloppo
Asked:
marcoloppo
  • 4
  • 3
  • 2
1 Solution
 
slamhoundCommented:
Can you show me how Jpeg.SendBinary interacts with the main page?

I'm guessing this is either a caching issue or a timming issue.

Caching - Put this code at the top of the page:
<% Response.ExpiresAbsolute=#December 1,1980# %>

Timming - Add a for next loop for around 10,000 loops just after the jpg is to be displayed. This will give the system enough time to handle the jpg before the rest of the code keeps processing.
0
 
marcoloppoAuthor Commented:
Hi,

Thank you for your answer, I tried what you suggested but did not work, I let in the top of the page:
<% Response.ExpiresAbsolute=#December 1,1980# %>

And let in the HTML:

<img src="thumb.asp?photo=<%=rs("photo")%>" border="0" />
<%
for i=1 to 10000
next
%>    

OR

<img src="thumb.asp?photo=<%=rs("photo")&width=86&height=82%>" border="0" />
<%
for i=1 to 10000
next
%>    

But did not work, what might be?
0
 
slamhoundCommented:
Try putting the loop in thumb.asp just after the code generates the image.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
marcoloppoAuthor Commented:
Hi,

I put the code in thumb.asp just after the Send Binary, but the problem persists.

Any other idea?

Thank you.
0
 
_Stilgar_Commented:
Try the two ideas below:

1. When accessing the image, add a random number/string as an extra parameter, s.a.:

<img src="thumb.asp?photo=<%=rs("photo")%>&rand=932f0fj2" border="0" />

See below a function to get you started.

2. Access the URLs for images which are not loaded directly. That page might be exeriencing an error which you don't see. If you find an error, try correcting it or paste it here. Make sure you have friendly HTTP errors turned off in IE.

Stilgar.
  Function GenerateRnd(nMax)
	Dim strLetter, intRnd, strPassWord, i
	i = 0
	strLetter = Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9")
	Randomize Timer
	do while i < nMax
	      intRnd = strLetter(Int(RND * 35))
	      strPassWord = strPassWord + intRnd
	      i = i + 1
	loop
	GenerateRnd = strPassWord
  End Function

Open in new window

0
 
marcoloppoAuthor Commented:
Hi,

Thank you for your message. I tried what u suggested but the problem persists, I'll show to you all my code, may be it might help. Waiting,

Thank you
thumb.asp
 
<%
 
rand = request(rand)
 
Set Jpeg = Server.CreateObject("Persits.Jpeg") 
 
 
Set Jpeg = Server.CreateObject("Persits.Jpeg")
ResizePath2 = "e:\home\site\web\novosite\fotos\"&request("foto")&""
 
Jpeg.Open ResizePath2
 
Jpeg.PreserveAspectRatio = True
L = 100
 
If Jpeg.OriginalWidth > Jpeg.OriginalHeight Then
  Jpeg.Height = L
Else
  Jpeg.Width = L
End If
 
Jpeg.Sharpen 1, 120
 
xCropWidth = request("width")
xCropHeight = request("height")
 
xOffset = int((Jpeg.Width-xCropWidth)/2)
yOffset = int((Jpeg.Height-xCropHeight)/2)
 
Jpeg.Crop xOffset, 0, Jpeg.Width-xOffset, 82
'Jpeg.Crop xOffset, yOffset, Jpeg.Width-xOffset, Jpeg.Height-yOffset
 
Jpeg.SendBinary
 
for i=1 to 15000
next
 
Jpeg.close()
Set Jpeg = Nothing
 
 
 
%>
 
the application in html
 
<td width="90" height="88" align="center" valign="middle" bgcolor="#F5F5F5">
					  <%
					  	if IsNull(rs3("foto_1")) = false AND rs3("foto_1") <> "" then
					   %>						
                       <a href="fotos/<%=rs3("foto_1")%>" rel="lightbox[galeria]"><img src="thumb.asp?foto=<%=rs3("foto_1")%>&rand=GenerateRnd(932f0fj2)&width=86&height=82" border="0" /></a>
					  <%							
						end if
					  %>                      </td>
                      <td width="90" align="center" valign="middle" bgcolor="#F5F5F5"><%
					  	if IsNull(rs3("foto_2")) = false AND rs3("foto_2") <> "" then
					   %>
                        <a href="fotos/<%=rs3("foto_2")%>" rel="lightbox[galeria]"><img src="thumb.asp?foto=<%=rs3("foto_2")%>&rand=GenerateRnd(mdkjfwoj)&width=86&amp;height=82" border="0" /></a>
                        <%							
						end if
					  %></td>
                    </tr>
                    <%
					if rs3("foto_3") <> "" OR rs3("foto_4") <> "" then
					%>
 
                    <tr>
                      <td height="88" align="center" valign="middle" bgcolor="#F5F5F5"><%
					  	if IsNull(rs3("foto_3")) = false AND rs3("foto_3") <> "" then
					   %>
                        <a href="fotos/<%=rs3("foto_3")%>" rel="lightbox[galeria]"><img src="thumb.asp?foto=<%=rs3("foto_3")%>&rand=GenerateRnd(mwndix5w)&width=86&amp;height=82" border="0" /></a>
                      <%							
						end if
					  %></td>
                      <td align="center" valign="middle" bgcolor="#F5F5F5"><%
					  	if IsNull(rs3("foto_4")) = false AND rs3("foto_4") <> "" then
					   %>
                        <a href="fotos/<%=rs3("foto_4")%>" rel="lightbox[galeria]"><img src="thumb.asp?foto=<%=rs3("foto_4")%>&rand=GenerateRnd(eilxijemt)&width=86&amp;height=82" border="0" /></a>
                      <%							
						end if
					  %></td>
                    </tr>
                    <%
					end if
					%>
                    <%
    				if rs3("foto_5") <> "" OR rs3("foto_6") <> "" then
					%>
                    <tr>
                      <td height="88" align="center" valign="middle" bgcolor="#F5F5F5"><%
					  	if IsNull(rs3("foto_5")) = false AND rs3("foto_5") <> "" then
					   %>
                        <a href="fotos/<%=rs3("foto_5")%>" rel="lightbox[galeria]"><img src="thumb.asp?foto=<%=rs3("foto_5")%>&rand=GenerateRnd(a48edfvt)&width=86&amp;height=82" border="0" /></a>
                      <%							
						end if
					  %></td>
                      <td align="center" valign="middle" bgcolor="#F5F5F5"><%
					  	if IsNull(rs3("foto_6")) = false AND rs3("foto_6") <> "" then
					   %>
                        <a href="fotos/<%=rs3("foto_6")%>" rel="lightbox[galeria]"><img src="thumb.asp?foto=<%=rs3("foto_6")%>&rand=GenerateRnd(w8xe4dbt)&width=86&amp;height=82" border="0" /></a>
                      <%							
						end if
					  %></td>

Open in new window

0
 
_Stilgar_Commented:
Can you ellaborate more? from the code above I can't tell where the problem is. If you're using thumb.asp to create thumbnails on the fly, and for some instances it wouldn't work, try identifying the problem. Will it error for those images it doesn't show? if not then what? are there any similar charectaristics?

Also, I've seen Jpeg objects (don't remember if it was Persits') which had issues processing certain formats. Try re-saving the JPG you're handling with Photoshop or similar and run it through the script again. If that helps, that will indicate issue with the component.
0
 
marcoloppoAuthor Commented:
Hi,

You can see the code working in this example: hhttp://www.benissimo.com.br/novosite/icones_de_estilo.asp?cod=1

The thumbnails in the left column are made with the Aspjpeg, if you reload the page 3 or 4 times you'll see that some thumbs are loaded (maybe all the 6 thumbs), in one time when refreshing, the same thumb(s) that was loaded with success at the other time, now it might be not loaded with success again...

You'll see there are no error messages, or things like that. AspJpeg is a persists component. I'm not sure about a problem with the jpeg files because this problem happens some times with the same files that some times are loaded fine.

My doubt is, would be it caused because 6 thumbs with send binary, been loaded in the same time (on the fly)? Or Did I make any code mistake?

What I really think strange, sometimes all the 6 thumbs are loaded with success, and sometimes the same thumbs pictures/pages have problems.

Waiting, thank you.
0
 
_Stilgar_Commented:
Sorry, I cannot seem to reproduce the error you're mentioning. What I could advise you is try and cache the thumb images on your server instead of creating them on the fly. This will reduce server workload, and deliever your files faster. The issue you're having might do with the fact the site takes a while to load in full.

Also, try generating that error in a different browser (I was using IE7).
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now