How do I enable logging or debug output for ImageResizer in C#?
I'm using ImageResizer in C# app. Some of the functionality I want to use does not have an associated property in the Instructions object. The docs say, "Just because a key doesn't have a property wrapper doesn't mean you can't use it. i["key"] = value; isnt' that scary."
However, you can put any nonsense in the Instructions Dictionary and nothing will be reported. This means that if I've done something wrong I'm unlikely to notice my mistake.
How can I view log output that will tell me what ImageResizer is doing so I can catch my mistakes?
Roughly what I'm doing:
var instructions = new Instructions
{
Mode = FitMode.Max,
};
instructions["fastscale"] = "true";
instructions["down.filter"] = "RobidouxSharp";
var bitmapImage = new BitmapImage();
using (var stream = new MemoryStream())
{
var job = ImageBuilder.Current.Build(path, stream, instructions);
stream.Position = 0;
bitmapImage.BeginInit();
bitmapImage.StreamSource = stream;
bitmapImage.EndInit();
bitmapImage.Freeze();
}
See also questions close to this topic
-
Left right DTO to object AutoMapper- C#
We recently implemented automapper and currently looking to optimise assigning values from the DTO to model. currently we are doing something like
model.Property1 = dto.Property1; model.SomePropertyType = dto.PropertyType; model.Property2 = dto.Property2;
Now this could go pretty long and repetitive task to all Mapper classes. Is there a way to simplify this on AutoMapper?
-
Simple where statement from table takes an hour
I have this simple line:
var records = db.MyDbTable.Where(x => x.SupplierId.HasValue).ToList();
And it takes one hour to execute. I have 272 rows in the table. The table has one column that is NVARCHAR(MAX) and inside there are huge strings. How can I optimize the statement? Afterwards in code I have a foreach which goes through the records and processes them.
-
C# Dapper Inner children
I'm trying to select one Person from table. These are structures to select from:
CREATE TABLE [dbo].[EyeColor] ( [Id] INT PRIMARY KEY IDENTITY (1,1) NOT NULL, [Color] VARCHAR(50) UNIQUE NOT NULL ) CREATE TABLE [dbo].[Voivodeship] ( [Id] INT PRIMARY KEY IDENTITY (1,1) NOT NULL, [Name] VARCHAR(50) UNIQUE NOT NULL ) CREATE TABLE [dbo].[City] ( [Id] INT PRIMARY KEY NOT NULL, [Name] VARCHAR(50) NOT NULL, [VoivodeshipId] INT NOT NULL, CONSTRAINT [FK_CityVoivodeship] FOREIGN KEY ([VoivodeshipId]) REFERENCES [dbo].[Voivodeship]([Id]) ) CREATE TABLE [dbo].[Person] ( [Id] INT PRIMARY KEY IDENTITY (1,1) NOT NULL, [Name] VARCHAR (100) NOT NULL, [LastName] VARCHAR (100) NOT NULL, [Age] INT NOT NULL, [HasAnimal] BIT NOT NULL, [EyeColorId] INT NOT NULL, [CityId] INT NOT NULL, CONSTRAINT [FK_EyeColorPerson] FOREIGN KEY ([EyeColorId]) REFERENCES [dbo].[EyeColor]([Id]), CONSTRAINT [FK_CityPerson] FOREIGN KEY ([CityId]) REFERENCES [dbo].[City]([Id]) ) CREATE TABLE [dbo].[Animal] ( [Id] INT PRIMARY KEY IDENTITY (1,1) NOT NULL, [Name] VARCHAR (100) NOT NULL, [Kind] VARCHAR (100) NOT NULL, [Age] INT NOT NULL, [PersonId] INT NOT NULL, CONSTRAINT [FK_PersonAnimal] FOREIGN KEY ([PersonId]) REFERENCES [dbo].[Person]([Id]) )
In the end after selecting these entities everything is filled with data except EyeColor. I was trying to reorder splitOn parameters but it didn't work. I'm struggling how to map dapper to include EyeColor.
public Person GetPerson(int personId) { //TODO ogarnąć to gónwo (EyeColor się nie wypełnia - jest nullem) using (var connection = new SqlConnection(ConnectionStringParams.ConnectionString)) { var query = "SELECT * FROM Person p " + "JOIN EyeColor ec ON p.EyeColorId = ec.Id " + "JOIN City c ON p.CityId = c.Id " + "JOIN Voivodeship v ON c.VoivodeshipId = v.Id " + "WHERE p.Id = @personId"; var person = connection.Query<Person, EyeColor, City, Voivodeship, Person>(query, (p, ec, c, v) => { p.EyeColor = ec; p.City = c; p.City.Voivodeship = v; return p; }, new { personId }, null, true, "EyeColorId,CityId,VoivodeshipId", null, null).FirstOrDefault(); return person; } }
-
How to export data from some columns from Gridcontrol to Excel file?
I have a
WPF
project that usedGridcontrol
. There are 6 columns, I don't know how to export 1st,2nd,3rd column to anexcel
file? I have searched many documents but they don't helpful. -
c# WPF application use dos questions
i use c# to create WPF,i want to use dos with my application。and to get output。 my code :
process = new Process(); process.StartInfo.FileName = @"cmd.exe"; process.StartInfo.WorkingDirectory = "."; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardInput = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.CreateNoWindow = true; //Process.Start("cmd.exe"); process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler); process.Start(); process.StandardInput.WriteLine(@"c:"); process.StandardInput.WriteLine(@"help"); process.StandardInput.WriteLine(@"javac"); process.StandardInput.WriteLine(@"dir"); process.StandardInput.WriteLine(@"adb shell"); process.StandardInput.WriteLine(@"ipconfig"); //process.StandardInput.WriteLine("exit"); process.BeginOutputReadLine();
dos command is regular。but my java command is nothing。below my result: enter image description here
i hope someone can help me.thank you.
-
Text input differs from the value in the grid of WPF lookupedit
Text input differs from the value in the grid of WPF lookupedit
I want to enter text in the same way that the combobox in winform does. This means that new data can not be entered in the datasuorce, but new data is added to the datasuorce. When losing focus, the text string is still on lookupedit. And I want to do it in WPF devexpress. I have found that for WF combobox mode can help me do that, but in WPF, I do not find any solution?
-
using WebImage with Imageresizer to add watermark image mvc5 c#
I am trying to add an image watermark to an image which has been manipulated using ImageResizer. When I run code no error is generated, the image is saved in a folder alright but watermark is not written. Below is my code snippet. Should I be approaching this in a different way?
var fEType="jpg"; var pname="New"; ImageResizer.ImageJob i = new ImageResizer.ImageJob(file, "~/Content/Images/" + pname + ".<ext>", new ImageResizer.Instructions("width=1080&height=1080&mode=max;format=" + fEType + ";anchor=middlecenter")); i.CreateParentDirectory = true; i.Build(); // add watermark GetImageWatermark(i.FinalPath);
Method for Webimage
public void GetImageWatermark(string imageurl ) { var watermarkPath = HttpContext.Server.MapPath("~/images/logo.png"); var watermark = new WebImage(watermarkPath); var ImagePath = imageurl; new WebImage(ImagePath) .AddImageWatermark(watermark,25, 60,"Center","Middle",50) .Write(); }
-
imageresizer sqlreader caching for deleted image
I'm using imageresizer and the SQLreader plugin to get user profile images from my database. I'm using stored procedures like:
blobQuery: SELECT UserImage FROM User WHERE UserGUID=@id modifiedQuery: Select DateLastModified, DateCreated From User WHERE UserGUID=@id existsQuery: Select COUNT(UserGUID) From User WHERE UserGUID=@id AND UserImage IS NOT Null
this works great if there is no image, and i upload a new one. Or if there is a current image and i change it to a different one. it does not work if there is a current image, and i clear it out however. Clearing out the image doesn't delete the row in the user table, it just nulls out the image field for that user.
I'm using the following in my web.config:
<add name="SqlReader" prefix="~/usrimg/" connectionString="myConnectionstring" idType="UniqueIdentifier" blobQuery="User_ImageBlobQuery" modifiedQuery="User_ModifiedDateQuery" existsQuery="User_ImageExistsQuery" requireImageExtension="false" cacheUnmodifiedFiles="true" extensionPartOfId="false" checkForModifiedFiles="true" vpp="true" untrustedData="false" queriesAreStoredProcedures="true" />
and i'm using the following url to access the image:
http://localhost/Testsite/usrimg/#userid#.png?w=35&mode=max&404=BlankUserImage.png
i have checked the 'datelastmodified' field in the user table, and it definitely gets updated when you clear the user data, so i'm not sure why the image URL is still showing the old image, instead of the 404 one
-
Query string gets chopped off using ImageResizer remotereader plugin
I'm working with URLs like:
mysite.com/export/media.ashx?MediaID=d011f09ad9c443c9b539b4d4b6b6cc10
When I build URLs like this, I lose the query string from the remote site, e.g. "?MediaID=..." gets chopped off: