Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to fix this diplay ASPJpeg thumbnail using Send Binary?

Posted on 2008-10-13
10
Medium Priority
?
1,117 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 1500 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

Independent Software Vendors: 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 recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Screencast - Getting to Know the Pipeline

610 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