473,770 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resize to image

I'm opening a page that has a single image on it. I'd like to resize the
window containing the image to the size of the image (slightly larger OK,
not smaller). The width isn't a problem, but the height is. The window, of
course has things like menu bars, toolbar, navigation, etc. I need to
account for these when I resize the image, but I'm not seeing how to do
that. I'm sure this must be done frequently, but I'm not seeing the
solution.

Would one of you guru's be so kind as to point me in the direction on how to
do this. I'll be eternally grateful.

tia
---Michael

Jul 23 '05 #1
8 2409
A little more information. The page is being built on the server (with the
single image), and the size may vary. I'd like to pass the image size back
to the main window and have javascript resize it at presentation time to
the size of the image. (All other suggestions gratefully accepted).

I've tried the following:

window.menubar. visible=false;
window.director ies.visible=fal se;
window.statusba r.visible=false ;
window.toolbar. visible=false;
window.location bar.visible=fal se;
window.personal bar.visible=fal se;
window.scrollba rs.visible=fals e;

which I thought would eliminate the distractions at the top - and (I hoped)
the problem, but this code didn't seem to have any effect. All of the
garbage at the top was still there.

Any suggestions?

Jul 23 '05 #2
Michael Satterwhite wrote:
A little more information. The page is being built on the server (with the
single image), and the size may vary. I'd like to pass the image size back
to the main window and have javascript resize it at presentation time to
the size of the image. (All other suggestions gratefully accepted).

I've tried the following:

window.menubar. visible=false;
window.director ies.visible=fal se;
window.statusba r.visible=false ;
window.toolbar. visible=false;
window.location bar.visible=fal se;
window.personal bar.visible=fal se;
window.scrollba rs.visible=fals e;


You can not reliably control any of the above features of a window, nor
can you reliably re-size it. Therefore, do not depend on being able to
do so.

The most common "fix" is to make your background black or some similar
colour sympathetic to your images, then place your image within the
page with a suitable border to frame it.

--
Fred
Jul 23 '05 #3
On Mon, 17 Jan 2005 23:49:41 GMT Michael Satterwhite wrote:
I'm opening a page that has a single image on it. I'd like to resize
the
window containing the image to the size of the image (slightly larger
OK,
not smaller). The width isn't a problem, but the height is. The window,
of
course has things like menu bars, toolbar, navigation, etc. I need to
account for these when I resize the image, but I'm not seeing how to do
that. I'm sure this must be done frequently, but I'm not seeing the
solution. Would one of you guru's be so kind as to point me in the direction on
how to
do this. I'll be eternally grateful. tia
---Michael


Done quite frequently for images.
You can turn off those items like, menu, toolbar, statusbar, etc.
Leave only the part showing the close buttons and that.
This is the basics with popups.

<a href="http://www.google.com" target="_blank" title="That search engine"
onclick="window .open(this.href ,'blank','width =200,height=100 ,menubar=no,too l
bar=no');">Goog le</a>

Here's one of the easiest ways of doing it.

Jul 23 '05 #4

"Fred Oz" <Oz****@iinet.n et.auau> wrote in message
news:Mz******** *********@news. optus.net.au...
You can not reliably control any of the above features of a window, nor
can you reliably re-size it. Therefore, do not depend on being able to
do so.

The most common "fix" is to make your background black or some similar
colour sympathetic to your images, then place your image within the
page with a suitable border to frame it.


I'm working on a site with a similar issue. How do I make the background of
the popup black? Is there any way to have the popup appear in the center of
the screen instead of the top left?

My code looks like this:

<td>
<div align="center">
<a href="javascrip t:;"
onClick="MM_ope nBrWindow('gall ery/photos/hostel-lounge-2.jpg','MiamiHo stelGu
ests6','scrollb ars=yes,resizab le=yes,width=25 5,height=200')" >
<img src="gallery/thumbnails/hostel-lounge-2.jpg" width="75" height="56">
</a>
</div>
</td>
Jul 23 '05 #5
Josh wrote:
"Fred Oz" <Oz****@iinet.n et.auau> wrote in message
news:Mz******** *********@news. optus.net.au... [...] I'm working on a site with a similar issue. How do I make the background of
the popup black? Is there any way to have the popup appear in the center of
the screen instead of the top left?


You can try detecting the available screen width and height, then size
and position your window accordingly. When creating the new window,
write HTML as if you were writing a stand-alone page (which is the
simplest way to develop the code to start with):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>demo</title>
<script type="text/javascript">
function popWin(a){
win = window.open('', 'Gallery Picture','');
var winContent = [
'<html><head><t itle>An Image</title></head>',
'<body style="backgrou nd-color: black;',
' text-align: center; margin-top: 100px">',
'<div style="border: 3px solid gold;',
' padding: 2 2 2 2;">',
'<img src="' + a.href + '"',
' style="border:1 px solid gold; padding: 3 3 3 3;',
' width: 100px; height: 100px;"',
' alt="An image">',
'</div>',
'<br>',
'<a href="javascrip t:window.close( );">Close</a>',
'</body></html>' ]
win.document.wr ite(winContent. join(''));
win.document.cl ose();
}

