HtmlString includes a web page, and soon it is converted to Html file.
In the web page, they are images, and some of them are large. They are so large, in fact they are going to destroy my Tables, so I need to resize these images.
I write a Function to do this job.
[COLOR=DarkOrang e]Resizeimage(Htm lString)[/COLOR]
[COLOR=SeaGreen]Function Resizeimage(Con Str)
Dim TempStr,Re,Matc hes,Match,Tempi ,TempArray
Set Re = New Regexp
Re.IgnoreCase = True
Re.Global = True
Re.Pattern ="<img.+?[^\>]>"
Set Matches =Re.Execute(Con Str)
For Each Match in Matches
If TempStr<>"" then
TempStr=TempStr & "$Array$" & Match.Value
Else
TempStr=Match.V alue
End if
Next
If TempStr<>"" Then
TempArray=Split (TempStr,"$Arra y$")
TempStr=""
For Tempi=0 To Ubound(TempArra y)
Re.Pattern ="src\s*=\s*.+? \.(gif|jpg|bmp| jpeg|psd|png|sv g|dxf|wmf|tiff) "
Set Matches =Re.Execute(Tem pArray(Tempi))
For Each Match in Matches
If TempStr<>"" then
TempStr=TempStr & "$Array$" & Match.Value
Else
TempStr=Match.V alue
End if
Next
Next
End if
If TempStr<>"" Then
Re.Pattern ="src\s*=\s* "
TempStr=Re.Repl ace(TempStr,"")
End If
Set Matches=nothing
Set Re=nothing
If TempStr="" or IsNull(TempStr) =True Then
ReplaceSaveRemo teFile=ConStr
Exit function
End if
TempStr=Replace (TempStr,""""," ")
TempStr=Replace (TempStr,"'","" )
TempStr=Replace (TempStr," ","")
Dim PathTemp
TempArray=Split (TempStr,"$Arra y$")
TempStr=""
For Tempi=0 To Ubound(TempArra y)
If Instr(Lcase(Tem pStr),Lcase(Tem pArray(Tempi))) <1 Then
TempStr=TempStr & "$Array$" & TempArray(Tempi )
End If
Next
TempStr=Right(T empStr,Len(Temp Str)-7)
TempArray=Split (TempStr,"$Arra y$")
Set Re = New Regexp
Re.IgnoreCase = True
Re.Global = True
For Tempi=0 To Ubound(TempArra y)
Re.Pattern =TempArray(Temp i)
PathTemp=TempAr ray(Tempi)
PathTemp=PathTe mp&"' onclick='javasc ript:window.ope n(this.src);' onload='javascr ipt:if(this.wid th>screen.width-300)this.style. width=screen.wi dth-300;"
ConStr=Re.Repla ce(ConStr,PathT emp)
Next
Set Re=nothing
Resizeimage=Con Str
End function[/COLOR]
this founction works well with the first few files,but I met problem soon.
2 3502
this function deal with this kind [COLOR=Navy]<img src='xxxx/2005081723/200508172347417 16.jpg'/>[/COLOR] images well.
but not this one:
[COLOR=Navy]<img src="xxxx/2005081723/200508172347417 16.jpg"/>[/COLOR] (with ")
nor this one:
[COLOR=Navy]<img src='xxxx/2005081723/200508172347417 16.jpg' onload="javascr ipt:if(this.wid th>screen.width-300)this.style. width=screen.wi dth-300;"/>[/COLOR] (with resize script already)
How can I improve my function to fit these codes?
Or do you have any better solution?
I find this simpler Function:
[COLOR=DarkOrchi d]Function bbimg(strText,s size)
Dim Re
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
Dim s
s=strText
re.Pattern="<im g(.[^>]*)>"
s=re.replace(s, "<img$1 onclick=""javas cript:window.op en(this.src);"" onload=""javasc ript:if
(this.width>scr een.width-"&ssize&")this. style.width=scr een.width-"&ssize&";" ">")
bbimg=s
End Function[/COLOR]
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: rams.kakara |
last post by:
hi,
My page have background image,on that image have more images and
text. My problem is whenever resize browser that images are not resized
and also not moved correct place .(i.e look not like before
alignment).I want to do everything in dyanamic. please help me.
urs..
Rams
|
by: David Hayes |
last post by:
juglesh <juglesh@nospamRadioKDUG.com> wrote in "Re: how to maximize the
browser window that fits the monitor size?" (Saturday, January 01, 2005 3:12
AM):
>
> >I want to maximize the browser window when I open a new window.
>
> function expand() {
> window.moveTo(0,0);
> window.resizeTo(screen.availWidth, screen.availHeight);
> }
|
by: SlasherStanley |
last post by:
BlankHi
How do you resize a jpg file. I want to open a file (c:\abc.jpg 800 x 600) and resize it as 120 x 100, I then want to save it as c:\abc_t.jpg.
Thanks
Slasher
|
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?
|
by: rbt |
last post by:
What's a good way to resize pictures so that they work well on html
pages? I have large jpg files. I want the original images to remain as
they are, just resize the displayed image in the browser.
| |
by: eholz1 |
last post by:
Hello PHP group,
I am using some php code to check the size of images, and then
resize or determine new dimension for the image. GD seems quite slow.
It takes about 5 seconds (plus or minus) to calulate dimension for 7
jpeg images.
I have a 700mhz processor (Pentium III, remember those??)! with almost
a gb of memory.
Is that the way GD is??? Here is a snippet of the dode I use: I pass
|
by: Bob Bedford |
last post by:
Hi all,
I've to resize uploaded images with the "imagecopyresampled" but when I've
images quite large (common those days) I reach the 16mb limits of the ISP.
How can I fix this ? I absolutely need to resize such images.
Bob
|
by: Noorain |
last post by:
Sir
i want to resize image. Following script working in my local server. But This coding doesn't work in php 2.6.0. please help me
<form action="<?php echo $_server; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
<input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
<button name="submit" type="submit" class="submitButton">Upload/Resize Image</button>
</form>...
|
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.
|
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...
|
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...
| |
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |