Author |
Topic |
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 26 April 2005 : 05:53:09
|
Finally managed to get my database driven thunbnail script working thanks to Podge and GhostNetworks - one final thing I need to do though is add transparent pixels to the edges of those thumbnails which may measure less horizontally or vertically than my desired thumbnail size. For example, if I wanted my thumbnails to measure 100 pixels square and I had one that was 50 pixels wide by 100 pixels hide, I'd need to add 25 pixels to the left and 25 pixels to the right of that image. Anyone have any ideas how I'd go about doing this or if it's even possible with .NET?
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
Edited by - Shaggy on 26 April 2005 05:53:20 |
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 26 April 2005 : 06:21:43
|
you could use 3 images, a transparent gif your thumbnail and another transparent gif and use CSS to align them next to each other |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 26 April 2005 : 06:27:57
|
Hmm ... sounds like a possibility ... but I'd have to somehow get the final dimensions of the proportionalised thumbnail from my *.aspx script and read them into a variable in my *.asp file which is displaying the thumbnail which I don't think would be possible seeing as the *.aspx script is called using the <img> tag rather than as an include.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 26 April 2005 : 06:55:19
|
here's another idea, probably simpler, use a div as your image placeholder and set its background to be your transparent gif, you can then center the thumbnail in the div over the top of the transparent gif background |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 26 April 2005 : 07:32:11
|
Ay, I think that's the way to go. For my own reference though (I was trying to use this script as a jump off point into .NET), is what I was originally trying to do possible with .NET's Drawing object?
<edit> Nearly forgot the reason I was trying to do this in the first place! I need to assign dimensions to the <img> tag referencing the *.aspx script - having an <img> tag without dimensions is something I hate doing. </edit>
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
Edited by - Shaggy on 26 April 2005 07:35:28 |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 26 April 2005 : 07:41:58
|
quote: is what I was originally trying to do possible with .NET's Drawing object?
yes, although probably what you need to do is create an empty image the size that you want and then copy the thumbnail to position x,y of your holders canvas rather than trying to alter the thumbnail itself.
you should be able to set the images size in your page_load event |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 26 April 2005 : 08:13:15
|
Thanks, HuwR That sends me in the right direction, at least; shall have a Google around for appropriate tutorials.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 26 April 2005 : 08:49:34
|
Sorry I can't give you any concrete examples, but have not done it in asp.net, however it should'nt be too difficult. good luck with your googling.
|
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 24 June 2005 : 11:23:54
|
Finally got around to revisiting this, I have it working nicely as it is, creating relatively resized thumbnails but I just need to make a few little tweaks to it.
01. If the image is to be a thumbnail (this will be specified in the querystring), I need to start off with a 100x100 pixel "canvas" that I can then centre my thumbnail in it horizontally and vertically. I did Google around a bit following Huw's suggestions and found a couple of samples and tutorials but just ended up confusing myself.
02. If the image is to be displayed full size or the original image is smaller or the same size as my thumbnail (100x100), I'd like to be able to determine whether the file size of the outputted thumbnail is less than that of the original image and, if not, output the original image rather than the thumbnail. (This one isn't hugely important, just an attempt to save on a bit of bandwidth.)
03. Lastly, I can't seem to get the contenttype right for *.png files. I have been using .png which all the documentation I have says is correct but keep receiving script errors so I'm thinking maybe the drawing object doesn't support *.png files. (Also not of major importance, I can output them as GIFs, if need be).
Here's the file as it is at the moment, if anyone could offer any insight to one or more of the above, I would be grateful.
<bump /> (sorry!)
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
Edited by - Shaggy on 12 July 2005 11:55:08 |
|
|
Ghostnetworks
New Member
95 Posts |
Posted - 17 July 2005 : 12:43:21
|
I leave town for a while and... Holy Cow, Batman! This thread hasn't been answered since last month?!
Please don't tell me I'm the only one sticking around the .Net forum
http://west-wind.com/weblog/posts/283.aspx A pretty decent thumbnail generation system
I did some digging around, and I'm not sure the method you use is the most efficient. Think about it. You have to call an external thread everytime you need a thumbnail. You're better off creating a handler and calling that instead. Calling an entire page may be a little too resource intensive.
http://www.dotnetdashboard.net/DesktopDefault.aspx?tabindex=2&tabid=71 A much better solution IMO, but it's a little more involved. Generates thumbnails to any size as well as include watermarks. It doesn't use transparent pixels, but measures the image size, so you can center it on page. The code is C#, but can be adapted for VB.Net with some work. The method uses a hanlder instead of a full page call. You can reuse this in many, many applications ( Galleries, news articles, tutorials etc... ) so it's worth looking into.
If I have the time this week, I'll work up a VB.Net version. I need something like this for a future project too, so we'll see if we can get two birds with one stone |
|
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 18 July 2005 : 13:00:03
|
Thanks, GN Looks like the first link might do the trick for me. I might be missing something in the second link but it looks like I'd need to use the file's URI to create the thumbnail when, ideally, I'd prefer for the file URIs not to be accessible by members at all.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
Ghostnetworks
New Member
95 Posts |
Posted - 18 July 2005 : 20:51:39
|
quote: Originally posted by Shaggy
I'd prefer for the file URIs not to be accessible by members at all.
I had the same requirement for a project last week. The best thing I can recommend is to check the referrer on the thumbnail.aspx page.
If it isn't called by the script page, you can't access it. That sort of thing.
Also.. You can just specify the image name when calling the thumbnail script, so it can dig into the file system without revealing the image location. That can also get around any hotlinking when used along side the referrer check. |
|
|
|
|
Topic |
|