Tuesday, March 01, 2005
by Nik Kalyani
Tuesday, March 01, 2005 11:30:03 AM (Pacific Standard Time, UTC-08:00)

Microsoft has altered the default security settings for web content running in the 'Local Machine Zone', that is, any web page loaded from a local source such as your hard disk or CD-ROM. The result is a warning message when such a page is loaded. To avoid this message you must place your web page into the secure 'Internet Zone'.  To do this paste the following comment at the start of your html source:

<!-- saved from url=(0014)about:internet -->

 

by Nik Kalyani
Tuesday, March 01, 2005 1:14:05 AM (Pacific Standard Time, UTC-08:00)
If you blog often, then Das Blog and BlogJet are an amazing combination. I only started using BlogJet recently, and I tell you, I am hooked. This is an amazing program. It is quite intuitive and makes blogging very simple and efficient. 
by Nik Kalyani
Tuesday, March 01, 2005 12:31:08 AM (Pacific Standard Time, UTC-08:00)

When DNN 3.x is released, it will be the most-changed of any version in DNN’s short history. In consolidating numerous breaking changes, the Core Team  (of which I am proud to be a member) took it upon itself to also get rid of some legacy baggage that DNN was carrying around from its IBuySpy roots. A richer U.I., Search, static localization, performance optimizations, content syndication and import/export data are some of the cool features that DNN 3.x sports.

There are also some warts such as FriendlyUrls, stylesheets gone crazy and overall inconsistent user interaction.

However, this is to be expected in the evolution of any open source project. Change takes time and improvements come as needs evolve.

If you don’t have a huge dependency on third-party modules, I would highly recommend taking the plunge. DNN 3.x is a fantastic piece of software and will enable you to create websites that are better looking and more feature-rich. I am going to work on upgrading all of my modules as quickly as possible to run on DNN 3.x portals.

 

by Nik Kalyani
Tuesday, March 01, 2005 12:20:18 AM (Pacific Standard Time, UTC-08:00)

Microsoft Word creates awful HTML code. If you need to use it on a web page (especially in an HTML editor), you will want to clean it up a bit. Here’s a Javascript function that will take a string of text copied from Microsoft Word, and return it minus all the extraneous formatting that Word adds:


function cleanWordContent(wordContent)
{

        wordDiv = document.createElement("DIV");
 wordDiv.innerHTML = wordContent;

 for (var i=0;i<wordDiv.all.length;i++)
 {
  wordDiv.all[i].removeAttribute("className","",0);
  wordDiv.all[i].removeAttribute("style","",0);
 }
 wordContent = wordDiv.innerHTML;
 wordContent = String(wordContent).replace(/<\\?\?xml[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?o:p[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?v:[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?o:[^>]*>/g,"");
 wordContent = String(wordContent).replace(/&nbsp;/g,"");//<p>&nbsp;</p>
 wordContent = String(wordContent).replace(/<\/?SPAN[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?FONT[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?STRONG[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?P[^>]*><\/P>/g,"");
 wordContent = String(wordContent).replace(/<\/?H1[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?H2[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?H3[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?H4[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?H5[^>]*>/g,"");
 wordContent = String(wordContent).replace(/<\/?H6[^>]*>/g,"");

 return(wordContent);

}

 

by Nik Kalyani
Tuesday, March 01, 2005 12:15:14 AM (Pacific Standard Time, UTC-08:00)

.Net allows you to do some amazing things with graphics using GDI+. Its handling of image meta data leaves something to be desired though. It’s like they started to do something, but then abandoned it mid-way. In working on the Speerio File Manager Pro (for ASP.Net and DotNetNuke) product’s imaging functions, after considerable research, I decided that Omar Shahine’s PhotoLibrary was the best fit. It has some excellent functions especially in the EXIF area.

After playing with it for a while, I was disappointed to find that it, like just about every other EXIF-handler Google can find, does not preserve EXIF data on resize and rotate operations. I saw some commercial .Net components did it, so I knew could be done. But hours of searching later, all I knew for certain is that GDI+ can read EXIF data, but cannot write it to a new image. Bummer!

Not being one to give up easily, I experimenting a bit, and am pleased to have come up with a solution. Here is my JPEG resizing code which preserves EXIF data:

public static void ResizeJpeg(string filePath, int width, int height)
{
try

{

System.Drawing.Image imgPhoto = System.Drawing.Image.FromFile(filePath);

int sourceWidth = imgPhoto.Width;

int sourceHeight = imgPhoto.Height;

if (height == -1)

height = (int) ((float) sourceHeight * ((float) width/ (float) sourceWidth));

if (width == -1)

width = (int) ((float) sourceWidth * ((float) height/ (float) sourceHeight));

int sourceX = 0;

int sourceY = 0;

int destX = 0;

int destY = 0;

float nPercent = 0;

float nPercentW = 0;

float nPercentH = 0;

nPercentW = ((float)width/(float)sourceWidth);

nPercentH = ((float)height/(float)sourceHeight);

//if we have to pad the height pad both the top and the bottom

//with the difference between the scaled height and the desired height

if(nPercentH < nPercentW)

{

nPercent = nPercentH;

destX = (int)((width - (sourceWidth * nPercent))/2);

}

else

{

nPercent = nPercentW;

destY = (int)((height - (sourceHeight * nPercent))/2);

}

int destWidth = (int)(sourceWidth * nPercent);

int destHeight = (int)(sourceHeight * nPercent);

Bitmap bmPhoto = new Bitmap(imgPhoto, width, height);

bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);

Graphics grPhoto = Graphics.FromImage(bmPhoto);

grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;

grPhoto.DrawImage(imgPhoto,

new Rectangle(destX,destY,destWidth,destHeight),

new Rectangle(sourceX,sourceY,sourceWidth,sourceHeight),

GraphicsUnit.Pixel);

grPhoto.Dispose();

try

{

foreach (PropertyItem propertyItem in imgPhoto.PropertyItems)

{

try

{

bmPhoto.SetPropertyItem(propertyItem);

}

catch{}

}

}

catch{}

System.Drawing.Imaging.Encoder enc = System.Drawing.Imaging.Encoder.Quality;

System.Drawing.Imaging.EncoderParameters encParms = new EncoderParameters(1);

System.Drawing.Imaging.EncoderParameter encParm = new EncoderParameter(enc,100L);

encParms.Param[0] = encParm;

ImageCodecInfo[] codecInfo = ImageCodecInfo.GetImageEncoders();

ImageCodecInfo codecInfoJpeg = codecInfo[1];

bmPhoto.Save(filePath+".tmp",codecInfoJpeg, encParms);

bmPhoto.Dispose();

imgPhoto.Dispose();

FileInfo fileInfo = new FileInfo(filePath);

fileInfo.Delete();

fileInfo = new FileInfo(filePath+".tmp");

fileInfo.MoveTo(filePath);

}

catch{}

}

RSS feed
Search and Links
Bling

View Nik Kalyani's profile on LinkedIn

Contact me: nik*kalyani.com (replace "*")

TechBubble
www.flickr.com
This is a Flickr badge showing public photos from techbubble. Make your own badge here.
Statistics
Total Posts: 204
This Year: 22
This Month: 0
This Week: 0
Comments: 231
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008
Nik Kalyani
Sign In
All Content © 2008, Nik Kalyani