Learn how to a build a cloud-first strategyRegister Now

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

resize image using aspjpeg

i have this image path in my database and i have aspjpeg installed in my web server

<%=(Recordset1.Fields.Item("image").Value)%>

how can i use aspjpeg so i will display a smaller version of my image.   i really do not need to save the thumbnail if it is possible.  
0
gianitoo
Asked:
gianitoo
  • 7
  • 5
  • 3
1 Solution
 
aprestoCommented:
0
 
gianitooAuthor Commented:
great but....in that case it creates a picture called thumbnail.

i would like to have this database driven

mypath=<%=(Recordset1.Fields.Item("image").Value)%>

so what would be the path for my dynamic thumbnail

<%
'create an instance of our object
Set thumbs = CreateObject("Persits.Jpeg")
'this is the path to your image or directory of images e.g

ImagePath = <%=(Recordset1.Fields.Item("image").Value)%>
'open the image
thumbs.Open ImagePath
' resize the image
thumbs.Width = thumbs.OriginalWidth / 3
thumbs.Height = thumbs.OriginalHeight / 3
'save the thumbnail version
thumbs.Save Server.MapPath("thumbnail.jpg")
%>

 
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
aprestoCommented:
i sorry gianitoo i have no idea
0
 
masirofCommented:
This code opens image, resizes proportionally setting a max of 100 pixel to the longer side of width or height.
And it doesnt save thumbnails, it just sends it to client. Of course image size decreases too.

<%
Set jpeg = Server.CreateObject("Persits.Jpeg")

jpeg.Open(Recordset1.Fields.Item("image").Value)

If jpeg.OriginalHeight < jpeg.OriginalWidth Then
      jpeg.Width = 100
      jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth
Else
      jpeg.Height = 100
      jpeg.Width = jpeg.OriginalWidth * jpeg.Height / jpeg.OriginalHeight
End If

jpeg.SendBinary
%>
0
 
gianitooAuthor Commented:
i am getting this error
Persits.Jpeg.1 error '800a0002'

The system cannot find the path specified.

/papa/coupon.asp, line 78


and in my database  the picture is located in this path     papa/coupons/321-04-0473-0.jpg
0
 
masirofCommented:
Sure,

You should write out path like you are just

<img src="papa/coupons/321-04-0473-0.jpg">

or let us know where your page resides and images.. Directory structure..
0
 
gianitooAuthor Commented:
page is located in a folder called  papa

so you can find the page here  http://www.soccerbydesign.com/papa/coupon.asp
the image is located in a folder coupons  so you can find the image here
http://www.soccerbydesign.com/papa/coupons/321-04-0473-0.jpg
0
 
masirofCommented:
Okey,

try this then :

jpeg.Open("../" & Recordset1.Fields.Item("image").Value)
0
 
gianitooAuthor Commented:
when i try this   <img src="<%=(Recordset1.Fields.Item("image").Value)%>">

the image loads perfect

when when i add the code for aspjpg  it creates that annoying error
0
 
masirofCommented:
Ah yea, sorry. We should show it exact physical path..

You can use this :

jpeg.Open(Server.Mappath("../") & Recordset1.Fields.Item("image").Value)
0
 
gianitooAuthor Commented:
now i get no error but i get a horrible scribble instead of the thubnail

see on link below
http://www.soccerbydesign.com/papa/coupon.asp
0
 
gianitooAuthor Commented:
The support guy from aspjpg   tellsme that i need to send  
You need to send an image using a separate script, like this
 
<IMG SRC="script.asp">
 
and script.asp will actually create the thumbnail.

how do i do this?
0
 
masirofCommented:
actually the code should be in script.asp, the code I sent to you..

And then you call it from img src="script.asp" or thumbnaail asp..

and of course you may send query parameters to like
<img src="script.asp?imagename=<%=(Recordset1.Fields.Item("image").Value)%>">

thus you will have this code in script.asp

<%
Set jpeg = Server.CreateObject("Persits.Jpeg")

jpeg.Open(Server.Mappath("../") & Request.QueryString("imagename"))

If jpeg.OriginalHeight < jpeg.OriginalWidth Then
     jpeg.Width = 100
     jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth
Else
     jpeg.Height = 100
     jpeg.Width = jpeg.OriginalWidth * jpeg.Height / jpeg.OriginalHeight
End If

jpeg.SendBinary
%>
0
 
gianitooAuthor Commented:
bingo
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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