Meridium: Webbplatser för offentlig sektor
Client or partner?
Forgot your password? Register
Svenska

Width and height of an image

Written by Fredrik Därth Monday, May 17, 2010 ImageVault 0 comments

When using ImageVault it is easy to get a image in any format and size you like using the API. Though in some circumstances it's not easy to determine the exact width and height of the result. For instance if you have only specified the width. And the editors also have their chance to get creative using the image editor to make adjustments to images.

Currently it's not possible to get this information using the API, but it is easily done if you are prepared to get under the hood.

<%@ Import Namespace="ImageStoreNET.Classes.Handlers" %>
<%@ Import Namespace="ImageStoreNET.Classes.Data" %>

<%
  FileWrapper fw = ImageHandler.
    ParseUrlAndGetImage(CurrentPage["IVImage"].ToString());

  DataObjectFormatInformation info = 
    DataFactory.Instance.ImageConverter.
      LoadDataObjectFormatInformation(fw.File.FullName);
%>

Filename = <%=fw.File.FullName%> <br />
Width = <%=info.Width%> <br />
Height = <%=info.Height %> <br />

In the example above I have a ImageVaultImage-property called IVImage which is used to get the url to the image, though any url to an ImageVault image would do.

Also note that the FileWrapper contains a DataObject which contains information about the image. But the information in any DataObject or IVDataObject is always about the original file so don't get fooled.

 

Discussion

Leave a comment

Enter verification word in the text field below.

Categories

Archive