473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

tag or attribut for correct Image-size

Hi all,

I have a php-generated webpage with images. My problem is: the Internet
Explorer cannot calculate the correct image size. Because of this the
images are not cached. So everytime a user clicks on some link all the
images gets retransfered and the page loads very slow.
You can check it if you right-click on an image and select properties.

Is there a possibility to send the image and its actual
size-information to the browser?

I hope this is somehow clear.

thanks in advance
Klaus

Sep 11 '06 #1
9 1483
In article
<11*********************@b28g2000cwb.googlegroups. com>,
"kl**************@googlemail.com"
<kl**************@googlemail.comwrote:
Hi all,

I have a php-generated webpage with images. My problem is: the Internet
Explorer cannot calculate the correct image size. Because of this the
images are not cached. So everytime a user clicks on some link all the
images gets retransfered and the page loads very slow.
You can check it if you right-click on an image and select properties.

Is there a possibility to send the image and its actual
size-information to the browser?

I hope this is somehow clear.
If you are using PHP, then you should know above average stuff
about HTML (PHP being something a bit more sophisticated server
side control) like that in the mark up for images, the width and
height attributes are quite important and are best specified
exactly. It sounds like your PHP is not properly serving up the
HTML. Browsers are not great image editors and it is best to tell
the browser the exact width and height. In general.

--
dorayme
Sep 11 '06 #2
kl**************@googlemail.com <kl**************@googlemail.comscripsit:
I have a php-generated webpage with images.
Do you have a URL for it?
My problem is: the
Internet Explorer cannot calculate the correct image size.
Our problem is that we cannot see your real problem since you did not
specify the URL and did not explain why you think that Internet Explorer
cannot calculate the correct image size.
Because of this the images are not cached.
And what makes you think so? I see little reason to expect image size to
have anything to do with cacheing, which operates on "entities" referred to
by URLs (btw, did I mention that you didn't mention the URL of your page?),
_not_ to their specific content, still less rendering.
So everytime a user clicks on some
link all the images gets retransfered and the page loads very slow.
Is there any reason to think that the images are "the same" as images that
have already been fetched by the browser? Cacheing works by URLs and HTTP
headers, not content. So if you have the same image accessible through
different URLs*), they are not the same from the cacheing perspective. Image
sizes have nothing to do with this.

*) "URL" here means the resolved absolute URL, which may differ from the
URLs in the src="..." attributes.
You can check it if you right-click on an image and select properties.
I cannot, because you did not specify any URL and you did not say what is
the "it" that I could check.
Is there a possibility to send the image and its actual
size-information to the browser?
Yes, that's what servers do all the time.
I hope this is somehow clear.
It isn't. It would be somewhat obscure even with a URL, but without a URL...

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Sep 11 '06 #3
Rik
kl**************@googlemail.com wrote:
Hi all,

I have a php-generated webpage with images. My problem is: the
Internet Explorer cannot calculate the correct image size. Because of
this the images are not cached. So everytime a user clicks on some
link all the images gets retransfered and the page loads very slow.
You can check it if you right-click on an image and select properties.
I wouldn't know ether this is the problem.
Is there a possibility to send the image and its actual
size-information to the browser?
ob_start();
imagejpeg(); //(/...png()/...gif())
header('Content-type: image/jpeg');
header('Content-length: '.ob_get_length());
ob_flush();

Grtz,
--
Rik Wasmus
Sep 11 '06 #4
kl**************@googlemail.com wrote:
Hi all,

I have a php-generated webpage with images. My problem is: the Internet
Explorer cannot calculate the correct image size. Because of this the
images are not cached. So everytime a user clicks on some link all the
images gets retransfered and the page loads very slow.
You can check it if you right-click on an image and select properties.

Is there a possibility to send the image and its actual
size-information to the browser?

I hope this is somehow clear.

thanks in advance
Klaus
You mean such as:

<img src="/images/image1.gif" width=150 height="200" alt="My Image">

Straight html - nothing to do with PHP.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 11 '06 #5
dorayme wrote:
My problem is: the Internet
Explorer cannot calculate the correct image size.
Is there a possibility to send the image and its actual
size-information to the browser?
If you are using PHP, then you should know above average stuff
about HTML
Not certain about this, but AFAIR the IE image non-caching problem is
related to file size, not image size. It's _not_ a HTML problem and you
can't solve it by using the <img width... height... attributes. So
it's a HTTP problem, not a HTML problem.

_AFAIR_ (you should probably check this, as it's years since I hit
this problem)
IE doesn't cache things it doesn't know the storage size of. For images
it finds this from a HTTP header which is sent before the image data.
If your image is dynamically generated, then you won't know the size
until it has been generated. If you code in the easy and obvious
manner, you omit the header and just start writing image data back as
fast as you create it. IE manages to display this, but it won't cache
it.

