public static Bitmap ResizeImage(Stream imageStream, PhotoSize size) { var maxHeight = 0; var maxWidth = 0; switch (size) { case PhotoSize.Medium: maxHeight = 225; maxWidth = 225; break; case PhotoSize.Fullsize: break; default: maxHeight = 125; maxWidth = 125; break; } var rs = new ResizeSettings(); if (maxHeight > 0) { rs.MaxHeight = maxHeight; rs.MaxWidth = maxWidth; } return ImageBuilder.Current.Build(imageStream, rs); }
public static string GetFilePath(int photoId, bool forUrl, PhotoSize size) { string result = null; string filenameToken; if (size == PhotoSize.Full) filenameToken = "Lg"; else if (size == PhotoSize.Medium) filenameToken = "Md"; else filenameToken = "Sm"; SiteSettings s = SiteSettings.GetSharedSettings(); { if (forUrl) { result = String.Format("{0}/{1}/{2}.{3}.jpg", ClassifiedsHttpApplication.SiteUrl, s.ServerPhotoUploadDirectory, photoId, filenameToken); } else { HttpContext context = HttpContext.Current; if (context != null) { string serverDirectory = context.Server.MapPath(s.ServerPhotoUploadDirectory); string file = String.Format("{0}.{1}.jpg", photoId, filenameToken); result = Path.Combine(serverDirectory, file); } } } return result; }
public static byte[] GetPhotoBytesById(int photoId, PhotoSize size) { using (PhotosDataAdapter db = new PhotosDataAdapter()) { return db.GetPhotoBytesById(photoId, (int)size) as byte[]; } }
public async Task<List<string>> GetPhotosByKeyword(string keyword, PhotoSize photoSize, int resultsPerPage, int pageNumber) { List<string> photosUrls = new List<string>(); string imageSearchUrl = $"https://{FLICKR_API_BASE_URL}?method={FLICKR_SEARCH_METHOD}&api_key={FLICKR_API_KEY}&per_page={resultsPerPage}&page={pageNumber}&tags={keyword}&format={FLICKR_RESPONSE_FORMAT}"; string responseString; using (HttpClient httpClient = GetHttpClient()) { httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await httpClient.GetAsync(imageSearchUrl); responseString = await response.Content.ReadAsStringAsync(); } if (string.IsNullOrEmpty(responseString)) { return photosUrls; } var startJson = responseString.IndexOf('{'); var endJson = responseString.LastIndexOf('}'); var jsonString = responseString.Substring(startJson, endJson - startJson + 1); FlickrReturnObject flickrReturnObject = JsonConvert.DeserializeObject<FlickrReturnObject>(jsonString); foreach (FlickrPhoto flickrPhoto in flickrReturnObject.FlickrPhotos.Photos) { string photoSizeSuffix = string.Empty; switch (photoSize) { case PhotoSize.Small: photoSizeSuffix = "n"; break; case PhotoSize.Medium: photoSizeSuffix = "c"; break; case PhotoSize.Large: photoSizeSuffix = "b"; break; case PhotoSize.ExtraLarge: photoSizeSuffix = "h"; break; case PhotoSize.ExtraExtraLarge: photoSizeSuffix = "k"; break; } string photoUrl = $"https://farm{flickrPhoto.Farm}.staticflickr.com/{flickrPhoto.Server}/{flickrPhoto.Id}_{flickrPhoto.Secret}_{photoSizeSuffix}.jpg"; photosUrls.Add(photoUrl); } return photosUrls; }
/// <summary> /// Returns the Photo based on the requested size /// </summary> /// <param name="size">Size of demanded photo</param> /// <returns>Photo in the requested photo</returns> public object Get(PhotoSize size) { if (Type == PhotoType.Artwork && size == PhotoSize.Tiny18 || Type == PhotoType.Avatar && (size == PhotoSize.Square67 || size == PhotoSize.Tiny20)) throw new ArgumentException($"{Type.ToString()} Photo cannot be in size {_parser.ToString(size)}"); var fullLink = $"{Link}/{_parser.ToString(size)}"; //TODO: Download the photo from that moment. throw new NotImplementedException("Downloading the Photo is missing."); }
public static Size GetThumbailSize(PhotoSize size) { switch (size) { case PhotoSize.Small: return new Size(100, 100); case PhotoSize.AvatarStandart: return new Size(500, 500); case PhotoSize.Standart: default: return new Size(255, 255); } }
public static FileContentResult GetHeroPhoto(string uri, PhotoSize size) { try { var wr = WebRequest.Create(uri); using (var response = wr.GetResponse()) { var bmp = ResizeImage(response.GetResponseStream(), size); return new FileContentResult(bmp.ToByteArray(), MediaTypeNames.Application.Octet); } } catch { return null; } }
IList<Photo> IPhotoRepository.GetMostInteresting(int index, int itemsPerPage, PhotoSize size) { string method = Helper.GetExternalMethodName(); string requestUrl = BuildUrl(method, "page", index.ToString(), "per_page", itemsPerPage.ToString()); IList<Photo> photos = new List<Photo>(); try { photos = GetPhotos(requestUrl, size).ToList<Photo>(); } catch (Exception ex) { throw new Exception(ex.Message); } return photos; }
public CameraCaptureUIMaxPhotoResolution GetMaxResolution(PhotoSize photoSize, int customPhotoSize) { if (photoSize == PhotoSize.Custom) { if (customPhotoSize <= 25) { photoSize = PhotoSize.Small; } else if (customPhotoSize <= 50) { photoSize = PhotoSize.Medium; } else if (customPhotoSize <= 75) { photoSize = PhotoSize.Large; } else { photoSize = PhotoSize.Large; } } if (photoSize == PhotoSize.MaxWidthHeight) { photoSize = PhotoSize.Full; } switch (photoSize) { case PhotoSize.Full: return(CameraCaptureUIMaxPhotoResolution.HighestAvailable); case PhotoSize.Large: return(CameraCaptureUIMaxPhotoResolution.Large3M); case PhotoSize.Medium: return(CameraCaptureUIMaxPhotoResolution.MediumXga); case PhotoSize.Small: return(CameraCaptureUIMaxPhotoResolution.SmallVga); } return(CameraCaptureUIMaxPhotoResolution.HighestAvailable); }
private static WebImage ResizePhoto(PhotoSize photoSize, byte[] blobBytes) { var webImage = new WebImage(blobBytes); switch (photoSize) { case PhotoSize.Small: webImage = webImage.Resize(64, 64, true, true); break; case PhotoSize.Medium: webImage = webImage.Resize(128, 128, true, true); break; case PhotoSize.Large: webImage = webImage.Resize(256, 256, true, true); break; } return webImage; }
public static Stream ZGetPhoto(int photoid, PhotoSize size) { bool filter = !(HttpContext.Current.User.IsInRole("Friends") || HttpContext.Current.User.IsInRole("Administrators")); Z.PhotoDataContext photoDB = new Z.PhotoDataContext(); Binary result = null; switch (size) { case PhotoSize.Small: result = photoDB.Photos .Where(p => p.PhotoID == photoid) .Where(p => p.Album.IsPublic == filter || p.Album.IsPublic == true) .Select(p => p.BytesThumb).SingleOrDefault(); break; case PhotoSize.Medium: result = photoDB.Photos .Where(p => p.PhotoID == photoid) .Where(p => p.Album.IsPublic == filter || p.Album.IsPublic == true) .Select(p => p.BytesPoster).SingleOrDefault(); break; case PhotoSize.Large: result = photoDB.Photos .Where(p => p.PhotoID == photoid) .Where(p => p.Album.IsPublic == filter || p.Album.IsPublic == true) .Select(p => p.BytesFull).SingleOrDefault(); break; case PhotoSize.Original: result = photoDB.Photos .Where(p => p.PhotoID == photoid) .Where(p => p.Album.IsPublic == filter || p.Album.IsPublic == true) .Select(p => p.BytesOriginal).SingleOrDefault(); break; } try { return(new MemoryStream(result.ToArray())); } catch { return(null); } }
public static PhotoSize GetClosestPhotoSizeWithSize(IList <PhotoSize> sizes, int side, bool byMinSide) { if (sizes == null || sizes.IsEmpty()) { return(null); } int lastSide = 0; PhotoSize closestObject = null; for (int a = 0; a < sizes.Count; a++) { PhotoSize obj = sizes[a]; if (obj == null) { continue; } int w = obj.Width; int h = obj.Height; if (byMinSide) { int currentSide = h >= w ? w : h; if (closestObject == null || side > 100 && side > lastSide && lastSide < currentSide) { closestObject = obj; lastSide = currentSide; } } else { int currentSide = w >= h ? w : h; if (closestObject == null || side > 100 && currentSide <= side && lastSide < currentSide) { closestObject = obj; lastSide = currentSide; } } } return(closestObject); }
// Photo-Related Methods public static Stream GetPhoto(int photoid, PhotoSize size) { return(ZGetPhoto(photoid, size)); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Personal"].ConnectionString)) { using (SqlCommand command = new SqlCommand("GetPhoto", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@PhotoID", photoid)); command.Parameters.Add(new SqlParameter("@Size", (int)size)); bool filter = !(HttpContext.Current.User.IsInRole("Friends") || HttpContext.Current.User.IsInRole("Administrators")); command.Parameters.Add(new SqlParameter("@IsPublic", filter)); connection.Open(); object result = command.ExecuteScalar(); try { return(new MemoryStream((byte[])result)); } catch { return(null); } } } }
public static Stream GetFirstPhoto(int albumid, PhotoSize size) { using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString)) { using (SqlCommand command = new SqlCommand("GetFirstPhoto", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@AlbumID", albumid)); command.Parameters.Add(new SqlParameter("@Size", (int)size)); connection.Open(); object result = command.ExecuteScalar(); try { return(new MemoryStream((byte[])result)); } catch { return(null); } } } }
private static WebImage ResizePhoto(PhotoSize photoSize, byte[] blobBytes) { var webImage = new WebImage(blobBytes); switch (photoSize) { case PhotoSize.Small: webImage = webImage.Resize(64, 64, true, true); break; case PhotoSize.Medium: webImage = webImage.Resize(128, 128, true, true); break; case PhotoSize.Large: webImage = webImage.Resize(256, 256, true, true); break; } return(webImage); }
internal static PhotoSize GetLargest(IEnumerable <PhotoSize> photo) { if (photo == null || photo.Count() == 0) { return(null); } var max = -1; PhotoSize r = null; foreach (var p in photo) { if (p.Height > max) { max = p.Height; r = p; } } return(r); }
private float CalculateResizePercent(PhotoSize photoSize) { var percent = 1.0f; switch (photoSize) { case PhotoSize.Large: percent = .75f; break; case PhotoSize.Medium: percent = .5f; break; case PhotoSize.Small: percent = .25f; break; } return(percent); }
private void UpdateThumbnail(MessageViewModel message, PhotoSize photoSize) { if (photoSize.Photo.Local.IsDownloadingCompleted) { double ratioX = (double)36 / photoSize.Width; double ratioY = (double)36 / photoSize.Height; double ratio = Math.Max(ratioX, ratioY); var width = (int)(photoSize.Width * ratio); var height = (int)(photoSize.Height * ratio); ThumbImage.ImageSource = new BitmapImage(new Uri("file:///" + photoSize.Photo.Local.Path)) { DecodePixelWidth = width, DecodePixelHeight = height, DecodePixelType = DecodePixelType.Logical }; } else if (photoSize.Photo.Local.CanBeDownloaded && !photoSize.Photo.Local.IsDownloadingActive) { message.ProtoService.Send(new DownloadFile(photoSize.Photo.Id, 1)); } }
// nullable public static FileLocation FileLocationGetVideoThumbLocation(VideoConstructor video) { PhotoSize size = video.thumb; if (size.Constructor == Constructor.photoSizeEmpty) { return(null); } if (size.Constructor == Constructor.photoSize) { return(((PhotoSizeConstructor)size).location); } if (size.Constructor == Constructor.photoCachedSize) { return(((PhotoCachedSizeConstructor)size).location); } return(null); }
private bool InternalResize(string filePath, PhotoSize photoSize, int quality) { try { if (photoSize == PhotoSize.Full) { return(false); } var percent = CalculateResizePercent(photoSize); var originalImage = new UIImage(filePath); var originalWidth = originalImage.Size.Width; var originalHeight = originalImage.Size.Height; var finalWidth = (int)(originalWidth * percent); var finalHeight = (int)(originalHeight * percent); using (var resizedImage = InternalResizeToUIImage(originalImage, finalWidth, finalHeight)) { using (var stream = File.Open(filePath, FileMode.Create, FileAccess.ReadWrite)) { var bytesImage = resizedImage.AsJPEG(quality / 100.0f).ToArray(); stream.Write(bytesImage, 0, bytesImage.Length); stream.Close(); } } return(true); } catch (Exception ex) { loggingService.Error(ex); return(false); } }
public async Task <Image> GetProfileImageAsync(int userId) { Image profileImage; try { UserProfilePhotos profilePhotos = await TelegramBot.GetUserProfilePhotosAsync(userId); PhotoSize photoSize = profilePhotos.Photos[0][1]; Telegram.Bot.Types.File profileFile = await TelegramBot.GetFileAsync(photoSize.FileId); Stream imageStream = new MemoryStream(); Telegram.Bot.Types.File getFile = await TelegramBot.GetInfoAndDownloadFileAsync(profileFile.FileId, imageStream); profileImage = Image.FromStream(imageStream); //profileImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg); } catch (Exception ex) { ErrorHandler.SetError(source: "GetProfileImageAsync", error: ex.Message); profileImage = Image.FromFile("unkown.png"); } return(profileImage); }
protected override Photo GetItem() { // default values PhotoSize size = Bucket.Instance.For.Item(PhotoColumns.Photosize).Value == null ? PhotoSize.Square : (PhotoSize)Bucket.Instance.For.Item(PhotoColumns.Photosize).Value; ViewMode viewMode = Bucket.Instance.For.Item(PhotoColumns.Viewmode).Value == null ? ViewMode.Public : (ViewMode)Bucket.Instance.For.Item(PhotoColumns.Viewmode).Value; Photo photo = null; using (IAuthRepository authRepository = repositoryFactory.CreateAuthRepository()) { GenerateToken(viewMode, authRepository); if (Bucket.Instance.For.Item(PhotoColumns.ID).Value != null) { using (IPhotoRepository photoRepository = repositoryFactory.CreatePhotoRepository()) { photo = photoRepository.GetPhotoDetail((string)Bucket.Instance.For.Item(PhotoColumns.ID).Value, size); } } } return(photo); }
public async Task Begin_NotInit() { // Arrange var turnContext = A.Fake <ITurnContext>(); var imageHuntState = new ImageHuntState() { TeamId = 16, CurrentLatitude = 15.2, CurrentLongitude = 56 }; A.CallTo(() => turnContext.GetConversationState <ImageHuntState>()).Returns(imageHuntState); var photoSize1 = new PhotoSize() { FileSize = 15, FileId = "15" }; var photoSize2 = new PhotoSize() { FileSize = 1195247, FileId = "AgADBAADOawxG-RQqVO-4ni8OVZOPOnykBkABDQFk1xY-YUAAR0SAgABAg" }; var activity = new Activity() { ActivityType = ActivityType.Message, ChatId = 15, Pictures = new[] { photoSize1, photoSize2 } }; A.CallTo(() => turnContext.Activity).Returns(activity); // Act await _target.Begin(turnContext); // Assert A.CallTo(() => turnContext.GetConversationState <ImageHuntState>()).MustHaveHappened(); A.CallTo(() => turnContext.ReplyActivity(A <string> ._)).MustHaveHappened(); A.CallTo(() => turnContext.End()).MustHaveHappened(); }
/// <summary> /// calls flickr.photos.getInfo to get the photo object. /// </summary> /// <param name="id"></param> /// <param name="size"></param> /// <returns>Detail of photo</returns> Photo IPhotoRepository.GetPhotoDetail(string id, PhotoSize size) { this.PhotoSize = size; string method = Helper.GetExternalMethodName(); string token = authRepo.Authenticate(Permission.Delete.ToString(), false); string sig = base.GetSignature(method, true, "photo_id", id, "auth_token", token); string requestUrl = BuildUrl(method, "photo_id", id, "auth_token", token, "api_sig", sig); XmlElement doc = elementProxy.GetResponseElement(requestUrl); var query = from photo in doc.Descendants("photo") select new Photo { Id = photo.Attribute("id").Value, FarmId = photo.Attribute("farm").Value, ServerId = photo.Attribute("server").Value, SecretId = photo.Attribute("secret").Value, Title = photo.Element("title").InnerText, User = photo.Element("owner").Attribute("username").Value ?? string.Empty, NsId = photo.Element("owner").Attribute("nsid").Value ?? string.Empty, Description = photo.Element("description").InnerText ?? string.Empty, DateUploaded = photo.Element("dates").Attribute("posted").Value ?? string.Empty, DateTaken = photo.Element("dates").Attribute("taken").Value ?? string.Empty, LastUpdated = photo.Element("dates").Attribute("lastupdate").Value ?? string.Empty, Tags = (from tag in photo.Descendants("tag") select tag.InnerText ?? string.Empty).ToArray(), PhotoSize = size, WebUrl = (from photoPage in photo.Descendants("url") where photoPage.Attribute("type").Value == "photopage" select photoPage.InnerText ).First(), Url = PhotoDetailUrl(photo.Attribute("id").Value, size) }; return(query.Single <Photo>()); }
public async Task CreateActivityFromUpdate_Message_Photo() { // Arrange var photoSize1 = new PhotoSize() { FileId = "fileId1", FileSize = 15 }; var photoSize2 = new PhotoSize() { FileId = "fileId2", FileSize = 150 }; var photoSize3 = new PhotoSize() { FileId = "fileId3", FileSize = 1500 }; var update = new Update() { Message = new Message() { Chat = new Chat() { Id = 15 }, Photo = new [] { photoSize1, photoSize2, photoSize3 } } }; // Act var activity = await _target.CreateActivityFromUpdate(update); // Assert Check.That(activity.ActivityType).Equals(ActivityType.Message); Check.That(activity.Pictures).HasSize(3).And.Contains(update.Message.Photo); Check.That(activity.ChatId).Equals(update.Message.Chat.Id); Check.That(activity.Text).Equals("/uploadphoto"); }
protected void SaveSizes(string Path) { var values = Enum.GetValues(typeof(ImageSizes)); foreach (ImageSizes ps in values) { Type type = ps.GetType(); var info = type.GetMember(ps.ToString()); PhotoSize attr = info[0].GetCustomAttribute <PhotoSize>(); if (!Directory.Exists(Server.MapPath("~/assets/images/" + ps.ToString()))) { Directory.CreateDirectory(Server.MapPath("~/assets/images/" + ps.ToString())); } string ImageToBePath = Server.MapPath("~/assets/images/" + ps.ToString() + "/" + System.IO.Path.GetFileNameWithoutExtension(Path)); if (!System.IO.File.Exists(ImageToBePath)) { ImageBuilder.Current.Build(new ImageJob(Path, ImageToBePath, new Instructions(attr.Command), false, true)); } } }
public static Bitmap ResizeImage(string filePath, PhotoSize photoSize) { var percent = 1.0f; switch (photoSize) { case PhotoSize.Large: percent = .75f; break; case PhotoSize.Medium: percent = .5f; break; case PhotoSize.Small: percent = .25f; break; } var originalImage = BitmapFactory.DecodeFile(filePath); var rotatedImage = Bitmap.CreateScaledBitmap(originalImage, (int)(originalImage.Width * percent), (int)(originalImage.Height * percent), false); originalImage.Recycle(); return(rotatedImage); }
public void Open() { PhotoSize sz = PhotoSize._2560; Bitmap bmp; while ((bmp = this.Load(sz)) == null) { switch (sz) { case PhotoSize._2560: sz = PhotoSize._1280; break; case PhotoSize._1280: sz = PhotoSize._807; break; case PhotoSize._807: sz = PhotoSize._604; break; case PhotoSize._604: sz = PhotoSize._130; break; case PhotoSize._130: return; } } String path = Path.GetTempFileName() + ".png"; bmp.Save(path, ImageFormat.Png); App.Platform.OpenFile(path); }
private static float CalculatePercent(PhotoSize photoSize, int customPhotoSize) { var percent = 1.0f; switch (photoSize) { case PhotoSize.Large: percent = .75f; break; case PhotoSize.Medium: percent = .5f; break; case PhotoSize.Small: percent = .25f; break; case PhotoSize.Custom: percent = (float)customPhotoSize / 100f; break; } return(percent); }
private string GetSizePostFix(PhotoSize size) { string sizePostFx; switch (size) { case PhotoSize.Square: sizePostFx = "_s"; break; case PhotoSize.Small: sizePostFx = "_m"; break; case PhotoSize.Thumbnail: sizePostFx = "_t"; break; default: sizePostFx = string.Empty; break; } return(sizePostFx); }
public static Stream GetPhoto(PhotoSize size) { string path = HttpContext.Current.Server.MapPath("~/Images/"); switch (size) { case PhotoSize.Small: path += "placeholder-100.jpg"; break; case PhotoSize.Medium: path += "placeholder-200.jpg"; break; case PhotoSize.Large: path += "placeholder-600.jpg"; break; default: path += "placeholder-600.jpg"; break; } return(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)); }
public static HttpResponseMessage Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "analyzerandomphotos")] HttpRequestMessage req, TraceWriter log) { Startup.Init(); PostsTableAdapter postsTableAdapter = new PostsTableAdapter(); postsTableAdapter.Init(log); ImageAnalysisTableAdapter imageAnalysisTableAdapter = new ImageAnalysisTableAdapter(); imageAnalysisTableAdapter.Init(); PhotoToAnalyzeQueueAdapter photoToAnalyzeQueueAdapter = new PhotoToAnalyzeQueueAdapter(); photoToAnalyzeQueueAdapter.Init(); string blobBaseUrl = ConfigurationManager.AppSettings["BlobBaseUrl"]; int blogsLimit = 50; int photosInBlogLimit = 10; BlogInfoTableAdapter blogInfoTableAdapter = new BlogInfoTableAdapter(); blogInfoTableAdapter.Init(); List <BlogStats> blogStats = blogInfoTableAdapter.GetBlogStats(); log.Info($"Got {blogStats.Count} blogs to index"); Random random = new Random(); blogStats.Shuffle(random); blogStats = blogStats.Take(blogsLimit).ToList(); int totalCount = 0; foreach (string blogname in blogStats.Select(x => x.RowKey)) { int analyzedInBlogCount = 0; List <PostEntity> noteCounts = postsTableAdapter.GetPostNoteCounts(blogname).OrderByDescending(x => x.NoteCount).ToList(); log.Info($"Got note counts for {noteCounts.Count} posts in blog {blogname}"); foreach (PostEntity noteCountPost in noteCounts) { PostEntity postEntity = postsTableAdapter.GetPost(blogname, noteCountPost.RowKey); if (postEntity == null) { log.Warning($"Post {blogname}/{noteCountPost.RowKey} not found, skipping"); continue; } if (string.IsNullOrEmpty(postEntity.PhotoBlobUrls)) { continue; } List <Photo> sitePhotos = JsonConvert.DeserializeObject <List <Photo> >(postEntity.PhotoBlobUrls); foreach (Photo photo in sitePhotos) { List <PhotoSize> sortedSizes = photo.Sizes.OrderByDescending(x => x.Nominal).ToList(); PhotoSize original = sortedSizes.FirstOrDefault(); if (original == null) { continue; } string url = blobBaseUrl + "/" + original.Container + "/" + photo.Name + "_" + original.Nominal + "." + photo.Extension; if (imageAnalysisTableAdapter.GetImageAnalysis(url) != null) { log.Info($"Image {url} already analyzed"); continue; } PhotoToAnalyze message = new PhotoToAnalyze { Blog = blogname, PostDate = postEntity.Date, Url = url }; photoToAnalyzeQueueAdapter.Send(message); log.Info($"Published PhotoToAnalyze message with URL {url}"); analyzedInBlogCount++; totalCount++; } if (analyzedInBlogCount >= photosInBlogLimit) { break; } } } return(req.CreateResponse(HttpStatusCode.OK, $"Will analyze {totalCount} new photos")); }
/// <summary> /// Resize Image Async /// </summary> /// <param name="filePath">The file image path</param> /// <param name="photoSize">Photo size to go to.</param> /// <returns>True if rotation or compression occured, else false</returns> public Task <bool> ResizeAsync(string filePath, PhotoSize photoSize, int quality, int customPhotoSize) { if (string.IsNullOrWhiteSpace(filePath)) { return(Task.FromResult(false)); } try { return(Task.Run(() => { try { if (photoSize == PhotoSize.Full) { return false; } var percent = 1.0f; switch (photoSize) { case PhotoSize.Large: percent = .75f; break; case PhotoSize.Medium: percent = .5f; break; case PhotoSize.Small: percent = .25f; break; case PhotoSize.Custom: percent = (float)customPhotoSize / 100f; break; } //First decode to just get dimensions var options = new BitmapFactory.Options { InJustDecodeBounds = true }; //already on background task BitmapFactory.DecodeFile(filePath, options); var finalWidth = (int)(options.OutWidth * percent); var finalHeight = (int)(options.OutHeight * percent); //calculate sample size options.InSampleSize = CalculateInSampleSize(options, finalWidth, finalHeight); //turn off decode options.InJustDecodeBounds = false; //this now will return the requested width/height from file, so no longer need to scale using (var originalImage = BitmapFactory.DecodeFile(filePath, options)) { //always need to compress to save back to disk using (var stream = File.Open(filePath, FileMode.Create, FileAccess.ReadWrite)) { originalImage.Compress(Bitmap.CompressFormat.Jpeg, quality, stream); stream.Close(); } originalImage.Recycle(); // Dispose of the Java side bitmap. GC.Collect(); return true; } } catch (Exception ex) { #if DEBUG throw ex; #else return false; #endif } })); } catch (Exception ex) { #if DEBUG throw ex; #else return(Task.FromResult(false)); #endif } }
/// <summary> /// Rotate an image if required and saves it back to disk. /// </summary> /// <param name="filePath">The file image path</param> /// <param name="photoSize">Photo size to go to.</param> /// <returns>True if rotation or compression occured, else false</returns> public Task <bool> FixOrientationAndResizeAsync(string filePath, PhotoSize photoSize, int quality, int customPhotoSize) { if (string.IsNullOrWhiteSpace(filePath)) { return(Task.FromResult(false)); } try { return(Task.Run(() => { try { //First decode to just get dimensions var options = new BitmapFactory.Options { InJustDecodeBounds = true }; //already on background task BitmapFactory.DecodeFile(filePath, options); var rotation = GetRotation(filePath); // if we don't need to rotate, aren't resizing, and aren't adjusting quality then simply return if (rotation == 0 && photoSize == PhotoSize.Full && quality == 100) { return false; } var percent = 1.0f; switch (photoSize) { case PhotoSize.Large: percent = .75f; break; case PhotoSize.Medium: percent = .5f; break; case PhotoSize.Small: percent = .25f; break; case PhotoSize.Custom: percent = (float)customPhotoSize / 100f; break; } var finalWidth = (int)(options.OutWidth * percent); var finalHeight = (int)(options.OutHeight * percent); //calculate sample size options.InSampleSize = CalculateInSampleSize(options, finalWidth, finalHeight); //turn off decode options.InJustDecodeBounds = false; //this now will return the requested width/height from file, so no longer need to scale var originalImage = BitmapFactory.DecodeFile(filePath, options); if (finalWidth != originalImage.Width || finalHeight != originalImage.Height) { originalImage = Bitmap.CreateScaledBitmap(originalImage, finalWidth, finalHeight, true); } //if we need to rotate then go for it. //then compresse it if needed if (rotation != 0) { var matrix = new Matrix(); matrix.PostRotate(rotation); using (var rotatedImage = Bitmap.CreateBitmap(originalImage, 0, 0, originalImage.Width, originalImage.Height, matrix, true)) { //always need to compress to save back to disk using (var stream = File.Open(filePath, FileMode.Create, FileAccess.ReadWrite)) { rotatedImage.Compress(Bitmap.CompressFormat.Jpeg, quality, stream); stream.Close(); } rotatedImage.Recycle(); } originalImage.Recycle(); originalImage.Dispose(); // Dispose of the Java side bitmap. GC.Collect(); //Save out new exif data SetExifData(filePath, Orientation.Normal); return true; } //always need to compress to save back to disk using (var stream = File.Open(filePath, FileMode.Create, FileAccess.ReadWrite)) { originalImage.Compress(Bitmap.CompressFormat.Jpeg, quality, stream); stream.Close(); } originalImage.Recycle(); originalImage.Dispose(); // Dispose of the Java side bitmap. GC.Collect(); return true; } catch (Exception ex) { #if DEBUG throw ex; #else return false; #endif } })); } catch (Exception ex) { #if DEBUG throw ex; #else return(Task.FromResult(false)); #endif } }
public Photo(string uri, PhotoSize psize) { this.uri = new Uri(uri); this.photoSize = psize; Status = PhotoStatus.New; }
public string GetUrlBySize(PhotoSize photoSize) { string url = ""; switch (photoSize) { case PhotoSize.Full: { url = this.FullUrl; break; } case PhotoSize.Large: { url = this.LargeUrl; break; } case PhotoSize.Medium: { url = this.MediumUrl; break; } case PhotoSize.Small: { url = this.SmallUrl; break; } case PhotoSize.Thumb: default : { url = this.ThumbUrl; break; } } return url; }
/// <summary> /// This is the event handler for PrintManager.PrintTaskRequested. /// In order to ensure a good user experience, the system requires that the app handle the PrintTaskRequested event within the time specified /// by PrintTaskRequestedEventArgs->Request->Deadline. /// Therefore, we use this handler to only create the print task. /// The print settings customization can be done when the print document source is requested. /// </summary> /// <param name="sender">The print manager for which a print task request was made.</param> /// <param name="e">The print taks request associated arguments.</param> protected override void PrintTaskRequested(Windows.Graphics.Printing.PrintManager sender, Windows.Graphics.Printing.PrintTaskRequestedEventArgs e) { PrintTask printTask = null; printTask = e.Request.CreatePrintTask("C# Printing SDK Sample", sourceRequestedArgs => { PrintTaskOptionDetails printDetailedOptions = PrintTaskOptionDetails.GetFromPrintTaskOptions(printTask.Options); // Choose the printer options to be shown. // The order in which the options are appended determines the order in which they appear in the UI printDetailedOptions.DisplayedOptions.Clear(); printDetailedOptions.DisplayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.MediaSize); printDetailedOptions.DisplayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Copies); // Create a new list option. PrintCustomItemListOptionDetails photoSize = printDetailedOptions.CreateItemListOption("photoSize", "Photo Size"); photoSize.AddItem("SizeFullPage", "Full Page"); photoSize.AddItem("Size4x6", "4 x 6 in"); photoSize.AddItem("Size5x7", "5 x 7 in"); photoSize.AddItem("Size8x10", "8 x 10 in"); // Add the custom option to the option list. printDetailedOptions.DisplayedOptions.Add("photoSize"); PrintCustomItemListOptionDetails scaling = printDetailedOptions.CreateItemListOption("scaling", "Scaling"); scaling.AddItem("ShrinkToFit", "Shrink To Fit"); scaling.AddItem("Crop", "Crop"); // Add the custom option to the option list. printDetailedOptions.DisplayedOptions.Add("scaling"); // Set default orientation to landscape. printTask.Options.Orientation = PrintOrientation.Landscape; // Register for print task option changed notifications. printDetailedOptions.OptionChanged += PrintDetailedOptionsOptionChanged; // Register for print task Completed notification. // Print Task event handler is invoked when the print job is completed. printTask.Completed += async(s, args) => { await scenarioPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { ClearPageCollection(); // Reset image options to default values. this.photoScale = Scaling.ShrinkToFit; this.photoSize = PhotoSize.SizeFullPage; // Reset the current page description currentPageDescription = null; // Notify the user when the print operation fails. if (args.Completion == PrintTaskCompletion.Failed) { MainPage.Current.NotifyUser("Failed to print.", NotifyType.ErrorMessage); } }); }; // Set the document source. sourceRequestedArgs.SetSource(printDocumentSource); }); }
public async Task<List<string>> GetPhotos(string keyword, PhotoSize photoSize = PhotoSize.Large, int resultsPerPage = 200, int pageNumber = 1) { List<string> photoUrls = await _flickrPhotoService.GetPhotosByKeyword(keyword, photoSize, resultsPerPage, pageNumber); return photoUrls; }
public static string GetPhotoSizeCode(PhotoSize imageSize) { string res = ""; switch (imageSize) { case PhotoSize.Custom: res = "custom"; break; case PhotoSize.Small: res = "s"; break; case PhotoSize.Medium: res = "m"; break; case PhotoSize.Large: res = "l"; break; case PhotoSize.XLarge: res = "xl"; break; case PhotoSize.Percentage: res = "percentage"; break; case PhotoSize.Original: break; default: break; } return res; }
public string GetImageUrl(PhotoSize size = PhotoSize.Medium) { string sizeSuffixe = "z"; if (size == PhotoSize.Medium) sizeSuffixe = "z"; else if (size == PhotoSize.Large) sizeSuffixe = "b"; return "http://farm" + Farm + ".staticflickr.com/" + Server + "/" + ResourceId + "_" + Secret + "_" + sizeSuffixe + ".jpg"; }
public static string GetPreviewSrc(string imageUrl, PhotoSize photoSize, int customWidth) { string res = ""; res = GetPreviewSrc(imageUrl, GetPhotoSizeCode(photoSize), customWidth); return res; }
public static Stream GetFirstPhoto(int albumid, PhotoSize size) { using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Personal"].ConnectionString)) { using (SqlCommand command = new SqlCommand("GetFirstPhoto", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@AlbumID", albumid)); command.Parameters.Add(new SqlParameter("@Size", (int)size)); bool filter = !(HttpContext.Current.User.IsInRole("Friends") || HttpContext.Current.User.IsInRole("Administrators")); command.Parameters.Add(new SqlParameter("@IsPublic", filter)); connection.Open(); object result = command.ExecuteScalar(); try { return new MemoryStream((byte[])result); } catch { return null; } } } }
public static Stream GetPhoto(int photoid, PhotoSize size) { using ( var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Personal"].ConnectionString)) { using (var command = new SqlCommand("GetPhoto", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@PhotoID", photoid)); command.Parameters.Add(new SqlParameter("@Size", Convert.ToInt32(size))); var filter = !(HttpContext.Current.User.IsInRole("Friends") | HttpContext.Current.User.IsInRole("Administrators")); command.Parameters.Add(new SqlParameter("@IsPublic", filter)); connection.Open(); var result = (byte[]) command.ExecuteScalar(); try { return new MemoryStream(result); } catch { return null; } } } }
public static Stream GetPhoto(PhotoSize size) { var path = HttpContext.Current.Server.MapPath("~/App_Themes/White/Images/"); switch (size) { case PhotoSize.Small: path = (path + "placeholder-100.jpg"); break; case PhotoSize.Medium: path = (path + "placeholder-200.jpg"); break; case PhotoSize.Large: path = (path + "placeholder-600.jpg"); break; default: path = (path + "placeholder-600.jpg"); break; } return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); }
string IPhotoRepository.GetSizedPhotoUrl(string id, PhotoSize size) { if (size == PhotoSize.Original) { string method = Helper.GetExternalMethodName(); string requestUrl = BuildUrl(method, "photo_id", id); XmlElement doc = elementProxy.GetResponseElement(requestUrl); var query = from sizes in doc.Descendants("size") select new PhotoSizeWrapper { Label = sizes.Attribute("label").Value ?? string.Empty, Url = sizes.Attribute("source").Value ?? string.Empty }; PhotoSizeWrapper[] sizeWrapper = query.ToArray<PhotoSizeWrapper>(); try { return sizeWrapper[(int)size].Url; } catch { return null; } } return null; }
private string PhotoDetailUrl(string photoId, PhotoSize size) { return (this as IPhotoRepository).GetSizedPhotoUrl(photoId, size); }
public PhotosPrintHelper(Page scenarioPage) : base(scenarioPage) { photoSize = PhotoSize.SizeFullPage; photoScale = Scaling.ShrinkToFit; }
public static Stream GetFirstPhoto(int albumId, PhotoSize size) { var service = GetService(); return(service.GetFirstPhoto(albumId, size)); }
/// <summary> /// Option change event handler /// </summary> /// <param name="sender">The print task option details for which an option changed.</param> /// <param name="args">The event arguments containing the id of the changed option.</param> private async void PrintDetailedOptionsOptionChanged(PrintTaskOptionDetails sender, PrintTaskOptionChangedEventArgs args) { bool invalidatePreview = false; // For this scenario we are interested only when the 2 custom options change (photoSize & scaling) in order to trigger a preview refresh. // Default options that change page aspect will trigger preview invalidation (refresh) automatically. // It is safe to ignore verifying other options and(or) combinations here because during Paginate event(CreatePrintPreviewPages) we check if the PageDescription changed. if (args.OptionId == null) { return; } string optionId = args.OptionId.ToString(); if (optionId == "photoSize") { IPrintOptionDetails photoSizeOption = sender.Options[optionId]; string photoSizeValue = photoSizeOption.Value as string; if (!string.IsNullOrEmpty(photoSizeValue)) { switch (photoSizeValue) { case "SizeFullPage": photoSize = PhotoSize.SizeFullPage; break; case "Size4x6": photoSize = PhotoSize.Size4x6; break; case "Size5x7": photoSize = PhotoSize.Size5x7; break; case "Size8x10": photoSize = PhotoSize.Size8x10; break; } invalidatePreview = true; } } if (optionId == "scaling") { IPrintOptionDetails scalingOption = sender.Options[optionId]; string scalingValue = scalingOption.Value as string; if (!string.IsNullOrEmpty(scalingValue)) { switch (scalingValue) { case "Crop": photoScale = Scaling.Crop; break; case "ShrinkToFit": photoScale = Scaling.ShrinkToFit; break; } invalidatePreview = true; } } // Invalidate preview if one of the 2 options (photoSize, scaling) changed. if (invalidatePreview) { await scenarioPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, printDocument.InvalidatePreview); } }
public FlipViewPagePrintHelper(UserControl hostControl, NotifyHost hostStatusHandler = null, NotifyHost hostErrorHandler = null) : base(hostControl, hostStatusHandler, hostErrorHandler) { photoSize = PhotoSize.SizeFullPage; photoScale = Scaling.ShrinkToFit; }
/// <summary> /// calls flickr.photos.getInfo to get the photo object. /// </summary> /// <param name="id"></param> /// <param name="size"></param> /// <returns>Detail of photo</returns> Photo IPhotoRepository.GetPhotoDetail(string id, PhotoSize size) { this.PhotoSize = size; string method = Helper.GetExternalMethodName(); string token = authRepo.Authenticate(Permission.Delete.ToString(), false); string sig = base.GetSignature(method, true, "photo_id", id, "auth_token", token); string requestUrl = BuildUrl(method, "photo_id", id, "auth_token", token, "api_sig", sig); XmlElement doc = elementProxy.GetResponseElement(requestUrl); var query = from photo in doc.Descendants("photo") select new Photo { Id = photo.Attribute("id").Value, FarmId = photo.Attribute("farm").Value, ServerId = photo.Attribute("server").Value, SecretId = photo.Attribute("secret").Value, Title = photo.Element("title").InnerText, User = photo.Element("owner").Attribute("username").Value ?? string.Empty, NsId = photo.Element("owner").Attribute("nsid").Value ?? string.Empty, Description = photo.Element("description").InnerText ?? string.Empty, DateUploaded = photo.Element("dates").Attribute("posted").Value ?? string.Empty, DateTaken = photo.Element("dates").Attribute("taken").Value ?? string.Empty, LastUpdated = photo.Element("dates").Attribute("lastupdate").Value ?? string.Empty, Tags = (from tag in photo.Descendants("tag") select tag.InnerText ?? string.Empty).ToArray(), PhotoSize = size, WebUrl = (from photoPage in photo.Descendants("url") where photoPage.Attribute("type").Value == "photopage" select photoPage.InnerText ).First(), Url = PhotoDetailUrl(photo.Attribute("id").Value, size) }; return query.Single<Photo>(); }
public static Stream GetPhoto(PhotoSize size) { string path = HttpContext.Current.Server.MapPath("~/Gallery/BlankPhoto/"); switch (size) { case PhotoSize.Small: path += "placeholder-100.jpg"; break; case PhotoSize.Medium: path += "placeholder-200.jpg"; break; case PhotoSize.Large: path += "placeholder-600.jpg"; break; default: path += "placeholder-600.jpg"; break; } return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); }
public FileResult Photo(string name, PhotoSize? size) { return SiteHelper.GetHeroPhoto(name, size.GetValueOrDefault(PhotoSize.Small)); }
public static Stream GetFirstPhoto(int albumid, PhotoSize size) { int maxHeight = 150; int maxWidth = 200; string strPath = ""; MemoryStream memStreamPhoto = null; try { string strSQl = @" SELECT TOP 1 'http://eepcindia.org//GALLERYPHOTO//'+ PHOTO_FOLDER_NAME+'//'+ PHOTO_FILENAME AS PHOTO_PATH FROM PHOTO_MASTER WHERE OCCASION_ID=" + albumid; //strPath = Convert.ToString(objDbHelper.gExecuteScalar(CommandType.Text, strSQl)); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString)) { using (SqlCommand command = new SqlCommand(strSQl, connection)) { command.CommandType = CommandType.Text; connection.Open(); strPath = Convert.ToString(command.ExecuteScalar()); } } string PhotoPath = strPath; Bitmap objBitmap = LoadImageFromURL(PhotoPath); // System.Drawing.Image img = System.Drawing.Image.FromFile(PhotoPath); string extension = "jpg"; //System.IO.Path.GetExtension(PhotoPath); //System.IO.Path.GetExtension(HttpContext.Current.Server.MapPath(strPath)); int width = objBitmap.Size.Width; int height = objBitmap.Size.Height; bool doWidthResize = (maxWidth > 0 && width > maxWidth && width > maxHeight); bool doHeightResize = (maxHeight > 0 && height > maxHeight && height > maxWidth); //only resize if the image is bigger than the max if (doWidthResize || doHeightResize) { int iStart; Decimal divider; if (doWidthResize) { iStart = width; divider = Math.Abs((Decimal)iStart / (Decimal)maxWidth); width = maxWidth; height = (int)Math.Round((Decimal)(height / divider)); } else { iStart = height; divider = Math.Abs((Decimal)iStart / (Decimal)maxHeight); height = maxHeight; width = (int)Math.Round((Decimal)(width / divider)); } System.Drawing.Image newImg = objBitmap.GetThumbnailImage(width, height, null, new System.IntPtr()); using (MemoryStream ms = new MemoryStream()) { if (extension.IndexOf("jpg") > -1) { newImg.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); } else if (extension.IndexOf("png") > -1) { newImg.Save(ms, System.Drawing.Imaging.ImageFormat.Png); } else if (extension.IndexOf("gif") > -1) { newImg.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); } else // if (extension.IndexOf("bmp") > -1) { newImg.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); } memStreamPhoto = new MemoryStream((byte[])ms.ToArray()); } } } catch { return null; } return memStreamPhoto; }
public static Bitmap ResizeImage (string filePath, PhotoSize photoSize) { var percent = 1.0f; switch (photoSize) { case PhotoSize.Large: percent = .75f; break; case PhotoSize.Medium: percent = .5f; break; case PhotoSize.Small: percent = .25f; break; } var originalImage = BitmapFactory.DecodeFile(filePath); var rotatedImage = Bitmap.CreateScaledBitmap(originalImage, (int)(originalImage.Width * percent), (int)(originalImage.Height * percent), false); originalImage.Recycle(); return rotatedImage; }
private IEnumerable<Photo> GetPhotos(string requestUrl, PhotoSize size) { XmlElement doc = elementProxy.GetResponseElement(requestUrl); XmlElement photosElement = doc.Element("photos"); CollectionBuilder<Photo> builder = new CollectionBuilder<Photo>("photos"); CollectionBuilder<CommonAttribute> commBuilder = new CollectionBuilder<CommonAttribute>("photos"); CommonAttribute sharedProperty = commBuilder.ToCollection(doc, null).Single(); return builder.ToCollection(photosElement, photo => { photo.Url = (this as IPhotoRepository).GetSizedPhotoUrl(photo.Id, size) ?? string.Empty; photo.PhotoSize = size; photo.SharedProperty = sharedProperty; }); }
public static byte[] ResizeImageFile(byte[] imageFile, PhotoSize size) { using (System.Drawing.Image original = System.Drawing.Image.FromStream(new MemoryStream(imageFile))) { int targetH, targetW; if (size == PhotoSize.Small || size == PhotoSize.Medium) { // regardless of orientation, // the *height* is constant for thumbnail images (UI constraint) if (original.Height > original.Width) { if (size == PhotoSize.Small) targetH = DefaultValues.FixedSmallImageHeight; else targetH = DefaultValues.FixedMediumImageHeight; targetW = (int)(original.Width * ((float)targetH / (float)original.Height)); } else { if (size == PhotoSize.Small) targetW = DefaultValues.FixedSmallImageWidth; else targetW = DefaultValues.FixedMediumImageWidth; targetH = (int)(original.Height * ((float)targetW / (float)original.Width)); } } else { // for full preview, we scale proportionally according to orienation if (original.Height > original.Width) { targetH = Math.Min(original.Height, DefaultValues.MaxFullImageSize); targetW = (int)(original.Width * ((float)targetH / (float)original.Height)); } else { targetW = Math.Min(original.Width, DefaultValues.MaxFullImageSize); targetH = (int)(original.Height * ((float)targetW / (float)original.Width)); } } using (System.Drawing.Image imgPhoto = System.Drawing.Image.FromStream(new MemoryStream(imageFile))) { // Create a new blank canvas. The resized image will be drawn on this canvas. using (Bitmap bmPhoto = new Bitmap(targetW, targetH, PixelFormat.Format24bppRgb)) { bmPhoto.SetResolution(72, 72); using (Graphics grPhoto = Graphics.FromImage(bmPhoto)) { grPhoto.SmoothingMode = SmoothingMode.AntiAlias; grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic; grPhoto.PixelOffsetMode = PixelOffsetMode.HighQuality; grPhoto.DrawImage(imgPhoto, new Rectangle(0, 0, targetW, targetH), 0, 0, original.Width, original.Height, GraphicsUnit.Pixel); MemoryStream mm = new MemoryStream(); bmPhoto.Save(mm, System.Drawing.Imaging.ImageFormat.Jpeg); return mm.GetBuffer(); } } } } }
/// <summary> /// Searchs the photos for supplied name value settings. /// </summary> /// <param name="index">Index</param> /// <param name="pageLen">Number of items on each page</param> /// <param name="photoSize"></param> /// <param name="token">Authentication token, if logged in</param> /// <param name="args">Search criteria</param> /// <returns>list of photos</returns> IEnumerable<Photo> IPhotoRepository.Search(int index, int pageLen, PhotoSize photoSize, string token, params object[] args) { string method = Helper.GetExternalMethodName(); string sig = string.Empty; if (!string.IsNullOrEmpty(token)) { IDictionary<string, string> sorted = new Dictionary<string, string>(); ProcessArguments(args, sorted); ProcessArguments(new object[] { "page", index.ToString(), "per_page", pageLen.ToString(), "auth_token", token }, sorted); sig = base.GetSignature(method, true, sorted); } IDictionary<string, string> dicionary = new Dictionary<string, string>(); dicionary.Add(Helper.BASE_URL + "?method", method); dicionary.Add("api_key", Provider.GetCurrentFlickrSettings().ApiKey); ProcessArguments(args, dicionary); ProcessArguments( new object [] {"api_sig", sig, "page", index.ToString(), "per_page", pageLen.ToString(), "auth_token", token }, dicionary); string requestUrl = GetUrl(dicionary); if (index < 1 || index > 500) { throw new FlickrException("Index must be between 1 and 500"); } return GetPhotos(requestUrl, photoSize); }
public static byte[] GetPhotoBytesById(int photoId, PhotoSize size) { return new byte [0]; }
public static string GetPreviewSrc2(string imageUrl, PhotoSize photoSize) { string res = ""; int width = GetPhotoSizeValue(photoSize).Width; res = GetPreviewSrc2(imageUrl, width, width); return res; }