I haven't tried out this code yet, but here's the concept:
var myPopup = window.open("", "MsgWindow", "width=100, height=100, resizable=1, scrollbars=1, menubar=1");
myPopup.document.write(
'<script language="Javascript" type="text/javascript">' +
'function getElementById(id)' +
'{' +
' if (document.getElementById != null)' +
' return document.getElementById(id)' +
' if (document.all != null)' +
' return document.all[id]' +
' alert("Problem getting element by id")' +
' return null' +
'}' +
'function resizeImage()' +
'{' +
' var elem = getElementById("pic");' +
' if(elem)' +
' {' +
' var h = elem.clip ? elem.clip.height : elem.offsetHeight;' +
' var w = elem.clip ? elem.clip.width : elem.offsetWidth;' +
' myPopup.resizeTo( w, h );' +
' var myWidth = 0, myHeight = 0, d = myPopup.document.documentElement, b = myPopup.document.body;' +
' if( myPopup.innerWidth ) ' +
' { ' +
' myWidth = myPopup.innerWidth; ' +
' myHeight = myPopup.innerHeight; ' +
' }' +
' else if( d && d.clientWidth ) ' +
' { ' +
' myWidth = d.clientWidth; ' +
' myHeight = d.clientHeight; ' +
' }' +
' else if( b && b.clientWidth ) ' +
' { ' +
' myWidth = b.clientWidth; ' +
' myHeight = b.clientHeight; ' +
' }' +
' myPopup.resizeTo(6+ w + ( w - myWidth ),6+ h + ( h - myHeight ) );' +
' }' +
'}' +
'</script>'
);
myPopup.document.write("<img id='pic' src='images/images/szafa.png'>");
myPopup.document.body.onLoad='resizeImage';
Alternatively, you could create a PHP script that outputs the HTML above and passes the image name as a URL query parameter to the script.