I need to get the crop details - the uQuery component allows you to retrieve the URL of a specific crop, but I need the dimensions, i.e .the x, y, x2 and y2 values.
It's not specifically the "size" of the cropped image, but the location and extent of the crop (top left to bottom right)!
Hi Jeroen - yes, I knew the data was in the XML ... my problem was getting to it! I ended up with code like this:
var test = new Media(media.Id); var crops = test.getProperty("imageCropper").Value.ToString(); XmlNode cropArea = null; var xmlCrops = new XmlDocument(); xmlCrops.LoadXml(crops);
var x1 = Convert.ToInt32(cropArea.Attributes["x"].Value)
There is more code than the above, there are 3 text box crops and I get all 4 corners (x, y, x2, y2) but that is the basics of what I have working now. I'm not necessarily sure it is the best way but it works!
Get crop dimensions in UserControl
How do I get the crop details (x, y, x2, y2) for a specific crop?
I need to get these details in a C# UserControl. I'm sure that I am missing something obvious ....
Are you talking about image size or the crop on an existing image? Does this help?
http://webcache.googleusercontent.com/search?q=cache:bfO2UeTnB34J:stackoverflow.com/questions/111345/getting-image-dimensions-without-reading-the-entire-file+&cd=1&hl=en&ct=clnk&gl=uk
USed the cache version as the live version is offline atm
I need to get the crop details - the uQuery component allows you to retrieve the URL of a specific crop, but I need the dimensions, i.e .the x, y, x2 and y2 values.
It's not specifically the "size" of the cropped image, but the location and extent of the crop (top left to bottom right)!
Well the crop info is stored in xml. If you have the media xml with a cropper on it the media should look something like this:
You can than use LinqToXml to get the info you need.
Jeroen
Hi Jeroen - yes, I knew the data was in the XML ... my problem was getting to it! I ended up with code like this:
Then, to get the specific "crop" details:
And finally, extract the dimensions:
There is more code than the above, there are 3 text box crops and I get all 4 corners (x, y, x2, y2) but that is the basics of what I have working now. I'm not necessarily sure it is the best way but it works!
Something like that is probably the best way. I prefer LinqToXml because you can fetch the data with a LINQ query which could be shorter.
Jeroen
is working on a reply...