The fix is to generate it on the server as a PHP variable, find the
size of it, write the size back in a HTTP header, then write the image
data in the HTTP response.

Sep 11 '06 #6
Jukka K. Korpela wrote:
>I hope this is somehow clear.
It isn't. It would be somewhat obscure even with a URL, but without a
URL...
You need to add WIDTH and HEIGHT attributes to your <IMGtags. If you
generate your html through PHP, you'll need to code something like this:

$myimage="myfolder\mypic.jpg";
$size = getimagesize($myimage);
$width = $size[0];
$height = $size[1];
echo "<img src=$myimage width=$width height=$height>";

I have not tested this code snippet, but you get the idea. It requires
the function getimagesize() (which is not part of the PHP core, but
pretty common these days) to be available on your server.

--
Gregor mit dem Motorrad auf Reisen:
http://hothaus.de/greg-tour/
Sep 11 '06 #7
Greg N. wrote:
Jukka K. Korpela wrote:

>>I hope this is somehow clear.

>It isn't. It would be somewhat obscure even with a URL, but without a
URL...

You need to add WIDTH and HEIGHT attributes to your <IMGtags. If you
generate your html through PHP, you'll need to code something like this:

$myimage="myfolder\mypic.jpg";
$size = getimagesize($myimage);
$width = $size[0];
$height = $size[1];
echo "
There is also a nice shortcut:

<img src=$myimage $size[3]>";
getimagesize ... "Returns an array with 4 elements ...
.... Index 3 is a text string with the correct height="yyy" width="xxx"
string that can be used directly in an IMG tag."

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
*****************************
Sep 12 '06 #8
Greg N. <yo*********@yahoo.comscripsit:
Jukka K. Korpela wrote:
>>I hope this is somehow clear.
>It isn't. It would be somewhat obscure even with a URL, but without a
URL...

You need to add WIDTH and HEIGHT attributes to your <IMGtags.
No I don't. You seem to have no idea of I what I wrote in my message, and
you quoted something that you don't comment on.

And your message has nothing to do with the problem posed, though it seems
to involve a misconception that the original poster also had.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Sep 12 '06 #9
Thanks everyone for trying to answer my question.

The solution (for me) lies not in using the height and width attribute
in the <src>-Tag, because my problem had to do something with the file
size and not with the image size. Sorry for the confusion.

The solution was to send an special header before the actual picture.
So now I use something like this:

<?php
ob_start();
header("Expires: " . date("D, j M Y H:i:s", time() + (86400 * 7)) . "
UTC");
header("Cache-Control: Public");
header("Pragma: Public");
$im = imagecreatefromgif($src);
imagegif($im);
header('Content-type: image/gif');
header('Content-length: ' . ob_get_length());
ob_flush();
?>

And it was an IE caching problem. Now it works pretty well. Special
thanks goes to Andy Dingley and Rik.

Klaus

Sep 16 '06 #10

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

Similar topics

5
by: khaled Hajjar | last post by:
Hello, I have this template : <root> <categorie> <poste att = 'true'> ..... </poste> <poste att = 'false'> .....
1
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct...
9
by: Michael Schuerig | last post by:
I'd like to mark input elements with class "invalid" by appending something, say a "?". My understanding is that it should work like this: input.invalid:after { content:"?"; } However, at...
4
by: Tony Johansson | last post by:
Hello experts! I have read in a book that say once a reference attribute has been assigned a value, it cannot be changed but this is wrong I think because I can change a reference attribute see...
6
by: Luis Arvayo | last post by:
Hello, I am trying to convert a jpeg image stored in a PictureBox to a byte array in order to later save it to a database, but I get this error : "Generic Error in GDI+". The source code is...
13
by: Dr. Zharkov | last post by:
Hello. A problem in the following. In VB .NET 2003 we create the project and in file Form1.vb the following code is written down: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As...
8
by: Joe Rattz | last post by:
Ok, I can't believe what I am seeing. I am sure I do this other places with no problems, but I sure can't here. I have some code that is indexing into the ItemArray in a DataSet's DataRow. I...
3
by: Marc Robitaille | last post by:
Hello, I have this Field attribut class and a Client class that uses this Attribut Class <AttributeUsage(AttributeTargets.Property)_ Public Class Field Inherits Attribute Private _FieldName...
1
by: Mel | last post by:
Hi! I have two text boxes and two image buttons. When I click image button 1 or 2 the same popup window is displayed (using 'window.open' method). When I click image button 1 the returning data...
1
by: joansally | last post by:
Anyone wanna help me? this is sort of urgent. I need to correct satellite image pixels. the bad image pixel values are to be replaced by an average of the neighbouring correct pixels. The bad and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.