private async Task <ActionResult> Process(ImageParameters parameters) { var details = await ImageDetails.GetById(parameters.Id); var image = await ImageController.GetImage(parameters.Id); this.Response.RegisterForDispose(image); ImageController.Crop(image, parameters, details); ImageController.Resize(image, parameters); ImageController.Quality(image, parameters); ImageController.Metadata(image, details); return(this.Ok(image)); }
internal static IXmpMeta Get(ImageDetails details) { var xmp = XmpMetaFactory.Create(); var idNs = "https://id.parliament.uk/"; var schemaNs = $"{idNs}schema/"; XmpMetaFactory.SchemaRegistry.RegisterNamespace(idNs, "id"); XmpMetaFactory.SchemaRegistry.RegisterNamespace(schemaNs, "schema"); xmp.SetProperty(XmpConstants.NsIptccore, "CiAdrCity", "London"); xmp.SetProperty(XmpConstants.NsIptccore, "CiAdrCtry", "UK"); xmp.SetProperty(XmpConstants.NsIptccore, "CiAdrRegion", "London"); xmp.SetProperty(XmpConstants.NsIptccore, "CiEmailWork", "*****@*****.**"); xmp.SetProperty(XmpConstants.NsIptccore, "CiTelWork", "+447740424810"); xmp.SetProperty(XmpConstants.NsIptccore, "CiUrlWork", "http://www.mcandrewphoto.co.uk"); xmp.SetProperty(XmpConstants.NsPhotoshop, "Source", "Chris McAndrew / UK Parliament"); xmp.SetProperty(XmpConstants.NsPhotoshop, "Credit", "Chris McAndrew / UK Parliament (Attribution 3.0 Unported (CC BY 3.0))"); xmp.SetPropertyDate(XmpConstants.NsPhotoshop, "DateCreated", XmpDateTimeFactory.Create(2017, 6, 17, 11, 30, 41, 0)); xmp.SetProperty(XmpConstants.NsDC, "rights", "Attribution 3.0 Unported (CC BY 3.0)"); xmp.SetProperty(XmpConstants.NsDC, "title", $"{details.GivenName} {details.FamilyName}"); xmp.SetProperty(XmpConstants.NsDC, "description", $"{details.GivenName} {details.FamilyName} - UK Parliament official portraits 2017"); xmp.SetProperty(XmpConstants.NsDC, "creator", "Chris McAndrew / UK Parliament"); // <rdf:Description rdf:about="http://id.parliament.uk/IMAGE1" /> xmp.SetObjectName($"{idNs}{details.Id}"); // id:IMAGE1 a schema:Image xmp.SetProperty(XmpConstants.NsRdf, "type", $"{schemaNs}Image", new PropertyOptions { IsUri = true }); // id:IMAGE1 schema:parlHasSubject id:PERSON1 xmp.SetProperty(schemaNs, "imageHasSubject", details.MemberUri, new PropertyOptions { IsUri = true }); // id:PERSON1 a schema:Person xmp.SetQualifier(schemaNs, "imageHasSubject", XmpConstants.NsRdf, "type", $"{schemaNs}Person", new PropertyOptions { IsUri = true }); return(xmp); }
private static void Metadata(MagickImage image, ImageDetails details) { var xmp = MetadataController.Get(details); var xmpBuffer = XmpMetaFactory.SerializeToBuffer(xmp, new SerializeOptions()); var xmpProfile = new XmpProfile(xmpBuffer); image.AddProfile(xmpProfile); var iptcProfile = new IptcProfile(); iptcProfile.SetValue(IptcTag.City, "London"); iptcProfile.SetValue(IptcTag.Country, "UK"); iptcProfile.SetValue(IptcTag.Contact, "[email protected], +447740424810,http://www.mcandrewphoto.co.uk"); iptcProfile.SetValue(IptcTag.CopyrightNotice, "Attribution 3.0 Unported (CC BY 3.0)"); iptcProfile.SetValue(IptcTag.Title, $"{details.GivenName} {details.FamilyName}"); iptcProfile.SetValue(IptcTag.Source, "Chris McAndrew / UK Parliament"); iptcProfile.SetValue(IptcTag.Credit, "Chris McAndrew / UK Parliament (Attribution 3.0 Unported (CC BY 3.0))"); image.AddProfile(iptcProfile); }
private static void Crop(MagickImage image, ImageParameters parameters, ImageDetails details) { if (parameters.Crop is null) { return; } var crop = Configuration.Crops.SingleOrDefault(c => c.Name == parameters.Crop); if (crop.Name is null) { throw new UnkownCropException(); } var x = 1; if (!(crop.OffsetX is null)) { x = details.CenterX - crop.OffsetX.Value; } image.Crop(x, details.CenterY - crop.OffsetY, crop.Width, crop.Height); }
public async Task <IXmpMeta> Get(string id) { var details = await ImageDetails.GetById(id); return(MetadataController.Get(details)); }