?
Solved

Create Cropped Thumbnail using ASPJPEG

Posted on 2007-08-09
4
Medium Priority
?
1,441 Views
Last Modified: 2009-01-14
I am using AspJpeg to create thumbnails for images. I need to preserve the aspect ratio and then crop the thumbnail image to fit in a 100 x 100 pixel area. I know how to create the thumbnail and resize it but the AspJpeg manual on cropping does not make sense to me.

To see what I need look here: http://technikcorp.com/crop.jpg

And here is my code:
==========================================================
         Set Jpeg = Server.CreateObject("Persits.Jpeg")
         ResizePath2 = vSitePath & vFolder &"\"& vMediaFile
         Jpeg.Open ResizePath2
                        Jpeg.PreserveAspectRatio = True
                        L = 100

                        If Jpeg.OriginalWidth > Jpeg.OriginalHeight Then
               Jpeg.Width = L
         Else
               Jpeg.Height = L
                        End If

                       Jpeg.Sharpen 1, 150
                       Jpeg.Quality 100
        Jpeg.Save vSitePath & vFolder &"\tn_"& vMediaFile

 
0
Comment
Question by:MarkWalker69
  • 3
4 Comments
 
LVL 11

Accepted Solution

by:
L00M earned 2000 total points
ID: 19664076
I'm sending it directly to the browser, but this should get you on the right path:

<%
Set Jpeg = Server.CreateObject("Persits.Jpeg")
ResizePath2 = server.mappath("crop.jpg")

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, 150

xCropWidth = 100
xCropHeight = 100

xOffset = int((Jpeg.Width-xCropWidth)/2)
yOffset = int((Jpeg.Height-xCropHeight)/2)
' May result in 99 instead of 100 due to rounding

Jpeg.Crop xOffset, yOffset, Jpeg.Width-xOffset, Jpeg.Height-yOffset
Jpeg.SendBinary
%>
0
 
LVL 11

Expert Comment

by:L00M
ID: 19664088
Note, I switched out the height and width in the if statement. And removed Jpeg.Quality as my version didn't support that.
0
 

Author Comment

by:MarkWalker69
ID: 19664163
Perfect. Thanks!
0
 
LVL 11

Expert Comment

by:L00M
ID: 19664175
NP! Glad to help!
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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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/…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Add visuals to your Prezi to keep your audience engaged. Learn how to embed images, edit them, and more in this video micro tutorial. Select "Insert" from the top menu in your Prezi editor: Select "Image": A toolbar will pop in from the right …
Suggested Courses

749 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