</script>
</head><body>
<a href="a.gif" border="0" onclick="
popWin(this);re turn false;
"><img src="b.gif" border="0" alt="Link to A"></a>
</body>
</html>

In the start document, the link is made with a standard href. If the
onclick runs, it returns false, canceling the link. If JavaScript is
not enabled or not supported, the link will be shown in the current
page - so the page is not dependent on JavaScript. Users can still
make the choice of opening the link in a new window or tab themselves.

This is just a demo, modify your code to suit. Remember that the HTML
you put in the new window should be just as valid as any other HTML you
write.

--
Rob
Jul 23 '05 #6

"RobG" <rg***@iinet.ne t.auau> wrote in message
news:SR******** *********@news. optus.net.au...
Josh wrote:
"Fred Oz" <Oz****@iinet.n et.auau> wrote in message
news:Mz******** *********@news. optus.net.au...

[...]
I'm working on a site with a similar issue. How do I make the background of the popup black? Is there any way to have the popup appear in the center of the screen instead of the top left?


You can try detecting the available screen width and height, then size
and position your window accordingly. When creating the new window,
write HTML as if you were writing a stand-alone page (which is the
simplest way to develop the code to start with):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>demo</title>
<script type="text/javascript">
function popWin(a){
win = window.open('', 'Gallery Picture','');
var winContent = [
'<html><head><t itle>An Image</title></head>',
'<body style="backgrou nd-color: black;',
' text-align: center; margin-top: 100px">',
'<div style="border: 3px solid gold;',
' padding: 2 2 2 2;">',
'<img src="' + a.href + '"',
' style="border:1 px solid gold; padding: 3 3 3 3;',
' width: 100px; height: 100px;"',
' alt="An image">',
'</div>',
'<br>',
'<a href="javascrip t:window.close( );">Close</a>',
'</body></html>' ]
win.document.wr ite(winContent. join(''));
win.document.cl ose();
}

</script>
</head><body>
<a href="a.gif" border="0" onclick="
popWin(this);re turn false;
"><img src="b.gif" border="0" alt="Link to A"></a>
</body>
</html>

In the start document, the link is made with a standard href. If the
onclick runs, it returns false, canceling the link. If JavaScript is
not enabled or not supported, the link will be shown in the current
page - so the page is not dependent on JavaScript. Users can still
make the choice of opening the link in a new window or tab themselves.

This is just a demo, modify your code to suit. Remember that the HTML
you put in the new window should be just as valid as any other HTML you
write.


Thanks for that tip. I just bought two books on JavaScript today and am
going to learn how to do this stuff...
Jul 23 '05 #7
JRS: In article <10************ *@corp.supernew s.com>, dated Wed, 19 Jan
2005 21:29:07, seen in news:comp.lang. javascript, Josh
<jo*****@hotmai l.com> posted :

Thanks for that tip. I just bought two books on JavaScript today and am
going to learn how to do this stuff...


If you had read the newsgroup FAQ, you would almost certainly have
learned that at least one of them was not considered worth recommending.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #8
Michael Satterwhite wrote:
A little more information. The page is being built on the server (with the single image), and the size may vary. I'd like to pass the image size back to the main window and have javascript resize it at presentation time to the size of the image. (All other suggestions gratefully accepted).

I've tried the following:

window.menubar. visible=false;
window.director ies.visible=fal se;
window.statusba r.visible=false ;
window.toolbar. visible=false;
window.location bar.visible=fal se;
window.personal bar.visible=fal se;
window.scrollba rs.visible=fals e;

which I thought would eliminate the distractions at the top - and (I hoped) the problem, but this code didn't seem to have any effect. All of the
garbage at the top was still there.

Any suggestions?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>PicUp</title>
<base href="http://www.johnleeart. com/Europe/" />
<style type="text/css">

body {
margin: 40px 0 0 0;
background: #806030;
}
a.PU img {
display: block;
margin-bottom: 4px;
border: 1px #000 solid;
border-left: 24px #403010 solid;
}

</style>
<script type="text/javascript">

PicUp.win = null;
PicUp.sticky = true;
PicUp.clickclos e = true;

function PicUp(url, title)
{
if (PicUp.win && !PicUp.win.clos ed)
PicUp.win.close ();
var plObj = new Image;
plObj.onload = function()
{
var w = this.width;
var h = this.height;
var config = [
'width=' + w , 'height=' + h ,
'left=' + (screen.availWi dth - w - 10) * .5 ,
'top=' + (screen.availHe ight - h - 10) * .5 ,
'status=0'
].join(',');

PicUp.HTML = [
'<html><head><t itle>' + title + '</title></head>' ,
'<body style="margin:0 ;background:bla ck;overflow:hid den;"' ,
((PicUp.sticky) ? ' onblur="setTime out(\'top.focus ()\',200)"' : '')
,
((PicUp.clickcl ose) ? ' onclick="top.cl ose()"' : '') ,
'><img style="border-width:0;cursor: pointer;"' ,
((PicUp.clickcl ose) ? ' title="click to close"' : '') ,
' src="' + this.src + '"></body></html>'
].join('');

PicUp.win = window.open('ja vascript:opener .PicUp.HTML', 'picwin',
config);
if (PicUp.win && !PicUp.win && PicUp.win.focus )
PicUp.win.focus ();
}
plObj.onerror = function()
{
alert('Larger size not available, sorry...');
}
plObj.alt = title;
plObj.src = url;
return false;
}

