 |
 |
AppleScript: Reset Height, Width of <img> Tags
|
 |
|
 |
|
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status:
Offline
|
|
Does anybody where I could find an AppleScript that does this:
Loops through all the <img> tags in an HTML document and retrieve the current width and height attributes of the image referenced by the tag, and insert those values in the appropriate place.
So say you have this:
<img src="images/my_image.gif" height="32" width ="68">
but the image's real height is 190 and its width is 223, the script would change it to:
<img src="images/my_image.gif" height="190" width ="223">
Thanks.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Nov 2001
Location: Oregon
Status:
Offline
|
|
Hmmm, that might be a useful script. Let's see, what would be the easiest way to grab an image's dimensions? I could probably throw such an AppleScript together if there's an easy way to fetch the image's dimensions.
It would probably be easiest to implement the script as a droplet, so it parses each file you toss on its icon. Of course it would have to handle relative as well as absolute references to the graphic. Relative references would be relative to the HTML file on the local HD, but absolute references would have to look on the net for the file. This may be more of a problem. Although i suppose it could look for an HTML comment tag containing a root directory on the local HD to use for absolute images. Yeah, it could be done (provided there's an easy way to read the image's dimensions).
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status:
Offline
|
|
Well, I discovered that the latest version of Lasso has a built-in function for fetching all kinds of info about an image (including height and width --- yay!) on the server side, so I went with that. No muss, no fuss -- it works great.
Still, this client side AppleScript we're talking about would help a lot of web designers who want to do all that before uploading the images to a server.
Maybe ImageEvents under Panther would allow this? I'll bet it would.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
Originally posted by selowitch:
Well, I discovered that the latest version of Lasso has a built-in function for fetching all kinds of info about an image (including height and width --- yay!) on the server side, so I went with that. No muss, no fuss -- it works great.
Still, this client side AppleScript we're talking about would help a lot of web designers who want to do all that before uploading the images to a server.
Maybe ImageEvents under Panther would allow this? I'll bet it would.
PHP has that too - if you're making pages that will get lots of hits, though, having a server-side script that fetches image size has the potential to give quite a performance hit. I'd do it only if you're unsure of the destination image's size, or it changes frequently (eg. a dynamic folio page)
|
|
Computer thez nohhh...
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Nov 2001
Location: Oregon
Status:
Offline
|
|
I'm still using Jaguar as my Mac doesn't (officially) support Panther... Haven't gotten around to installing Panther with XPostFacto yet.
I think there's probably a way to read the image size info using Perl, but i'm not completely sure.
And isn't Safari's rendering engine part of the OS? There's probably a way to get at it that way too.
I'm sure there must be a way somehow, without resorting to third party software.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Location: London
Status:
Offline
|
|
ImageEvents can tell you the Dimensions of an Image via AppleScript.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Nov 2001
Location: Oregon
Status:
Offline
|
|
Originally posted by Diggory Laycock:
ImageEvents can tell you the Dimensions of an Image via AppleScript.
But it requires Panther.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|