Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • syn-rg 282 posts 425 karma points
    Apr 18, 2011 @ 08:00
    syn-rg
    0

    How to display the image thumbnail width and height values?

    I want to display the image thumbnail width and height values. How can I do this using:

    <xsl:value-of select="data [@alias = 'umbracoWidth']"/>
    <xsl:value-of select="data [@alias = 'umbracoHeight']"/>

    Some how it would have to be manipulated to look for the "_thumb.jpg" code and display the "thumb" width and height instead of the original width and height.

    Any ideas?

    Cheers,
    JV

     

  • Rich Green 2246 posts 4008 karma points
    Apr 18, 2011 @ 08:29
    Rich Green
    0

    Don't know off the top of my head but you could also use Imagegen to do exactly this, it's way more flexible too. Rich

  • syn-rg 282 posts 425 karma points
    Apr 18, 2011 @ 08:54
    syn-rg
    0

    Hi Rich,

    I'm using Imagegen. I have an image gallery, that has a "High resolution" and "Low resolution" image download option.

    The high resolution image is the original image uploaded, the low resolution is the JPG Imagegen cuts. _thumb_1024.jpg

    I can display the width and height of the original, but need a way of displaying the width and height of the _thumb_1024.jpg

    Here's how it displays on the front end:
    Low resolution image

    (2592 x 1944 px @ 72 dpi - RGB - 2.91 MB - jpg)

    High resolution image

    (2592 x 1944 px @ - RGB - 2.91 MB - jpg)

    Is it possible to display the _thumb_1024.jpg width and height? I'm thinking a C# method would probably work if I can't display the values any other way.

  • david 46 posts 81 karma points
    Apr 18, 2011 @ 09:51
    david
    0

    in c#

    int nodeId = 1234;
    var media = new umbraco.cms.businesslogic.media.Media(nodeId);
    var file = media.getProperty("umbracoFile");
    string url = file.Value.ToString().Replace("jpg", "_thumb_1024.jpg");
    Image img = Image.FromFile(HttpContext.Current.Server.MapPath(url));
    string.Format("{0} * {1}",img.Size.Width, img.Size.Height);

  • Rich Green 2246 posts 4008 karma points
    Apr 18, 2011 @ 10:09
    Rich Green
    0

    Hey JV,

    It seems like you are not using imagegen? If you are using imagegen to resize your image you know exactly the size they are going to be!

    Prehaps I'm confused about what you're trying to do?

    Rich

  • syn-rg 282 posts 425 karma points
    Apr 18, 2011 @ 11:27
    syn-rg
    0

    Hi Rich,

    What I'm trying to do is get the size of the _thumb_1024.jpg. I know one of the values, width or height, will be 1024px. I need to find out how to calculate what other value is.

    I realise that an image uploaded using Imagegen will create a jpg at 96 dpi.

    So an image (3200 x 2400 px @ 300 dpi) when uploaded will create an image (1024 x 768 px @ 96 dpi).

    I was hoping to just get the values of the _thumb_1024.jpg to use, but I think I'll have to use some Java or C# script to convert the umbracoWidth and umbracoHeight to suit an image with one value being 1024 px, and accounting for the change in 300 dpi and 96 dpi.

    Cheers,
    JV

  • david 46 posts 81 karma points
    Apr 18, 2011 @ 11:35
    david
    0

    You could add thumb height, thumb with and thumb resolution as properties on the media type and use the Media.AfterSave event to update them.  Then you'd only have to calulate it whenever the image is created or changed and not every time its displayed

  • syn-rg 282 posts 425 karma points
    Apr 19, 2011 @ 07:24
    syn-rg
    0

    Hi David,

    How do I add the the thumb height and thumb width to the media type? Do they have a special name? e.g. umbracoThumbWidth?

Please Sign in or register to post replies

Write your reply to:

Draft