</script>
</head>
<body>
<div id="container" >
<a class="PU"
title="Afternoo n In Alhambra"
target="_blank"
href="images/AfternoonInAlha mbra01.jpg"
onclick="return PicUp(this.href ,this.title)">
<img
alt="Thumbnail - Click for fullsize image"
src="thumbnails/AfternoonInAlha mbra01.jpg" />
</a>
<a class="PU"
title="Apartmen ts In Muslin Quarter"
target="_blank"
href="images/ApartmentsInMus linQuarter.jpg"
onclick="return PicUp(this.href ,this.title)">
<img
alt="Thumbnail - Click for fullsize image"
src="thumbnails/ApartmentsInMus linQuarter.jpg" />
</a>
<a class="PU"
title="Empire's Glory Days"
target="_blank"
href="images/EmpuriesGloryDa ys.jpg"
onclick="return PicUp(this.href ,this.title)">
<img
alt="Thumbnail - Click for fullsize image"
src="thumbnails/EmpuriesGloryDa ys.jpg" />
</a>
<a class="PU"
title="Merry-Go-Round"
target="_blank"
href="images/MerryGoRound.jp g"
onclick="return PicUp(this.href ,this.title)">
<img
alt="Thumbnail - Click for fullsize image"
src="thumbnails/MerryGoRound.jp g" />
</a>
</div>
</body>
</html>

Might as well cover my ass: this code is bad.
Pop-ups: really bad, may be blocked (bad).
Messing w/window unreliable. Focussing, bad.
Have fun. ~:>)

Jul 23 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3270
by: Z D | last post by:
Hello, BACKGROUND: ============== I've created a Windows User Control that contains an Image Control (among other controls). The user control handles the picture resize event. Whenever the parent that holds my user control is resized, I resize my image so that it uses the maximum available space. Note: It takes about 2 seconds to regenerate the
14
2794
by: Rudy | last post by:
Hello all! I been trying to get a handle with Images. I have learned alot from the fine people here. So, I also learned that thumbnail images look terrible taken from a digital cam. I know why they look bad. So what is the best way to resize an image. I'm not too concerned about size, but I guess I would like to compress it on the upload. Any thoughts?
2
9457
by: Carl Gilbert | last post by:
Hi I am looking for either a component or technique to allow me to do the following: * Provide a panel with a background image * Resize the image to best fit the panel to maintain aspect ratio * Provide white (or other color) borders at the sides or the top/bottom The last point would be used to allow users to resize the panel to any ratio
15
5363
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
1
3778
by: Arjen | last post by:
Hi, I want to resize an image on my server. I tried a lot of samples... but all the time it does resize and saves the images but I can not view the image insize a webbrowser. With an imageviewer (desktop application) I can view the image. I believe there is something wrong with the maximum colors... This is what I have now... Image originalBitmap = Image.FromFile("C:\temp\image.jpg", true);
2
2513
by: Tim Arnold | last post by:
Hi, I'm using the Image module to resize PNG images from 300 to 100dpi for use in HTML pages, but I'm losing some vertical and horizontal lines in the images (usually images of x-y plots). Here's what I do: import Image def imgResize(self,filename): img = Image.open(filename) dpi = img.info.get('dpi') if dpi and 295 < int(dpi) < 305:
2
20909
by: Dominic Vella | last post by:
Hi, I know I seem to have the really complicated questions, but I guess that's why I'm here. This is a little verbose, only because I've been trying to crack this for a week now. Your help would be appreciated. I've been trying numerous ways to resize images, as I want to make store thumbnails, not full images in my database. -----------------------------------------------------------------------------
8
9429
by: infoseekar | last post by:
Image Resize & Rotation Hi I have 2 scripts, one for Image rotation and other image resize and they both are working. Image resize scripts load the picture and resize it and Image rotation rotate the image by 90 deg. They are two differennt files i.e. resize.php and rotate.php. What I want to do is to combine both rotate.php & resize.php files, so when the script resized the image than it will call rotate script to rotate the...
3
3582
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
Hi! This discussion may help other programmers get a better idea of how to save uploaded images through a website. Why? Well currently, I save 3 versions of every uploaded image on my own little website: 1. Small: DOWNsize of original image to be used as a thumbnail. 2. Medium: DOWNsize of original image to be used as user avatars/icons in forums or profiles.
22
4982
by: simon2x1 | last post by:
i have an image which width is 213 and height is 200 when i echo the image and i resize it echo "<img src='company/$present' width='70' height='68'/>"; the image was not as clear as when it was 213 * 200.how can i make the image clear after i have resize it to 70 * 200.
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.