Solved

How to fix this diplay ASPJpeg thumbnail using Send Binary?

Posted on 2008-10-13
10
1,087 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
  • 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Highlight a word from some text 16 48
Css expand Div to fit its content (Of other divs) 4 46
How to hide jquery hemiintro in returning user? 1 68
Need help editing script 3 65
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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/…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now