Forum Moderators: open

Message Too Old, No Replies

browser resize according to image..... How?

         

smagdy

7:51 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



Hi everybody..

I have pics gallery that when I click on pic.. it opens the picture in new window, so I just want the browser to change its dimensions and fit the image size.

<td>
<a href="image.jpg" target="_blank">
<img border="0" src="image.jpg">
</a>
</td>

so how to do that?

Thanks in advance

2by4

8:01 pm on Jul 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you're on apache, with either gd or imagemagik, you can get the image size through php and use that to write the size of the new window.

Trace

2:35 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



If you're on a windows box, it's just as easy to find an images dimensions in ASP. Here's an example:

<%
Dim Img
sub CheckFile (strFileName)
set Img = Server.CreateObject ("ImgSize.Check")
Img.FileName = strFileName
if Img.Error <> "" then
Response.Write "An error occurred in processing this image.<br>"
Response.Write "The error was: <b>" & Img.Error & "</b>"
else
Response.Write "<p>Image <b>" & strFileName & "</b> successfully read.<br>"
Response.Write "Image Height = <b>" & Img.Height & "</b><br>"
Response.Write "Image Width = <b>" & Img.Width & "</b></p>"
end if

set Img = nothing
end sub

CheckFile ("d:\inetpub\wwwroot\images\569.jpg")
CheckFile ("d:\inetpub\wwwroot\images\cloudy.jpg")
CheckFile ("d:\inetpub\wwwroot\images\chart1.bmp")
CheckFile ("d:\inetpub\wwwroot\images\aspdevlogo.gif")
CheckFile ("d:\inetpub\wwwroot\images\write.gif")
CheckFile ("d:\inetpub\wwwroot\images\smpchrt1.png")
CheckFile ("d:\inetpub\wwwroot\images\toast.png")
%>

smagdy

3:30 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



Thanks but am using PHP...

Well, am confused should i let it open in new window and the browser fit the screen.. or just open in same window and the user use back button to return back instead of bothering with new window?

whats more professional?
whats more convenient for the user?

am talkin about small thumbnails gallery (3-4 pics) for products!

Thanks

encyclo

3:34 pm on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think that a pop-up window would be best in this situation. You need to use Javascript to create the pop-up at the appropriate size, but you can use PHP to get the size of the image and write out the appropriate values. In your pop-up window, you should allow for some space around the image for a short title and a "close window" dialog at the bottom.

smagdy

3:53 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



ok thanks a lot

2by4

4:59 pm on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you make a file with this:
<?php
phpinfo();
?>
save it as test.php
upload it to your server root, then type in that url, you will get a list of what components apache has installed, look for either imagemagick or gd, then you'll know which php functions to use to get the size. If neither appears, you don't have the image processing part you need installed on your webserver.

dreamcatcher

6:44 pm on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don`t need ImageMagick or the GD Library to get an images size. PHP has a built in function for that already.

[uk.php.net...]

dc

2by4

9:55 pm on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



dreamcatcher, thanks for correcting that, a long time ago I was doing some gd stuff, and somewhere along the line I must have gotten the function you referred to mixed up with some gd specific functions, it's an internal memory corruption issue I think but I'm stuck with it....

dreamcatcher

12:59 pm on Jul 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No problem 2by4. :)