[pmwiki-users] automatically generate image width/height?

Patrick R. Michaud pmichaud at pobox.com
Wed Dec 6 19:09:46 CST 2006


On Wed, Dec 06, 2006 at 09:32:00PM +0000, Lucian Wischik wrote:
> I wonder if it would be useful for pmwiki to inspect .gif/.jpg
> images that it attaches, look at their headers, read their dimensions,
> and use these dimensions to emit
>   <img src="pic.gif" width=100 height=200>
> for
>   Attach:pic.gif
> 
> That way the web-client would get the benefit of correctly-sized
> image placeholders, the wiki author would get the benefit of
> not having to specify image sizes, and it'd only impose a little
> extra burden on the webserver to read about 100 bytes per image.
> 
> Is such a thing already written? What do people think?

The biggest obstacle is that this can only work for images where
PmWiki knows the location of the image -- i.e., attachments.
For images that are obtained via http:// or some other web
address, PmWiki can't easily get the image size (except by doing
a separate fetch of the image, which probably isn't a good idea).

There's also the issue that many PHP configurations don't have
the image processing libraries enabled, so there's not a reliable 
method to inspect the .gif/.jpg images.  (Yes, we could choose to
not generate width/height when the libraries aren't present, but
it is another consideration.)

Lastly we'd have to handle the case where an author chooses to override
the width/height via a wikistyle, which complicates things even
more, because the wikistyle code has to be able to look at the
<img ... /> tag and remove any existing width/height values that
may be present.  Doable, but still messy.

I've thought about trying to enable automatic calculation of
width/height for attachments, but it introduces enough complications
into the overall processing that I've let it go for now.

Pm




More information about the pmwiki-users mailing list