Meridium: Webbplatser för offentlig sektor

Width and height of an image

Skrivet av Johan Magnusson den 14 maj 2010 ImageVault 0 kommentarer

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.

 

Diskussion

Skriv kommentar

Ange kontrollordet i textfältet nedan.

Kategorier

Arkiv