Solved

How to fix this diplay ASPJpeg thumbnail using Send Binary?

Posted on 2008-10-13
10
1,103 Views
Last Modified: 2010-08-05
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
Comment
Question by:marcoloppo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
10 Comments
 
LVL 10

Expert Comment

by:slamhound
ID: 22708547
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
 

Author Comment

by:marcoloppo
ID: 22708940
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
 
LVL 10

Expert Comment

by:slamhound
ID: 22708960
Try putting the loop in thumb.asp just after the code generates the image.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:marcoloppo
ID: 22713869
Hi,

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

Any other idea?

Thank you.
0
 
LVL 14

Expert Comment

by:_Stilgar_
ID: 22731159
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
 

Author Comment

by:marcoloppo
ID: 22733260
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
 
LVL 14

Expert Comment

by:_Stilgar_
ID: 22737182
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
 

Author Comment

by:marcoloppo
ID: 22737328
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
 
LVL 14

Accepted Solution

by:
_Stilgar_ earned 500 total points
ID: 22738510
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question