private void ResizeImages(FileInfo thisPhotoFile, PhotoDetail thisPhoto) { //resize to temp folder //make the small images as markers if (IncludeThumbnails) { var imgresized = ImageMethods.ResizeImageFile(thisPhotoFile, thumbSize, thumbSize); ImageMethods.SaveOutputImage(thisPhoto.ThumbnailFilename, imgresized, 60L); } //now make the popout images { var imgresized = ImageMethods.ResizeImageFile(thisPhotoFile, PopoutImagesize, PopoutImagesize); ImageMethods.SaveOutputImage(thisPhoto.ImageFilename, imgresized, 80L); } }
/// <summary> /// create a KML placemark with thumbnail or std icon /// </summary> /// <param name="pd"></param> /// <returns></returns> private string GetPlaceMark(PhotoDetail pd) { StringBuilder sb = new StringBuilder(@" <Placemark>"); sb.AppendLine(@" <description>"); sb.Append(@" <![CDATA[<br>"); if (PhotoFilename_asDescription) { sb.AppendFormat("<b>{0}</b>", pd.Description); } if (IncludeDateonpopout) { sb.AppendLine("<span style='padding-left:5em;font-style:italic;'>" + pd.DateTaken.ToString("ddd dd-MMM-yyyy HH:mm") + "</span>"); } sb.Append(@"<br><table><tr><td><img src='" + pd.ImageFilename.Replace(tempFolder + @"\", @"") + "'></td></tr></table>]]>"); sb.AppendLine(); sb.AppendLine(@" </description>"); sb.AppendLine(@" <Snippet maxLines='0'></Snippet>"); sb.AppendLine(@" <name>" + pd.DateTaken.ToString("ddd dd-MMM-yyyy HH:mm") + "</name>"); sb.AppendLine(@" <LookAt>"); sb.AppendLine(@" <longitude>" + pd.longitude.ToString() + "</longitude>"); sb.AppendLine(@" <latitude>" + pd.latitude.ToString() + "</latitude>");; sb.AppendLine(@" <range>500</range>"); sb.AppendLine(@" <tilt>40</tilt>"); sb.AppendLine(@" <heading>0</heading>"); sb.AppendLine(@" </LookAt>"); sb.AppendLine(@" <visibility>1</visibility>"); sb.AppendLine(@" <open>0</open>"); sb.AppendLine(@" <styleUrl>#vtgStyleMap</styleUrl>"); sb.AppendLine(@" <Style> <IconStyle><Icon><href>" + pd.ThumbnailFilename.Replace(tempFolder + @"\", @"") + "</href></Icon></IconStyle> <BalloonStyle><text><![CDATA[$[description]]]></text></BalloonStyle></Style>"); sb.AppendLine(@" <Point>"); sb.AppendLine(@" <extrude>0</extrude>"); sb.AppendLine(@" <tessellate>0</tessellate>"); sb.AppendLine(@" <altitudeMode>clampToGround</altitudeMode>"); sb.AppendLine(@" <coordinates>" + pd.longitude.ToString() + "," + pd.latitude.ToString() + ",0</coordinates>"); sb.AppendLine(@" </Point>"); sb.AppendLine(@" </Placemark>"); return(sb.ToString()); }
private void Makelist(DirectoryInfo di) { RaiseProgress("Creating image list..", 10); FileInfo[] availFiles = di.GetFiles(); int maxFiles = availFiles.Length; int filenum = 0; #region make the list foreach (FileInfo thisPhotoFile in di.GetFiles()) { filenum++; int percentdone = Convert.ToInt32(filenum * 100.0 / maxFiles); if (filenum % 5 == 0) { RaiseProgress(string.Format("processing image #{0}", filenum), Convert.ToInt32(10 + percentdone / 2)); } PhotoDetail thisPhoto = new PhotoDetail { latitude = -99 //cant be plotted }; //test if it is a valid image switch (thisPhotoFile.Extension.ToUpper()) { case ".JPG": case ".JPEG": case ".TIFF": thisPhoto.Description = thisPhotoFile.Name; Exif_Ext.EXIF_Data exif = new Exif_Ext.EXIF_Data(thisPhotoFile.FullName); DateTime dateTaken = exif.CameraDate; if (exif.GPSLatitude == 0) { break; } if (exif.GPSLatitude == -999) { break; } //if(exif.GPSUTCDate > DateTime.MinValue && UseGPSDate) //{ // dateTaken = GPSMethods.GetLocalTimefromGPS(exif.GPSLatitude, exif.GPSLongitude, exif.GPSUTCDate); //} thisPhoto.latitude = exif.GPSLatitude; thisPhoto.longitude = exif.GPSLongitude; thisPhoto.DateTaken = dateTaken; if (SortByDateTaken) { thisPhoto.keyid = thisPhoto.DateTaken.ToString("yyyyMMdd-HHmmss"); } else { thisPhoto.keyid = thisPhoto.Description; } break; default: //ignore unsupperted files break; } //now attempt to load to the list. may generate duplicate key. int retry = 0; string originalkeyid = thisPhoto.keyid; if (thisPhoto.latitude > -99) { do { if (retry > 0) { thisPhoto.keyid = string.Format("{0}{1:00}", originalkeyid, retry); } thisPhoto.ThumbnailFilename = Path.Combine(thumbFolder, thisPhoto.keyid + thisPhotoFile.Extension); thisPhoto.ImageFilename = Path.Combine(imageFolder, thisPhoto.keyid + thisPhotoFile.Extension); try { //save the data to the Sorted list inputPhotos.Add(thisPhoto.keyid, thisPhoto); retry = 0; } catch (ArgumentException) { retry++; } catch (Exception ex) { Console.WriteLine(ex.ToString()); throw; } } while (retry > 0); //now have unique id, create the smaller images and thumbnails ResizeImages(thisPhotoFile, thisPhoto); } } #endregion }